0
0
mirror of https://github.com/signalapp/libsignal.git synced 2024-09-20 03:52:17 +02:00

build_helpers.sh: fix error message if Rust isn't installed

This commit is contained in:
Jordan Rose 2020-11-18 11:48:23 -08:00
parent 44b0f96c1c
commit 2e42d72ef8

View File

@ -6,16 +6,18 @@
# shellcheck shell=bash # shellcheck shell=bash
check_rust() { check_rust() {
if ! which rustup > /dev/null; then if ! which rustup > /dev/null && [[ -n "$SHELL" ]]; then
# Try to find rustup using the user's default shell. # Try to find rustup using the user's default shell.
# This will be important when running from inside Xcode, # This will be important when running from inside Xcode,
# which does not run in an existing shell context. # which does not run in a login shell context.
RUSTUP_PATH=$("$SHELL" -c 'which rustup') RUSTUP_PATH=$("$SHELL" -c 'which rustup' || true)
if [[ "$RUSTUP_PATH" == /* || "$RUSTUP_PATH" == '~'/* ]]; then
PATH=$(dirname "$RUSTUP_PATH"):$PATH PATH=$(dirname "$RUSTUP_PATH"):$PATH
fi fi
fi
if ! which rustup > /dev/null; then if ! which rustup > /dev/null; then
echo 'error: rustup not found; get it from https://rustup.rs/' >&2 echo 'error: rustup not found; install Rust from https://rustup.rs/' >&2
exit 1 exit 1
fi fi
@ -23,7 +25,7 @@ check_rust() {
echo "error: Rust target ${CARGO_BUILD_TARGET} not installed" >&2 echo "error: Rust target ${CARGO_BUILD_TARGET} not installed" >&2
echo 'note: get it by running' >&2 echo 'note: get it by running' >&2
printf "\n\t%s\n\n" "rustup +${RUSTUP_TOOLCHAIN:-$(cat ./rust-toolchain)} target add ${CARGO_BUILD_TARGET}" >&2 printf "\n\t%s\n\n" "rustup +${RUSTUP_TOOLCHAIN:-$(cat ./rust-toolchain)} target add ${CARGO_BUILD_TARGET}" >&2
exit 2 exit 1
fi fi
} }