-
Notifications
You must be signed in to change notification settings - Fork 2.8k
docs(layout): Updated layout module docs to document new layout #16502
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
Merged
+118
−12
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -1,22 +1,52 @@ | ||
| //! Management of the directory layout of a build | ||
| //! | ||
| //! The directory layout is a little tricky at times, hence a separate file to | ||
| //! house this logic. The current layout looks like this: | ||
| //! house this logic. Cargo stores build artifacts in two directories: `artifact-dir` and | ||
| //! `build-dir` | ||
| //! | ||
| //! ## `artifact-dir` layout | ||
| //! | ||
| //! `artifact-dir` is where final artifacts like binaries are stored. | ||
| //! The `artifact-dir` layout is consider part of the public API and | ||
| //! cannot be easily changed. | ||
| //! | ||
| //! ```text | ||
| //! # This is the root directory for all output, the top-level package | ||
| //! # places all of its output here. | ||
| //! target/ | ||
| //! <artifact-dir>/ | ||
| //! | ||
| //! # Compilation files are grouped by build target and profile. | ||
| //! # The target is omitted if not explicitly specified. | ||
| //! [<target>]/<profile>/ # e.g. `debug` / `release` | ||
| //! | ||
| //! # File used to lock the directory to prevent multiple cargo processes | ||
| //! # from using it at the same time. | ||
| //! .cargo-lock | ||
| //! | ||
| //! # Root directory for all compiled examples. | ||
| //! examples/ | ||
| //! | ||
| //! # Output from rustdoc | ||
| //! doc/ | ||
| //! | ||
| //! # Output from `cargo package` to build a `.crate` file. | ||
| //! package/ | ||
| //! ``` | ||
| //! | ||
| //! ## `build-dir` layout | ||
| //! | ||
| //! `build-dir` is where intermediate build artifacts are stored. | ||
| //! The `build-dir` layout is considered an internal implementation detail of Cargo | ||
| //! meaning that we can change this if needed. However, in reality many tools rely on | ||
| //! implementation details of Cargo so breaking changes need to be done carefully. | ||
| //! | ||
| //! ```text | ||
| //! <build-dir>/ | ||
| //! | ||
| //! # Cache of `rustc -Vv` output for performance. | ||
| //! .rustc-info.json | ||
| //! | ||
| //! # All final artifacts are linked into this directory from `deps`. | ||
| //! # Note that named profiles will soon be included as separate directories | ||
| //! # here. They have a restricted format, similar to Rust identifiers, so | ||
| //! # Cargo-specific directories added in the future should use some prefix | ||
| //! # like `.` to avoid name collisions. | ||
| //! debug/ # or release/ | ||
| //! # Compilation files are grouped by build target and profile. | ||
| //! # The target is omitted if not explicitly specified. | ||
| //! [<target>]/<profile>/ # e.g. `debug` / `release` | ||
| //! | ||
| //! # File used to lock the directory to prevent multiple cargo processes | ||
| //! # from using it at the same time. | ||
|
|
@@ -88,8 +118,84 @@ | |
| //! # Stderr output from the build script. | ||
| //! stderr | ||
| //! | ||
| //! # Output from rustdoc | ||
| //! doc/ | ||
| //! # Used by `cargo package` and `cargo publish` to build a `.crate` file. | ||
| //! package/ | ||
| //! | ||
| //! # Experimental feature for generated build scripts. | ||
| //! .metabuild/ | ||
| //! ``` | ||
| //! | ||
| //! ### New `build-dir` layout | ||
| //! | ||
| //! `build-dir` supports a new "build unit" based layout that is unstable. | ||
| //! It can be enabled via `-Zbuild-dir-new-layout`. | ||
| //! For more info about the layout transition see: [#15010](https://github.com/rust-lang/cargo/issues/15010) | ||
| //! | ||
| //! ```text | ||
| //! <build-dir>/ | ||
| //! | ||
| //! # Cache of `rustc -Vv` output for performance. | ||
| //! .rustc-info.json | ||
| //! | ||
| //! # Compilation files are grouped by build target and profile. | ||
| //! # The target is omitted if not explicitly specified. | ||
| //! [<target>]/<profile>/ # e.g. `debug` / `release` | ||
| //! | ||
| //! # File used to lock the directory to prevent multiple cargo processes | ||
| //! # from using it at the same time. | ||
| //! .cargo-lock | ||
| //! | ||
| //! # Directory used to store incremental data for the compiler (when | ||
| //! # incremental is enabled. | ||
| //! incremental/ | ||
| //! | ||
| //! # Main directory for storing build unit related files. | ||
| //! # Files are organized by Cargo build unit (`$pkgname/$META`) so that | ||
| //! # related files are stored in a single directory. | ||
| //! build/ | ||
| //! | ||
| //! # This is the location at which the output of all files related to | ||
| //! # a given build unit. These files are organized together so that we can | ||
| //! # treat this directly like a single unit for locking and caching. | ||
| //! $pkgname/ | ||
| //! $META/ | ||
| //! # The general purpose output directory for build units. | ||
| //! # For compilation units, the rustc artifact will be located here. | ||
| //! # For build script run units, this is the $OUT_DIR | ||
| //! out/ | ||
| //! | ||
| //! # For artifact dependency units, the output is nested by the kind | ||
| //! artifact/$kind | ||
| //! | ||
ranger-ross marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| //! # Directory that holds all of the fingerprint files for the build unit. | ||
| //! fingerprint/ | ||
| //! # Set of source filenames for this package. | ||
| //! dep-lib-$targetname | ||
| //! # Timestamp when this package was last built. | ||
| //! invoked.timestamp | ||
| //! # The fingerprint hash. | ||
| //! lib-$targetname | ||
| //! # Detailed information used for logging the reason why | ||
| //! # something is being recompiled. | ||
| //! lib-$targetname.json | ||
| //! # The console output from the compiler. This is cached | ||
| //! # so that warnings can be redisplayed for "fresh" units. | ||
| //! output-lib-$targetname | ||
| //! | ||
|
Comment on lines
+172
to
+184
Contributor
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. Side note: I feel like we could design the entire |
||
| //! # Directory for "execution" units that spawn a process (excluding compilation with | ||
| //! # rustc). Contains the process execution details. | ||
| //! # Currently the only execution unit Cargo supports is running build script | ||
| //! # binaries. | ||
| //! run/ | ||
| //! # Timestamp of last execution. | ||
| //! invoked.timestamp | ||
| //! # Stdout output from the process. | ||
| //! stdout | ||
| //! # Stderr output from the process. | ||
| //! stderr | ||
epage marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| //! # Path to `out`, used to help when the target directory is | ||
| //! # moved. (build scripts) | ||
| //! root-output | ||
| //! | ||
| //! # Used by `cargo package` and `cargo publish` to build a `.crate` file. | ||
| //! package/ | ||
|
|
||
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.
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.
Shouldn't this be removed from
build-dir?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.
Actually its still present in the old layout.
It contains the pre-uplifted bins
cargo/src/cargo/core/compiler/build_runner/compilation_files.rs
Lines 229 to 230 in 2200079
In the new layout, the examples will use the
<build-unit>/outdir just like regular compilation build units