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