-
-
Save Gankra/6a025b5cce9d9b047e46a5caeded3050 to your computer and use it in GitHub Desktop.
vendor-std.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/!bin/bash | |
# Vendors a project with the additional dependencies to build with `-Zbuild-std` | |
# | |
# The main problem is that Cargo won't naively see the lockfile for | |
# the Rust workspace in the `rust-src` component. To fix this, we | |
# just copy the lock to `test`, which we then pull in with vendor's | |
# `-s` flag. | |
# In case you need a specific nightly for your build | |
# e.g. nightly-2020-03-10 | |
NIGHTLY_VER=nightly | |
# Dir structure changed, not sure what date this is yet! | |
# Anything from october onward seems fine. | |
OLD_NIGHTLY=0 | |
# Need the rust-src component installed for this toolchain | |
rustup toolchain install $NIGHTLY_VER --force --component rust-src | |
rustc "+"$NIGHTLY_VER -V | |
TOOLCHAIN_PATH=$(rustc "+"$NIGHTLY_VER --print sysroot) | |
RUST_SRC=$TOOLCHAIN_PATH/lib/rustlib/src/rust/ | |
RUST_LOCK=$RUST_SRC/Cargo.lock | |
if ["$OLD_NIGHTLY" = "1"] ; then | |
RUST_TEST=$RUST_SRC/library/test/ | |
else | |
RUST_TEST=$RUST_SRC/src/libtest/ | |
fi | |
RUST_TEST_TOML=$RUST_TEST/Cargo.toml | |
# Copy the Cargo.lock for Rust to places `vendor` will see | |
cp $RUST_LOCK $RUST_TEST | |
# Actually do the vendor | |
cargo "+"$NIGHTLY_VER vendor -s $RUST_TEST_TOML | |
# You can now use build-std in a vendor like (substitute your own target triple): | |
# cargo "+"$NIGHTLY_VER build -Zbuild-std --target=x86_64-pc-windows-msvc | |
# If you compile with panic=abort, use this instead | |
# cargo "+"$NIGHTLY_VER build -Zbuild-std=panic_abort,std --target=x86_64-pc-windows-msvc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment