summaryrefslogtreecommitdiffhomepage
path: root/ci/ci-rust-script.sh
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2019-10-22 09:47:58 +0200
committerLinus Färnstrand <linus@mullvad.net>2019-10-25 14:24:59 +0200
commit5900f4c4eb0e2d3521051f7ccbd3b0b96d492ddf (patch)
tree2643de58887dcf0c9952a09a76cd26c4e690ea3c /ci/ci-rust-script.sh
parent951c4ea946ad4430e5e0a3289417c774fb0cb610 (diff)
downloadmullvadvpn-5900f4c4eb0e2d3521051f7ccbd3b0b96d492ddf.tar.xz
mullvadvpn-5900f4c4eb0e2d3521051f7ccbd3b0b96d492ddf.zip
Move Windows rustup install to ci script
Diffstat (limited to 'ci/ci-rust-script.sh')
-rwxr-xr-xci/ci-rust-script.sh33
1 files changed, 20 insertions, 13 deletions
diff --git a/ci/ci-rust-script.sh b/ci/ci-rust-script.sh
index 0086936dbc..62f33005da 100755
--- a/ci/ci-rust-script.sh
+++ b/ci/ci-rust-script.sh
@@ -1,26 +1,33 @@
#!/usr/bin/env bash
-set -eu
+set -eux
RUST_TOOLCHAIN_CHANNEL=$1
RUSTFLAGS="--deny unused_imports --deny dead_code"
source env.sh ""
-RUST_EXTRA_COMPONENTS=""
-if [ "${RUST_TOOLCHAIN_CHANNEL}" = "nightly" ]; then
- RUST_EXTRA_COMPONENTS+=" -c rustfmt-preview"
-fi
+RUST_TARGET_ARG=""
+case "$(uname -s)" in
+ Linux*|Darwin*)
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
+ -y --default-toolchain none --profile minimal
+ ;;
+ MINGW*|MSYS_NT*)
+ curl -sSf -o rustup-init.exe https://win.rustup.rs/
+ ./rustup-init.exe -y --default-toolchain none --profile minimal --default-host x86_64-pc-windows-msvc
+ RUST_TARGET_ARG="--target x86_64-pc-windows-msvc"
+ ;;
+esac
+export PATH="$HOME/.cargo/bin/:$PATH"
-# Install Rust if on Linux or macOS
-if [[ "$(uname -s)" == "Linux" || "$(uname -s)" == "Darwin" ]]; then
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
- -y --default-toolchain $RUST_TOOLCHAIN_CHANNEL --profile minimal $RUST_EXTRA_COMPONENTS
- source $HOME/.cargo/env
-fi
+# Install the toolchain together with rustfmt. Here -c backtracks to last version where
+# the component was available.
+time rustup toolchain install $RUST_TOOLCHAIN_CHANNEL --no-self-update -c rustfmt $RUST_TARGET_ARG
case "$(uname -s)" in
MINGW*|MSYS_NT*)
+ export PATH="/c/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/amd64/:$PATH"
time ./build_windows_modules.sh --dev-build
;;
esac
@@ -28,8 +35,8 @@ esac
# FIXME: Becaues of our old jsonrpc dependency our Rust code won't build
# on latest nightly.
if [ "${RUST_TOOLCHAIN_CHANNEL}" != "nightly" ]; then
- time cargo build --locked --verbose
- time cargo test --locked --verbose
+ time cargo build --locked --verbose $RUST_TARGET_ARG
+ time cargo test --locked --verbose $RUST_TARGET_ARG
fi
if [[ "${RUST_TOOLCHAIN_CHANNEL}" == "nightly" && "$(uname -s)" == "Linux" ]]; then