1#!/usr/bin/env sh 2# This is intended to be used in CI only. 3 4set -ex 5 6echo "Setup toolchain" 7toolchain= 8if [ -n "$TOOLCHAIN" ]; then 9 toolchain=$TOOLCHAIN 10else 11 # Pin the nightly version as newer nightly versions break CI, 12 # https://github.com/rust-lang/rust/issues/103673 contains related information. 13 case "$TARGET" in 14 *android*) toolchain=nightly-2022-10-09;; 15 # FIXME: Unpin once mips' components are available on nightly. 16 # https://rust-lang.github.io/rustup-components-history/mips-unknown-linux-gnu.html 17 *mips*) toolchain=nightly-2023-07-04;; 18 *) toolchain=nightly;; 19 esac 20fi 21if [ "$OS" = "windows" ]; then 22 : "${TARGET?The TARGET environment variable must be set.}" 23 rustup set profile minimal 24 rustup update --force $toolchain-"$TARGET" 25 rustup default $toolchain-"$TARGET" 26else 27 rustup set profile minimal 28 rustup update --force $toolchain 29 rustup default $toolchain 30fi 31 32if [ -n "$TARGET" ]; then 33 echo "Install target" 34 rustup target add "$TARGET" 35fi 36 37if [ -n "$INSTALL_RUST_SRC" ]; then 38 echo "Install rust-src" 39 rustup component add rust-src 40fi 41 42if [ "$OS" = "windows" ]; then 43 if [ "$ARCH_BITS" = "i686" ]; then 44 echo "Install MinGW32" 45 choco install mingw --x86 --force 46 fi 47 48 echo "Find GCC libraries" 49 gcc -print-search-dirs 50 /usr/bin/find "C:\ProgramData\Chocolatey" -name "crt2*" 51 /usr/bin/find "C:\ProgramData\Chocolatey" -name "dllcrt2*" 52 /usr/bin/find "C:\ProgramData\Chocolatey" -name "libmsvcrt*" 53 54 if [ -n "$ARCH_BITS" ]; then 55 echo "Fix MinGW" 56 for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do 57 cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw$ARCH_BITS/$ARCH-w64-mingw32/lib/$i" "$(rustc --print sysroot)/lib/rustlib/$TARGET/lib" 58 done 59 fi 60fi 61 62echo "Query rust and cargo versions" 63command -v rustc 64command -v cargo 65command -v rustup 66rustc -Vv 67cargo -V 68rustup -Vv 69rustup show 70 71echo "Generate lockfile" 72N=5 73n=0 74until [ $n -ge $N ] 75do 76 if cargo generate-lockfile; then 77 break 78 fi 79 n=$((n+1)) 80 sleep 1 81done 82