• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 [ -n "$INSTALL_RUST_SRC" ]; then
30  echo "Install rust-src"
31  rustup component add rust-src
32fi
33
34if [ "$OS" = "windows" ]; then
35  if [ "$ARCH_BITS" = "i686" ]; then
36    echo "Install MinGW32"
37    choco install mingw --x86 --force
38  fi
39
40  echo "Find GCC libraries"
41  gcc -print-search-dirs
42  /usr/bin/find "C:\ProgramData\Chocolatey" -name "crt2*"
43  /usr/bin/find "C:\ProgramData\Chocolatey" -name "dllcrt2*"
44  /usr/bin/find "C:\ProgramData\Chocolatey" -name "libmsvcrt*"
45
46  if [ -n "$ARCH_BITS" ]; then
47    echo "Fix MinGW"
48    for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do
49      cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw$ARCH_BITS/$ARCH-w64-mingw32/lib/$i" "$(rustc --print sysroot)/lib/rustlib/$TARGET/lib"
50    done
51  fi
52fi
53
54echo "Query rust and cargo versions"
55command -v rustc
56command -v cargo
57command -v rustup
58rustc -Vv
59cargo -V
60rustup -Vv
61rustup show
62
63echo "Generate lockfile"
64N=5
65n=0
66until [ $n -ge $N ]
67do
68  if cargo generate-lockfile; then
69    break
70  fi
71  n=$((n+1))
72  sleep 1
73done
74