|
2 | 2 | set -e
|
3 | 3 | # We want to call the binary directly, so we need to know where it ends up.
|
4 | 4 | ROOT_DIR="$(dirname "$0")"
|
5 |
| -MIRI_SCRIPT_TARGET_DIR="$ROOT_DIR"/miri-script/target |
6 |
| -TOOLCHAIN="+nightly" |
| 5 | +TARGET_DIR="$ROOT_DIR"/miri-script/target |
| 6 | +# Prepare cargo invocation. |
| 7 | +# We have to overwrite the toolchain since `+miri` might be activated and not installed. |
| 8 | +TOOLCHAIN="+stable" |
| 9 | +CARGO_FLAGS=("-q") |
7 | 10 | # If we are being invoked for RA, use JSON output and the default toolchain (to make proc-macros
|
8 | 11 | # work in RA). This needs a different target dir to avoid mixing up the builds.
|
| 12 | +# Also set `-Zroot-dir` so that RA can identify where the error occurred. |
9 | 13 | if [ -n "$MIRI_IN_RA" ]; then
|
10 |
| - MESSAGE_FORMAT="--message-format=json" |
11 | 14 | TOOLCHAIN=""
|
12 |
| - MIRI_SCRIPT_TARGET_DIR="$MIRI_SCRIPT_TARGET_DIR"/ra |
| 15 | + CARGO_FLAGS+=("--message-format=json" "-Zroot-dir=$ROOT_DIR") |
| 16 | + TARGET_DIR="$ROOT_DIR"/target |
13 | 17 | fi
|
14 |
| -# We need a nightly toolchain, for `-Zroot-dir`. |
15 |
| -cargo $TOOLCHAIN build $CARGO_EXTRA_FLAGS --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \ |
16 |
| - -Zroot-dir="$ROOT_DIR" \ |
17 |
| - -q --target-dir "$MIRI_SCRIPT_TARGET_DIR" $MESSAGE_FORMAT || \ |
18 |
| - ( echo "Failed to build miri-script. Is the 'nightly' toolchain installed?"; exit 1 ) |
19 |
| -# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly. Invoking `cargo run` goes through |
20 |
| -# rustup (that sets it's own environmental variables), which is undesirable. |
21 |
| -"$MIRI_SCRIPT_TARGET_DIR"/debug/miri-script "$@" |
| 18 | +# Run cargo. |
| 19 | +cargo $TOOLCHAIN build --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \ |
| 20 | + --target-dir "$TARGET_DIR" "${CARGO_FLAGS[@]}" || \ |
| 21 | + ( echo "Failed to build miri-script. Is the 'stable' toolchain installed?"; exit 1 ) |
| 22 | +# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly. |
| 23 | +# Invoking `cargo run` goes through rustup (that sets it's own environmental variables), which is |
| 24 | +# undesirable. |
| 25 | +"$TARGET_DIR"/debug/miri-script "$@" |
0 commit comments