Skip to content

Add support for build-dir layout v2#483

Open
ranger-ross wants to merge 2 commits intotaiki-e:mainfrom
ranger-ross:build-dir-new-layout
Open

Add support for build-dir layout v2#483
ranger-ross wants to merge 2 commits intotaiki-e:mainfrom
ranger-ross:build-dir-new-layout

Conversation

@ranger-ross
Copy link
Copy Markdown

This PR adds logic to handle the new layout of Cargo's build-dir which changes the directory structure of Cargo internally.
(can be enabled with -Zbuild-dir-new-layout)
While this is still unstable we are not expecting any large changes to the structure at this point.

Resources

Comment on lines -367 to -368
let mut collect_target_dir =
|mut target_dir: Utf8PathBuf, mut build_dir: Option<Utf8PathBuf>| -> Result<()> {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sorry about the diffs in this closure, I don't really understand why rustfmt has decided it wants to change this.
The only real change is adding both regexes to the walk_target_dir fn call

walk_target_dir(cx, &build_script_v1_layout_re, &build_script_v2_layout_re, &target_dir)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

hiding the whitespace changes in GitHub makes reviewing this a bit easier

Copy link
Copy Markdown
Owner

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! It looks good aside from the fact that I can't tell if it's actually working since there's no test.

@ranger-ross ranger-ross force-pushed the build-dir-new-layout branch from 008cf8d to 96d23cb Compare March 31, 2026 16:26
@ranger-ross
Copy link
Copy Markdown
Author

I added a test. I didn't know exactly how the test harness works so let me know if I did something wrong.
I copied the real1 test and enabled the new layout using the Cargo unstable flag (-Zbuild-dir-new-layout) via env var.

Before committing I modified the workspace_root in tests/auxilary/mod.rs to use .keep(), then verified the tests are actually using the correct layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants