Skip to content

Commit 79873cf

Browse files
committed
Merge branch 'nickez/fix-vendor-script'
2 parents 3b7aa33 + b47b314 commit 79873cf

5 files changed

Lines changed: 19 additions & 13 deletions

File tree

.containerversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
53
1+
54

Dockerfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,8 @@ ENV PATH=/opt/lcov-1.14/bin:$PATH
126126
# Install rust compiler
127127
ENV PATH=/opt/cargo/bin:$PATH
128128
ENV RUSTUP_HOME=/opt/rustup
129-
COPY src/rust/rust-toolchain.toml /tmp/rust-toolchain.toml
130-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | CARGO_HOME=/opt/cargo sh -s -- --default-toolchain $(grep -oP '(?<=channel = ")[^"]+' /tmp/rust-toolchain.toml) -y
131-
RUN rustup target add thumbv7em-none-eabi
132-
RUN rustup target add thumbv8m.main-none-eabihf
133-
RUN rustup component add rustfmt
134-
RUN rustup component add clippy
135-
RUN rustup component add rust-src
129+
COPY src/rust/rust-toolchain.toml rust-toolchain.toml
130+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | CARGO_HOME=/opt/cargo sh -s -- --default-toolchain $(grep -oP '(?<=channel = ")[^"]+' rust-toolchain.toml) -y
136131
RUN CARGO_HOME=/opt/cargo cargo install cbindgen --version 0.29.2 --locked
137132
RUN CARGO_HOME=/opt/cargo cargo install bindgen-cli --version 0.72.1 --locked
138133

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,4 @@ clean:
191191

192192
# When you vendor rust libs avoid duplicates
193193
vendor-rust-deps:
194-
(cd external; ./vendor-rust.sh)
194+
./external/vendor-rust.sh

external/vendor-rust.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
#
33
# Script for vendoring our dependencies, including the deps of core/alloc.
44
#
5-
# This script must be called from the <git-project-root>/src/rust directory. It will place the
6-
# dependencies in a directory called "vendor" in the current working directory.
5+
# This script can be called from any directory. It runs Cargo from the
6+
# <git-project-root>/src/rust directory so rustup loads rust-toolchain.toml, and places the
7+
# dependencies in <git-project-root>/external/vendor.
78
#
89
# For some reason Cargo needs to find the dependencies of all rust std libs. Since "test" depends
910
# on all the other ones, we take the toml-file from it. This means that we vendor libs that we
@@ -15,9 +16,16 @@
1516
# Copying the Cargo.lock file in the rust sysroot image requires root permissions. Therefore it is
1617
# done in the Dockerfile in our setup.
1718

19+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
21+
RUST_WORKSPACE_DIR="$REPO_ROOT/src/rust"
22+
VENDOR_DIR="../../external/vendor"
23+
24+
cd "$RUST_WORKSPACE_DIR"
25+
1826
RUST_SYSROOT="$(rustc --print=sysroot)"
1927

2028
RUSTC_BOOTSTRAP=1 cargo vendor \
21-
--manifest-path ../src/rust/Cargo.toml \
29+
--manifest-path Cargo.toml \
2230
--sync "$RUST_SYSROOT/lib/rustlib/src/rust/library/test/Cargo.toml" \
23-
vendor
31+
"$VENDOR_DIR"

src/rust/rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[toolchain]
22
channel = "1.93.1"
3+
components = ["clippy", "rust-analyzer", "rust-src", "rustfmt"]
4+
targets = ["thumbv7em-none-eabi", "thumbv8m.main-none-eabihf"]
5+
profile = "minimal"

0 commit comments

Comments
 (0)