Skip to content

Commit

Permalink
Move Rust basic from riotbuild to static-test-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysn committed Oct 2, 2024
1 parent 7e1b9bc commit 7c2657d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
17 changes: 2 additions & 15 deletions riotbuild/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ RUN \
ca-certificates \
ccache \
cmake \
curl \
cython3 \
gcc-multilib \
gdb \
Expand Down Expand Up @@ -324,27 +323,15 @@ RUN echo 'Installing python3 packages' >&2 \
&& pip3 install --no-cache-dir -r /tmp/requirements.txt \
&& rm /tmp/requirements.txt

# While sourcing ~/.cargo/env later would have the right short-term effect,
# we'd still need to set the right path even later when HOME is
# /data/riotbuild -- so setting it right away.
ENV PATH ${PATH}:/opt/rustup/.cargo/bin
# Install nightly Rust via rustup; this is needed for Rust-on-RIOT builds and
# contains all CARGO_TARGETs currently recognized for RIOT targets.
# Add Rust components needed for building, adding to installation from static-test-tools
#
# *_HOMEs moved to /opt to make them world readable. RUSTUP_HOME is set
# persistently in case someone in their image wants to do a quick `sudo rustup
# toolchain add` or similar; CARGO_HOME is not because the user will need to
# write there, and all rustup does here is to place some binaries that later
# fan out to RUSTUP_HOME anyway.
# See static-test-tools/Dockerfile for why which variables are set how.
#
# Components: rust-src is needed to run `-Z build-std=core`, which in turn is
# needed on AVR (which thus doesn't need the avr-unknown-gnu-atmega328 target;
# being able to build core might be useful for other targets as well).
ENV RUSTUP_HOME /opt/rustup/.rustup
RUN \
RUSTUP_HOME=/opt/rustup/.rustup \
CARGO_HOME=/opt/rustup/.cargo sh -c "\
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal && \
rustup component add rust-src && \
rustup target add i686-unknown-linux-gnu && \
rustup target add riscv32imac-unknown-none-elf && \
Expand Down
25 changes: 25 additions & 0 deletions static-test-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN \
apt-get -y --no-install-recommends install \
coccinelle \
cppcheck \
curl \
doxygen \
graphviz \
less \
Expand All @@ -35,3 +36,27 @@ RUN echo 'Installing python3 packages' >&2 && \

# Install uncrustify
COPY --from=ghcr.io/kaspar030/uncrustify-builder:latest /usr/bin/uncrustify /usr/bin/uncrustify

# Rust base installation

# While sourcing ~/.cargo/env later would have the right short-term effect,
# we'd still need to set the right path even later when HOME is
# /data/riotbuild -- so setting it right away.
ENV PATH ${PATH}:/opt/rustup/.cargo/bin

# Install Rust via rustup; this is needed for Rust-on-RIOT builds and contains
# all CARGO_TARGETs currently recognized for RIOT targets.
#
# *_HOMEs moved to /opt to make them world readable. RUSTUP_HOME is set
# persistently in case someone in their image wants to do a quick `sudo rustup
# toolchain add` or similar; CARGO_HOME is not because the user will need to
# write there, and all rustup does here is to place some binaries that later
# fan out to RUSTUP_HOME anyway.
#
# Components: fmt is needed for the static test tools as those do `cargo fmt`
# checks. More are added for riotbuild.
ENV RUSTUP_HOME /opt/rustup/.rustup
RUN \
CARGO_HOME=/opt/rustup/.cargo sh -c "\
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal && \
rustup component add rustfmt"

0 comments on commit 7c2657d

Please sign in to comment.