Expand description
The entry point for starting the compilation process for commands like
build, test, doc, rustc, etc.
The compile function will do all the work to compile a workspace. A
rough outline is:
- Resolve the dependency graph (see 
ops::resolve). - Download any packages needed (see 
PackageSet). - Generate a list of top-level “units” of work for the targets the user
requested on the command-line. Each 
Unitcorresponds to a compiler invocation. This is done in this module (UnitGenerator::generate_root_units). - Starting from the root 
Units, generate theUnitGraphby walking the dependency graph from the resolver. See alsounit_dependencies. - Construct the 
BuildContextwith all of the information collected so far. This is the end of the “front end” of compilation. - Create a 
BuildRunnerwhich coordinates the compilation process and will perform the following steps:- Prepare the 
targetdirectory (seeLayout). - Create a 
JobQueue. The queue checks the fingerprint of eachUnitto determine if it should run or be skipped. - Execute the queue via 
drain_the_queue. Each leaf in the queue’s dependency graph is executed, and then removed from the graph when finished. This repeats until the queue is empty. Note that this is the only point in cargo that currently uses threads. 
 - Prepare the 
 - The result of the compilation is stored in the 
Compilationstruct. This can be used for various things, such as running tests after the compilation has finished. 
Note: “target” inside this module generally refers to “Cargo Target”, which corresponds to artifact that will be built in a package. Not to be confused with target-triple or target architecture.
Re-exports§
pub use compile_filter::CompileFilter;pub use compile_filter::FilterRule;pub use compile_filter::LibRule;pub use packages::Packages;
Modules§
- compile_
filter 🔒 - Filters and their rules to select which Cargo targets will be built.
 - packages 🔒
 - See 
Packages. - unit_
generator 🔒 
Structs§
- Compile
Options  - Contains information about how a package should be compiled.
 
Functions§
- compile
 - Compiles!
 - compile_
with_ exec  - Like 
compilebut allows specifying a customExecutorthat will be able to intercept build calls and add custom logic. - compile_
ws  - Like 
compile_with_execbut without warnings from manifest parsing. - create_
bcx  - Prepares all required information for the actual compilation.
 - override_
rustc_ 🔒crate_ types  - Override crate types for given units.
 - Executes 
rustc --print <VALUE>. - rebuild_
unit_ 🔒graph_ shared  - This is used to rebuild the unit graph, sharing host dependencies if possible, and applying other unit adjustments based on the whole graph.
 - remove_
duplicate_ 🔒doc  - Removes duplicate 
CompileMode::Docunits that would cause problems with filename collisions. - resolve_
all_ features  - Gets all of the features enabled for a package, plus its dependencies’ features.
 - traverse_
and_ 🔒share  - Recursive function for rebuilding the graph.