X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=setup-toolchain.sh;h=191ea4315a6b5a8a29e56f6440f88115c466e8b9;hb=6b3ee8f6000ea0fe88d1d19bceac9441a43d8694;hp=e95e0e207d10b9ed2a9799119c61b6b043c040bb;hpb=eae7b997dd41e397a2c01a5b6724d0b38353e686;p=rust.git diff --git a/setup-toolchain.sh b/setup-toolchain.sh index e95e0e207d1..191ea4315a6 100755 --- a/setup-toolchain.sh +++ b/setup-toolchain.sh @@ -1,21 +1,19 @@ -#!/bin/bash +#!/usr/bin/env bash # Set up the appropriate rustc toolchain set -e cd "$(dirname "$0")" -ERRNO=0 -RTIM_PATH=$(command -v rustup-toolchain-install-master) || ERRNO=$? +RTIM_PATH=$(command -v rustup-toolchain-install-master) || INSTALLED=false CARGO_HOME=${CARGO_HOME:-$HOME/.cargo} -# Check if people also install RTIM in other locations beside -# ~/.cargo/bin -if [[ "$ERRNO" -ne 0 ]] || [[ "$RTIM_PATH" == $CARGO_HOME/bin/rustup-toolchain-install-master ]]; then - cargo install -Z install-upgrade rustup-toolchain-install-master +# Check if RTIM is not installed or installed in other locations not in ~/.cargo/bin +if [[ "$INSTALLED" == false || "$RTIM_PATH" == $CARGO_HOME/bin/rustup-toolchain-install-master ]]; then + cargo +nightly install rustup-toolchain-install-master else VERSION=$(rustup-toolchain-install-master -V | grep -o "[0-9.]*") - REMOTE=$(cargo search rustup-toolchain-install-master | grep -o "[0-9.]*") + REMOTE=$(cargo +nightly search rustup-toolchain-install-master | grep -o "[0-9.]*") echo "info: skipping updating rustup-toolchain-install-master at $RTIM_PATH" echo " current version : $VERSION" echo " remote version : $REMOTE" @@ -28,5 +26,11 @@ if rustc +master -Vv 2>/dev/null | grep -q "$RUST_COMMIT"; then exit 0 fi -rustup-toolchain-install-master -f -n master -c rustc-dev -- "$RUST_COMMIT" +if [[ -n "$HOST_TOOLCHAIN" ]]; then + TOOLCHAIN=('--host' "$HOST_TOOLCHAIN") +else + TOOLCHAIN=() +fi + +rustup-toolchain-install-master -f -n master "${TOOLCHAIN[@]}" -c rustc-dev -c llvm-tools -- "$RUST_COMMIT" rustup override set master