Skip to content

Commit c38bc6f

Browse files
committed
canonicalize miri's directory
1 parent bb9db2b commit c38bc6f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

miri

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ EOF
3939
TARGET=$(rustc --version --verbose | grep "^host:" | cut -d ' ' -f 2)
4040
SYSROOT=$(rustc --print sysroot)
4141
LIBDIR=$SYSROOT/lib/rustlib/$TARGET/lib
42+
MIRIDIR=$(readlink -e "$(dirname "$0")")
4243
if ! test -d "$LIBDIR"; then
4344
echo "Something went wrong determining the library dir."
4445
echo "I got $LIBDIR but that does not exist."
@@ -51,7 +52,7 @@ if [ -z "$CARGO_INCREMENTAL" ]; then
5152
fi
5253
if [ -z "$CARGO_TARGET_DIR" ]; then
5354
# Share target dir between `miri` and `cargo-miri`.
54-
export CARGO_TARGET_DIR="$(dirname "$0")"/target
55+
export CARGO_TARGET_DIR="$MIRIDIR/target"
5556
fi
5657
# We set the rpath so that Miri finds the private rustc libraries it needs.
5758
# We enable debug-assertions to get tracing.
@@ -63,9 +64,9 @@ export RUSTFLAGS="-C link-args=-Wl,-rpath,$LIBDIR -C debug-assertions -C debugin
6364
# Build a sysroot and set MIRI_SYSROOT to use it. Arguments are passed to `cargo miri setup`.
6465
build_sysroot() {
6566
# Build once, for the user to see.
66-
cargo run $CARGO_BUILD_FLAGS --manifest-path "$(dirname "$0")"/cargo-miri/Cargo.toml -- miri setup "$@"
67+
cargo run $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml -- miri setup "$@"
6768
# Call again, to just set env var.
68-
export MIRI_SYSROOT="$(cargo run $CARGO_BUILD_FLAGS --manifest-path "$(dirname "$0")"/cargo-miri/Cargo.toml -q -- miri setup --print-sysroot "$@")"
69+
export MIRI_SYSROOT="$(cargo run $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml -q -- miri setup --print-sysroot "$@")"
6970
}
7071

7172
# Prepare and set MIRI_SYSROOT. Respects `MIRI_TEST_TARGET` and takes into account
@@ -108,18 +109,18 @@ case "$COMMAND" in
108109
install|install-debug)
109110
# "--locked" to respect the Cargo.lock file if it exists,
110111
# "--offline" to avoid querying the registry (for yanked packages).
111-
cargo install $CARGO_INSTALL_FLAGS --path "$(dirname "$0")" --force --locked --offline "$@"
112-
cargo install $CARGO_INSTALL_FLAGS --path "$(dirname "$0")"/cargo-miri --force --locked --offline "$@"
112+
cargo install $CARGO_INSTALL_FLAGS --path "$MIRIDIR" --force --locked --offline "$@"
113+
cargo install $CARGO_INSTALL_FLAGS --path "$MIRIDIR"/cargo-miri --force --locked --offline "$@"
113114
;;
114115
check|check-debug)
115116
# Check, and let caller control flags.
116-
cargo check $CARGO_BUILD_FLAGS --manifest-path "$(dirname "$0")"/Cargo.toml "$@"
117-
cargo check $CARGO_BUILD_FLAGS --manifest-path "$(dirname "$0")"/cargo-miri/Cargo.toml "$@"
117+
cargo check $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml "$@"
118+
cargo check $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@"
118119
;;
119120
build|build-debug)
120121
# Build, and let caller control flags.
121-
cargo build $CARGO_BUILD_FLAGS --manifest-path "$(dirname "$0")"/Cargo.toml "$@"
122-
cargo build $CARGO_BUILD_FLAGS --manifest-path "$(dirname "$0")"/cargo-miri/Cargo.toml "$@"
122+
cargo build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml "$@"
123+
cargo build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@"
123124
;;
124125
test|test-debug)
125126
# First build and get a sysroot.

0 commit comments

Comments
 (0)