fix: set OUT_DIR for all units with build scripts#13204
fix: set OUT_DIR for all units with build scripts#13204bors merged 2 commits intorust-lang:masterfrom
Conversation
|
r? @ehuss (rustbot has picked a reviewer for you, use r? to override) |
c8ebc18 to
1f496dd
Compare
c8d00f0 to
3aaf4ee
Compare
| // Add `OUT_DIR` to env vars if unit has a build script. | ||
| let units_with_build_script = &self | ||
| .bcx | ||
| .roots | ||
| .iter() | ||
| .filter(|unit| self.build_scripts.contains_key(unit)) | ||
| .dedup_by(|x, y| x.pkg.package_id() == y.pkg.package_id()) | ||
| .collect::<Vec<_>>(); | ||
| for unit in units_with_build_script { | ||
| for dep in &self.bcx.unit_graph[unit] { | ||
| if dep.unit.mode.is_run_custom_build() { | ||
| let out_dir = self | ||
| .files() | ||
| .build_script_out_dir(&dep.unit) | ||
| .display() | ||
| .to_string(); | ||
| let script_meta = self.get_run_build_script_metadata(&dep.unit); | ||
| self.compilation | ||
| .extra_env | ||
| .entry(script_meta) | ||
| .or_insert_with(Vec::new) | ||
| .push(("OUT_DIR".to_string(), out_dir)); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
If I'm understanding this, we only really need to set OUT_DIR once per package and the previous code did that be assuming the lib unit was sufficient (but some packages don't have that).
I'm assuming there isn't a more direct way to iterate over packages to find out the necessary information and set it, and instead we have to walk all units and de-dupe down to individual packages?
There was a problem hiding this comment.
Yes. I think your understanding is correct. Before https://github.com/rust-lang/cargo/pull/3310/files, we set it for every unit.

|
@rustbot author |
Signed-off-by: hi-rustin <rustin.liu@gmail.com> test: remove the env set by Cargo Signed-off-by: hi-rustin <rustin.liu@gmail.com> Fix Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
3aaf4ee to
6739c7e
Compare
|
@rustbot ready |
|
Thanks! @bors r+ |
|
☀️ Test successful - checks-actions |
Update cargo 14 commits in 2ce45605d9db521b5fd6c1211ce8de6055fdb24e..3e428a38a34e820a461d2cc082e726d3bda71bcb 2024-01-04 18:04:13 +0000 to 2024-01-09 20:46:36 +0000 - refactor: replace `iter_join` with `itertools::join` (rust-lang/cargo#13275) - docs(unstable): doc comments for items and fields (rust-lang/cargo#13274) - crates-io: Set `Content-Type: application/json` only for requests with a body payload (rust-lang/cargo#13264) - fix: only inherit workspace package table if the new package is a member (rust-lang/cargo#13261) - feat(cli): add colors to `-Zhelp` console output (rust-lang/cargo#13269) - chore(deps): update msrv (rust-lang/cargo#13266) - refactor(toml): Make it more obvious to update package-dependent fields (rust-lang/cargo#13267) - chore(ci): Fix MSRV:3 updates (rust-lang/cargo#13268) - chore(ci): Shot-in-the-dark fix for MSRV updating (rust-lang/cargo#13265) - fix: set OUT_DIR for all units with build scripts (rust-lang/cargo#13204) - fix(manifest): Provide unused key warnings for lints table (rust-lang/cargo#13262) - test(manifest): Verify we warn on unused workspace.package fields (rust-lang/cargo#13263) - docs(changelog): Call out cargo-new lockfile change (rust-lang/cargo#13260) - chore: Add dependency dashboard (rust-lang/cargo#13255) r? ghost
What does this PR try to resolve?
close #13127
How should we test and review this PR?
Check out the unit test.
Additional information
None