xref: /rust-libc-0.2.174/ci/install-rust.sh (revision fe8470be)
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  # FIXME: Add `--no-self-update` to avoid CI failure.
17  rustup update --force $toolchain-"$TARGET" --no-self-update
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 [ "$OS" = "windows" ]; then
31  if [ "$ARCH_BITS" = "i686" ]; then
32    echo "Install MinGW32"
33    choco install mingw --x86 --force
34  fi
35
36  echo "Find GCC libraries"
37  gcc -print-search-dirs
38  /usr/bin/find "C:\ProgramData\Chocolatey" -name "crt2*"
39  /usr/bin/find "C:\ProgramData\Chocolatey" -name "dllcrt2*"
40  /usr/bin/find "C:\ProgramData\Chocolatey" -name "libmsvcrt*"
41
42  if [ -n "$ARCH_BITS" ]; then
43    echo "Fix MinGW"
44    for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do
45      cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw$ARCH_BITS/$ARCH-w64-mingw32/lib/$i" "$(rustc --print sysroot)/lib/rustlib/$TARGET/lib"
46    done
47  fi
48fi
49
50echo "Query rust and cargo versions"
51command -v rustc
52command -v cargo
53command -v rustup
54rustc -Vv
55cargo -V
56rustup -Vv
57rustup show
58
59echo "Generate lockfile"
60N=5
61n=0
62until [ $n -ge $N ]
63do
64  if cargo generate-lockfile; then
65    break
66  fi
67  n=$((n+1))
68  sleep 1
69done
70