Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 5be2709

Browse files
committed
Add setup-toolchain.sh from rust-semverver
1 parent a50f3c9 commit 5be2709

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

ci/setup-toolchain.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
# Set up the appropriate rustc toolchain
3+
4+
set -e
5+
6+
cd "$(dirname "$0")"
7+
8+
RTIM_PATH=$(command -v rustup-toolchain-install-master) || INSTALLED=false
9+
CARGO_HOME=${CARGO_HOME:-$HOME/.cargo}
10+
11+
# Check if RTIM is not installed or installed in other locations not in ~/.cargo/bin
12+
if [[ "$INSTALLED" == false || "$RTIM_PATH" == $CARGO_HOME/bin/rustup-toolchain-install-master ]]; then
13+
cargo install rustup-toolchain-install-master
14+
else
15+
VERSION=$(rustup-toolchain-install-master -V | grep -o "[0-9.]*")
16+
REMOTE=$(cargo search rustup-toolchain-install-master | grep -o "[0-9.]*")
17+
echo "info: skipping updating rustup-toolchain-install-master at $RTIM_PATH"
18+
echo " current version : $VERSION"
19+
echo " remote version : $REMOTE"
20+
fi
21+
22+
RUST_COMMIT=$(git ls-remote https://github.com/rust-lang/rust master | awk '{print $1}')
23+
24+
if rustc +master -Vv 2>/dev/null | grep -q "$RUST_COMMIT"; then
25+
echo "info: master toolchain is up-to-date"
26+
exit 0
27+
fi
28+
29+
if [[ -n "$HOST_TOOLCHAIN" ]]; then
30+
TOOLCHAIN=('--host' "$HOST_TOOLCHAIN")
31+
else
32+
TOOLCHAIN=()
33+
fi
34+
35+
rustup-toolchain-install-master -f -n master "${TOOLCHAIN[@]}" -c rustc-dev -c llvm-tools -- "$RUST_COMMIT"
36+
rustup override set master
37+

0 commit comments

Comments
 (0)