]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/setup-toolchain.sh
Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2
[rust.git] / src / tools / clippy / setup-toolchain.sh
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 +nightly install rustup-toolchain-install-master
14 else
15     VERSION=$(rustup-toolchain-install-master -V | grep -o "[0-9.]*")
16     REMOTE=$(cargo +nightly 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