2019-03-14 19:41:05 -07:00
|
|
|
#
|
|
|
|
# This file maintains the rust versions for use by CI.
|
|
|
|
#
|
2020-04-29 18:02:05 -07:00
|
|
|
# Obtain the environment variables without any automatic toolchain updating:
|
|
|
|
# $ source ci/rust-version.sh
|
2019-03-14 19:41:05 -07:00
|
|
|
#
|
2020-04-29 18:02:05 -07:00
|
|
|
# Obtain the environment variables updating both stable and nightly, only stable, or
|
|
|
|
# only nightly:
|
|
|
|
# $ source ci/rust-version.sh all
|
|
|
|
# $ source ci/rust-version.sh stable
|
2019-03-14 19:41:05 -07:00
|
|
|
# $ source ci/rust-version.sh nightly
|
2020-04-29 18:02:05 -07:00
|
|
|
|
|
|
|
# Then to build with either stable or nightly:
|
|
|
|
# $ cargo +"$rust_stable" build
|
2019-03-14 19:41:05 -07:00
|
|
|
# $ cargo +"$rust_nightly" build
|
|
|
|
#
|
|
|
|
|
2019-11-22 21:53:39 -08:00
|
|
|
if [[ -n $RUST_STABLE_VERSION ]]; then
|
|
|
|
stable_version="$RUST_STABLE_VERSION"
|
|
|
|
else
|
2022-12-19 08:00:14 -08:00
|
|
|
# read rust version from rust-toolchain.toml file
|
|
|
|
base="$(dirname "${BASH_SOURCE[0]}")"
|
|
|
|
# pacify shellcheck: cannot follow dynamic path
|
|
|
|
# shellcheck disable=SC1090,SC1091
|
|
|
|
source "$base/../scripts/read-cargo-variable.sh"
|
|
|
|
stable_version=$(readCargoVariable channel "$base/../rust-toolchain.toml")
|
2019-11-22 21:53:39 -08:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n $RUST_NIGHTLY_VERSION ]]; then
|
|
|
|
nightly_version="$RUST_NIGHTLY_VERSION"
|
|
|
|
else
|
2023-02-17 11:08:27 -08:00
|
|
|
nightly_version=2023-01-22
|
2019-11-22 21:53:39 -08:00
|
|
|
fi
|
|
|
|
|
2019-03-14 19:41:05 -07:00
|
|
|
|
2019-06-20 07:43:31 -07:00
|
|
|
export rust_stable="$stable_version"
|
|
|
|
export rust_stable_docker_image=solanalabs/rust:"$stable_version"
|
|
|
|
|
|
|
|
export rust_nightly=nightly-"$nightly_version"
|
|
|
|
export rust_nightly_docker_image=solanalabs/rust-nightly:"$nightly_version"
|
2019-03-14 19:41:05 -07:00
|
|
|
|
|
|
|
[[ -z $1 ]] || (
|
|
|
|
|
|
|
|
rustup_install() {
|
|
|
|
declare toolchain=$1
|
2020-06-15 21:40:53 -07:00
|
|
|
if ! cargo +"$toolchain" -V > /dev/null; then
|
|
|
|
echo "$0: Missing toolchain? Installing...: $toolchain" >&2
|
2019-03-14 19:41:05 -07:00
|
|
|
rustup install "$toolchain"
|
|
|
|
cargo +"$toolchain" -V
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
set -e
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
|
|
|
case $1 in
|
|
|
|
stable)
|
|
|
|
rustup_install "$rust_stable"
|
|
|
|
;;
|
|
|
|
nightly)
|
|
|
|
rustup_install "$rust_nightly"
|
|
|
|
;;
|
2020-04-29 18:02:05 -07:00
|
|
|
all)
|
|
|
|
rustup_install "$rust_stable"
|
|
|
|
rustup_install "$rust_nightly"
|
|
|
|
;;
|
2019-03-14 19:41:05 -07:00
|
|
|
*)
|
2020-06-15 21:40:53 -07:00
|
|
|
echo "$0: Note: ignoring unknown argument: $1" >&2
|
2019-03-14 19:41:05 -07:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
)
|