2019-10-20 21:44:28 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Install/update rust.
|
|
|
|
# The first argument should be the toolchain to install.
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
if [ -z "$1" ]
|
|
|
|
then
|
|
|
|
echo "First parameter must be toolchain to install."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
TOOLCHAIN="$1"
|
|
|
|
|
|
|
|
rustup set profile minimal
|
|
|
|
rustup component remove --toolchain=$TOOLCHAIN rust-docs || echo "already removed"
|
2020-07-07 21:08:51 +00:00
|
|
|
rustup update --no-self-update $TOOLCHAIN
|
2022-07-22 11:28:54 +00:00
|
|
|
if [ -n "$2" ]
|
|
|
|
then
|
|
|
|
TARGET="$2"
|
|
|
|
HOST=$(rustc -Vv | grep ^host: | sed -e "s/host: //g")
|
|
|
|
if [ "$HOST" != "$TARGET" ]
|
|
|
|
then
|
|
|
|
rustup component add llvm-tools-preview --toolchain=$TOOLCHAIN
|
|
|
|
rustup component add rust-std-$TARGET --toolchain=$TOOLCHAIN
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-10-20 21:44:28 +00:00
|
|
|
rustup default $TOOLCHAIN
|
|
|
|
rustup -V
|
|
|
|
rustc -Vv
|
|
|
|
cargo -V
|