fix: support relative TARGET_DIR in near-test-contracts #6181
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
near-test-contracts builds some wasm contracts for use in testing. It
does so by recursively invoking
cargo
frombuild.rs
. Before thiscommit, we tried to re-use parent's
CARGO_TARGET_DIR
to figure outwhere we should put the data. That was rather hacky, as cargo doesn't
expose that information to the build scripts in a reliable way:
rust-lang/cargo#9661 (comment)
Naturally, our hacks broken when when the
CARGO_TARGET_DIR
was set toa relative path, because build.rs doesn't know where workspace root
lives.
The fix is to use
OUT_DIR
rather thanCARGO_TARGET_DIR
, which Ithink is the supported way to this in the first place. Eg, the
cc
crate uses
OUT_DIR
to store intermediate.o
files, which I thinkmatches our use case pretty closely.