Skip to content

Commit

Permalink
[cargo.sh] Set CARGO_TARGET_DIR for cargo metadata (#580)
Browse files Browse the repository at this point in the history
Closes #547
  • Loading branch information
joshlf authored Nov 3, 2023
1 parent b771d91 commit 2ab4f2a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cargo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ function print-usage-and-exit {
[[ $# -gt 0 ]] || print-usage-and-exit

function pkg-meta {
cargo metadata --format-version 1 | jq -r ".packages[] | select(.name == \"zerocopy\").$1"
# NOTE(#547): We set `CARGO_TARGET_DIR` here because `cargo metadata`
# sometimes causes the `cargo-metadata` crate to be rebuilt from source using
# the default toolchain. This has the effect of clobbering any existing build
# artifacts from whatever toolchain the user has specified (e.g., `+nightly`),
# causing the subsequent `cargo` invocation to rebuild unnecessarily. By
# specifying a separate build directory here, we ensure that this never
# clobbers the build artifacts used by the later `cargo` invocation.
CARGO_TARGET_DIR=target/cargo-sh cargo metadata --format-version 1 | jq -r ".packages[] | select(.name == \"zerocopy\").$1"
}

function lookup-version {
Expand Down

0 comments on commit 2ab4f2a

Please sign in to comment.