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 *) toolchain=nightly;; 16 esac 17fi 18if [ "$OS" = "windows" ]; then 19 : "${TARGET?The TARGET environment variable must be set.}" 20 rustup set profile minimal 21 rustup update --force $toolchain-"$TARGET" 22 rustup default $toolchain-"$TARGET" 23else 24 rustup set profile minimal 25 rustup update --force $toolchain 26 rustup default $toolchain 27fi 28 29if [ -n "$TARGET" ]; then 30 echo "Install target" 31 rustup target add "$TARGET" 32fi 33 34if [ -n "$INSTALL_RUST_SRC" ]; then 35 echo "Install rust-src" 36 rustup component add rust-src 37fi 38 39if [ "$OS" = "windows" ]; then 40 if [ "$ARCH_BITS" = "i686" ]; then 41 echo "Install MinGW32" 42 choco install mingw --x86 --force 43 fi 44 45 echo "Find GCC libraries" 46 gcc -print-search-dirs 47 /usr/bin/find "C:\ProgramData\Chocolatey" -name "crt2*" 48 /usr/bin/find "C:\ProgramData\Chocolatey" -name "dllcrt2*" 49 /usr/bin/find "C:\ProgramData\Chocolatey" -name "libmsvcrt*" 50 51 if [ -n "$ARCH_BITS" ]; then 52 echo "Fix MinGW" 53 for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do 54 cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw$ARCH_BITS/$ARCH-w64-mingw32/lib/$i" "$(rustc --print sysroot)/lib/rustlib/$TARGET/lib" 55 done 56 fi 57fi 58 59echo "Query rust and cargo versions" 60command -v rustc 61command -v cargo 62command -v rustup 63rustc -Vv 64cargo -V 65rustup -Vv 66rustup show 67 68echo "Generate lockfile" 69N=5 70n=0 71until [ $n -ge $N ] 72do 73 if cargo generate-lockfile; then 74 break 75 fi 76 n=$((n+1)) 77 sleep 1 78done 79