1#!/usr/bin/env sh 2# This is intended to be used in CI only. 3 4set -eux 5 6echo "Setup toolchain" 7 8toolchain="${TOOLCHAIN:-nightly}" 9os="${OS:-}" 10 11case "$(uname -s)" in 12 Linux*) os=linux ;; 13 Darwin*) os=macos ;; 14 MINGW*) os=windows ;; 15 *) 16 echo "Unknown system $(uname -s)" 17 exit 1 18 ;; 19esac 20 21if [ "$os" = "windows" ] && [ -n "${TARGET:-}" ]; then 22 toolchain="$toolchain-$TARGET" 23 rustup set profile minimal 24fi 25 26rustup set profile minimal 27rustup update --force "$toolchain" --no-self-update 28rustup default "$toolchain" 29 30if [ -n "${TARGET:-}" ]; then 31 echo "Install target" 32 rustup target add "$TARGET" 33fi 34 35if [ -n "${INSTALL_RUST_SRC:-}" ]; then 36 echo "Install rust-src" 37 rustup component add rust-src 38fi 39 40if [ "$os" = "windows" ]; then 41 if [ "${ARCH_BITS:-}" = "i686" ]; then 42 echo "Install MinGW32" 43 choco install mingw --x86 --force 44 fi 45 46 echo "Find GCC libraries" 47 gcc -print-search-dirs 48 /usr/bin/find "C:\ProgramData\Chocolatey" -name "crt2*" 49 /usr/bin/find "C:\ProgramData\Chocolatey" -name "dllcrt2*" 50 /usr/bin/find "C:\ProgramData\Chocolatey" -name "libmsvcrt*" 51 52 if [ -n "${ARCH_BITS:-}" ]; then 53 echo "Fix MinGW" 54 for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do 55 cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw$ARCH_BITS/$ARCH-w64-mingw32/lib/$i" "$(rustc --print sysroot)/lib/rustlib/$TARGET/lib" 56 done 57 fi 58fi 59 60echo "Query rust and cargo versions" 61rustc -Vv 62cargo -V 63rustup -Vv 64rustup show 65 66echo "Generate lockfile" 67N=5 68n=0 69until [ $n -ge $N ]; do 70 if cargo generate-lockfile; then 71 break 72 fi 73 74 n=$((n+1)) 75 sleep 1 76done 77