-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Enable Cargo's new build-dir layout #155439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ranger-ross
wants to merge
4
commits into
rust-lang:main
Choose a base branch
from
ranger-ross:cargo-new-build-dir-layout
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a67c933
Enable Cargo's new build-dir layout in boostrap
ranger-ross 0c79f67
test: Enable Cargo's new layout in tests
ranger-ross 0fd06e3
test: Add support for cargo's build-dir v2 layout (rustfmt)
ranger-ross 4a1caec
chore: Move CI to use Cargo's v2 layout (rustfmt)
ranger-ross File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2652,8 +2652,8 @@ pub fn run_cargo( | |
| ) -> Vec<PathBuf> { | ||
| // `target_root_dir` looks like $dir/$target/release | ||
| let target_root_dir = stamp.path().parent().unwrap(); | ||
| // `target_deps_dir` looks like $dir/$target/release/deps | ||
| let target_deps_dir = target_root_dir.join("deps"); | ||
| // `target_build_dir` looks like $dir/$target/release/build | ||
| let target_build_dir = target_root_dir.join("build"); | ||
| // `host_root_dir` looks like $dir/release | ||
| let host_root_dir = target_root_dir | ||
| .parent() | ||
|
|
@@ -2724,7 +2724,7 @@ pub fn run_cargo( | |
|
|
||
| // If this was output in the `deps` dir then this is a precise file | ||
| // name (hash included) so we start tracking it. | ||
| if filename.starts_with(&target_deps_dir) { | ||
| if filename.starts_with(&target_build_dir) { | ||
| deps.push((filename.to_path_buf(), DependencyType::Target)); | ||
| continue; | ||
| } | ||
|
|
@@ -2759,11 +2759,18 @@ pub fn run_cargo( | |
|
|
||
| // Ok now we need to actually find all the files listed in `toplevel`. We've | ||
| // got a list of prefix/extensions and we basically just need to find the | ||
| // most recent file in the `deps` folder corresponding to each one. | ||
| let contents = target_deps_dir | ||
| // most recent file in the `build` folder corresponding to each one. | ||
| // | ||
| // Cargo's build folder is structured as `build/<pkg>/<hash>/out/<artifacts>` so | ||
| // we need to traverse multiple directory layers to get to actual files. | ||
| let read_dir = |path: &Path| path.read_dir().ok().into_iter().flatten().filter_map(Result::ok); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. checks failed because if there are any lingering files/dirs in Update the original code to not panic if we call |
||
| let contents = target_build_dir | ||
| .read_dir() | ||
| .unwrap_or_else(|e| panic!("Couldn't read {}: {}", target_deps_dir.display(), e)) | ||
| .map(|e| t!(e)) | ||
| .unwrap_or_else(|e| panic!("Couldn't read {}: {}", target_build_dir.display(), e)) | ||
| .map(|e| e.unwrap()) | ||
| .flat_map(|e| read_dir(&e.path())) | ||
| .flat_map(|e| read_dir(&e.path())) | ||
| .flat_map(|e| read_dir(&e.path())) | ||
| .map(|e| (e.path(), e.file_name().into_string().unwrap(), t!(e.metadata()))) | ||
| .collect::<Vec<_>>(); | ||
| for (prefix, extension, expected_len) in toplevel { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet read the code by myself. Just wonder why bootstrap are doing this? And if bootstrap needs to do it, it should be a feature in Cargo, at least a (perma-)unstable feature.
View changes since the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the commit block around line 2374. Basically we need the non-uplifted name that contains the unique hash. The artifact notifications provide the uplifted name where possible.