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