forked from rust-lang/miri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rustup-toolchain
executable file
·46 lines (41 loc) · 1.51 KB
/
rustup-toolchain
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -e
# Manages a rustup toolchain called "miri".
#
# All commands set "miri" as the override toolchain for the current directory,
# and make the `rust-version` file match that toolchain.
#
# USAGE:
#
# ./rustup-toolchain: Update "miri" toolchain to match `rust-version` (the known-good version for this commit).
#
# ./rustup-toolchain HEAD: Update "miri" toolchain and `rust-version` file to latest rustc HEAD.
#
# ./rustup-toolchain $COMMIT: Update "miri" toolchain and `rust-version` file to match that commit.
# Make sure rustup-toolchain-install-master is installed.
if ! which rustup-toolchain-install-master >/dev/null; then
echo "Please install rustup-toolchain-install-master by running 'cargo install rustup-toolchain-install-master'"
exit 1
fi
# Determine new commit.
if [[ "$1" == "" ]]; then
NEW_COMMIT=$(cat rust-version)
elif [[ "$1" == "HEAD" ]]; then
NEW_COMMIT=$(git ls-remote https://github.com/rust-lang/rust/ HEAD | cut -f 1)
else
NEW_COMMIT="$1"
fi
echo "$NEW_COMMIT" > rust-version
# Check if we already are at that commit.
CUR_COMMIT=$(rustc +miri --version -v 2>/dev/null | egrep "^commit-hash: " | cut -d " " -f 2)
if [[ "$CUR_COMMIT" == "$NEW_COMMIT" ]]; then
echo "miri toolchain is already at commit $CUR_COMMIT."
rustup override set miri
exit 0
fi
# Install and setup new toolchain.
rustup toolchain uninstall miri
rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -- "$NEW_COMMIT"
rustup override set miri
# Cleanup.
cargo clean