Wrap cargo-miri for rust-src

This commit is contained in:
oxalica 2021-01-16 01:14:03 +08:00
parent 80287ab66a
commit 0565a346c1
2 changed files with 21 additions and 0 deletions

11
cargo-miri-wrapper.sh Executable file
View File

@ -0,0 +1,11 @@
#!@bash@ -e
src_dir="@out@/lib/rustlib/src/rust/library"
if [[ ! -v XARGO_RUST_SRC ]]; then
if [[ ! -d "$src_dir" ]]; then
echo '`rust-src` is required by miri but not installed.' >&2
echo 'Please either install component `rust-src` or set `XARGO_RUST_SRC`.' >&2
exit 1
fi
export XARGO_RUST_SRC="$src_dir"
fi
exec -a "$0" "@miri@" "$@"

View File

@ -253,6 +253,16 @@ let
cp --remove-destination "$(realpath -e $target)" $target
fi
done
if [ -e $out/bin/cargo-miri ]; then
cargo_miri=$(readlink $out/bin/cargo-miri)
cp -f ${./cargo-miri-wrapper.sh} $out/bin/cargo-miri
chmod +w $out/bin/cargo-miri
substituteInPlace $out/bin/cargo-miri \
--replace "@bash@" "${self.pkgs.bash}/bin/bash" \
--replace "@miri@" "$cargo_miri" \
--replace "@out@" "$out"
fi
'';
# Add the compiler as part of the propagated build inputs in order