Reorganize build unit directory layout for new build-dir layout#16542
Reorganize build unit directory layout for new build-dir layout#16542epage merged 5 commits intorust-lang:masterfrom
Conversation
| [ROOT]/foo/build-dir/debug/build/foo/[HASH]/deps/foo[..][EXE] | ||
| [ROOT]/foo/build-dir/debug/build/foo/[HASH]/deps/foo[..].d | ||
| [ROOT]/foo/build-dir/debug/build/foo/[HASH]/out/foo.txt | ||
| [ROOT]/foo/build-dir/debug/build/foo/[HASH]/out/build_script_build[..].d | ||
| [ROOT]/foo/build-dir/debug/build/foo/[HASH]/out/build_script_build[..][EXE] | ||
| [ROOT]/foo/build-dir/debug/build/foo/[HASH]/out/build-script-build[EXE] | ||
| [ROOT]/foo/build-dir/debug/build/foo/[HASH]/out/foo[..][EXE] | ||
| [ROOT]/foo/build-dir/debug/build/foo/[HASH]/out/foo[..].d |
There was a problem hiding this comment.
note on the diffs here: Now that both the build-script and build units use the same directory we run into the issue of
foo/[HASH]/out/foo[..][EXE]
matching foo.txt that is output from the build-script.
To solve this I moved the foo.txt before the foo[..][EXE] line so it would be matched earlier.
But after doing that I felt the order of the files was mislead as it makes it look like foo.txt and foo.txt are in the same directory which they are not. (HASH is different)
So I also moved the other build script files in hopes that it might be a bit more clear.
cargo-semver-checks already supported rustdoc JSON v57 but not yet released
But the |
src/cargo/core/compiler/layout.rs
Outdated
| /// New features should consider using this so we can avoid their migrations. | ||
| pub fn deps_new_layout(&self, pkg_dir: &str) -> PathBuf { | ||
| self.build_unit(pkg_dir).join("deps") | ||
| pub fn output(&self, pkg_dir: &str) -> PathBuf { |
There was a problem hiding this comment.
Why is this output and not out?
There was a problem hiding this comment.
Sorry, I had original named them output but then changed the named to out and forgot to update this one.
Will change to out
There was a problem hiding this comment.
I'm still seeing some output_dirs present
There was a problem hiding this comment.
I think that is expected.
Note that there are 2 functions in CompilationFiles relevant in this PR:
fn output_dir()-- (was previouslyout_dir) that gets the output path over many different types of units.- I renamed this in the first commit to 1) avoid confusion as it does NOT always point to the
outdir in both the new and old layouts and 2) I wanted to useout_diras the fn name for the path that does lead to theoutdir. - I am up for renaming this fn to something else to make it even less confusing. I couldn't come up with anything more descriptive than "output" since its quiet general.
- I renamed this in the first commit to 1) avoid confusion as it does NOT always point to the
fn out_dir()-- (previousfn deps_dir) points totarget/<profile>/build/<build-unit>/outin the new layout and/target/<profile>/deps
d7c6ce1 to
494c2f1
Compare
This comment has been minimized.
This comment has been minimized.
494c2f1 to
2decb74
Compare
This comment has been minimized.
This comment has been minimized.
2decb74 to
49abc7e
Compare
This comment has been minimized.
This comment has been minimized.
|
See cd39acf in commit history. Rebase got messed up? |
|
ahhh yeah, I think I did an |
49abc7e to
5716af9
Compare
This comment has been minimized.
This comment has been minimized.
|
@epage gentle reminder this PR is waiting on review |
|
Still working through everything from when my family was sick. |
Rename `fn out_dir` to `fn output_dir` to avoid naming collisions in future layout changes.
Previously `deps` was only the compiler output. This commit renames it to `out` to make it more general to any kind of build output. The build script OUT_DIR will eventually be merged into this directory.
This was previously indirectly created by `OUT_DIR`, however in the future `OUT_DIR` will not be nested in the build-script run dir so we always want to create it.
This commit moves the build-script OUT_DIR location from `{build-unit-dir}/build-script-execution/out`
to `{build-unit-dir}/out` dir (that was previously `{build-unit-dir}/deps`)
This commit changes the build script execution dir from `{build-unit-dir}/build-script`
to `{build-unit-dir}/run`. The motivation behind this is to have a
general directory for units that execute some binary/external process
and output to stdout/err. Currently this is only used by build-scripts
but could be expanded in the future.
5716af9 to
e4327a5
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Update cargo submodule 8 commits in 0c9e687d237ff04b53ccb67b4ce63e9483789e88..ce69df6f72a3b6a2b5c722ba68ddef255344b31c 2026-02-11 05:58:30 +0000 to 2026-02-12 12:39:45 +0000 - fix: apply `host.runner` only when `host-config` enabled (rust-lang/cargo#16631) - fix(cli): Improve bad manifest error (rust-lang/cargo#16630) - fix: Adjust casing of error message (rust-lang/cargo#16625) - Enable triagebot new `[view-all-comments-link]` feature (rust-lang/cargo#16629) - test(help): snapshot cargo help tests (rust-lang/cargo#16626) - Suggest a `workspace.members` entry even from outside the workspace root (rust-lang/cargo#16616) - Reorganize build unit directory layout for new build-dir layout (rust-lang/cargo#16542) - Make the error messaging for `cargo install` aware of `build.build-dir` (rust-lang/cargo#16623)
Update cargo submodule 8 commits in 0c9e687d237ff04b53ccb67b4ce63e9483789e88..ce69df6f72a3b6a2b5c722ba68ddef255344b31c 2026-02-11 05:58:30 +0000 to 2026-02-12 12:39:45 +0000 - fix: apply `host.runner` only when `host-config` enabled (rust-lang/cargo#16631) - fix(cli): Improve bad manifest error (rust-lang/cargo#16630) - fix: Adjust casing of error message (rust-lang/cargo#16625) - Enable triagebot new `[view-all-comments-link]` feature (rust-lang/cargo#16629) - test(help): snapshot cargo help tests (rust-lang/cargo#16626) - Suggest a `workspace.members` entry even from outside the workspace root (rust-lang/cargo#16616) - Reorganize build unit directory layout for new build-dir layout (rust-lang/cargo#16542) - Make the error messaging for `cargo install` aware of `build.build-dir` (rust-lang/cargo#16623)
What does this PR try to resolve?
This PR makes more changes to the new
build-dirlayout as discussed in #16502 (comment).The goal here is to have more general (and thus reusable) directories in the build unit structure.
Layout changes
{build-unit-dir}/depsto{build-unit-dir}/outOUT_DIRfrom{build-unit-dir}/build-script/outto{build-unit-dir}/out{build-unit-dir}/build-scriptto{build-unit-dir}/runThe resulting structure looks like
Part of #15010
How to test and review this PR?
See the test updates included in each commit