Skip to content

Conversation

0xPoe
Copy link
Member

@0xPoe 0xPoe commented Dec 25, 2023

What does this PR try to resolve?

close #13127

  • Added a minimal case to cover this behavior.
  • Set OUT_DIR for all units with build scripts.

How should we test and review this PR?

Check out the unit test.

Additional information

None

@rustbot
Copy link
Collaborator

rustbot commented Dec 25, 2023

r? @ehuss

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 25, 2023
@0xPoe 0xPoe force-pushed the rustin-patch-test-out-dir branch from c8ebc18 to 1f496dd Compare December 26, 2023 02:04
@0xPoe 0xPoe changed the title WIP: test: include a case for setting OUT_DIR fix: set OUT_DIR for all units with build scripts Dec 27, 2023
@0xPoe 0xPoe marked this pull request as ready for review December 27, 2023 02:50
@0xPoe 0xPoe force-pushed the rustin-patch-test-out-dir branch from c8d00f0 to 3aaf4ee Compare December 27, 2023 02:53
Copy link
Member Author

@0xPoe 0xPoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔢 Self-check

Comment on lines +189 to +213
// 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));
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I think your understanding is correct. Before https://github.com/rust-lang/cargo/pull/3310/files, we set it for every unit.
image

@ehuss
Copy link
Contributor

ehuss commented Jan 2, 2024

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 2, 2024
0xPoe added 2 commits January 8, 2024 20:58
Signed-off-by: hi-rustin <[email protected]>

test: remove the env set by Cargo

Signed-off-by: hi-rustin <[email protected]>

Fix

Signed-off-by: hi-rustin <[email protected]>
@0xPoe 0xPoe force-pushed the rustin-patch-test-out-dir branch from 3aaf4ee to 6739c7e Compare January 8, 2024 13:00
@rustbot rustbot added the A-testing-cargo-itself Area: cargo's tests label Jan 8, 2024
@0xPoe
Copy link
Member Author

0xPoe commented Jan 8, 2024

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. labels Jan 8, 2024
@0xPoe 0xPoe requested a review from epage January 8, 2024 13:17
@ehuss
Copy link
Contributor

ehuss commented Jan 8, 2024

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Jan 8, 2024

📌 Commit 6739c7e has been approved by ehuss

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 8, 2024
@bors
Copy link
Contributor

bors commented Jan 8, 2024

⌛ Testing commit 6739c7e with merge 0c98d6e...

@bors
Copy link
Contributor

bors commented Jan 8, 2024

☀️ Test successful - checks-actions
Approved by: ehuss
Pushing 0c98d6e to master...

@bors bors merged commit 0c98d6e into rust-lang:master Jan 8, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 10, 2024
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
@ehuss ehuss added this to the 1.77.0 milestone Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing-cargo-itself Area: cargo's tests S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OUT_DIR env var Behaviour discrepancy between testing a whole crate and individual test
5 participants