pub struct Context<'a, 'cfg> {
    pub bcx: &'a BuildContext<'a, 'cfg>,
    pub compilation: Compilation<'cfg>,
    pub build_script_outputs: Arc<Mutex<BuildScriptOutputs>>,
    pub build_explicit_deps: HashMap<Unit, BuildDeps>,
    pub fingerprints: HashMap<Unit, Arc<Fingerprint>>,
    pub mtime_cache: HashMap<PathBuf, FileTime>,
    pub compiled: HashSet<Unit>,
    pub build_scripts: HashMap<Unit, Arc<BuildScripts>>,
    pub jobserver: Client,
    pub rustc_clients: HashMap<Unit, Client>,
    pub lto: HashMap<Unit, Lto>,
    pub metadata_for_doc_units: HashMap<Unit, Metadata>,
    /* private fields */
}
Expand description

Collection of all the stuff that is needed to perform a build.

Fields

bcx: &'a BuildContext<'a, 'cfg>

Mostly static information about the build task.

compilation: Compilation<'cfg>

A large collection of information about the result of the entire compilation.

build_script_outputs: Arc<Mutex<BuildScriptOutputs>>

Output from build scripts, updated after each build script runs.

build_explicit_deps: HashMap<Unit, BuildDeps>

Dependencies (like rerun-if-changed) declared by a build script. This is only populated from the output from previous runs. If the build script hasn’t ever been run, then it must be run.

fingerprints: HashMap<Unit, Arc<Fingerprint>>

Fingerprints used to detect if a unit is out-of-date.

mtime_cache: HashMap<PathBuf, FileTime>

Cache of file mtimes to reduce filesystem hits.

compiled: HashSet<Unit>

A set used to track which units have been compiled. A unit may appear in the job graph multiple times as a dependency of multiple packages, but it only needs to run once.

build_scripts: HashMap<Unit, Arc<BuildScripts>>

Linking information for each Unit. See build_map for details.

jobserver: Client

Job server client to manage concurrency with other processes.

rustc_clients: HashMap<Unit, Client>

When we’re in jobserver-per-rustc process mode, this keeps those jobserver clients for each Unit (which eventually becomes a rustc process).

lto: HashMap<Unit, Lto>

Map of the LTO-status of each unit. This indicates what sort of compilation is happening (only object, only bitcode, both, etc), and is precalculated early on.

metadata_for_doc_units: HashMap<Unit, Metadata>

Map of Doc/Docscrape units to metadata for their -Cmetadata flag. See Context::find_metadata_units for more details.

Implementations

Starts compilation, waits for it to finish, and returns information about the result of compilation.

Returns the executable for the specified unit (if any).

Prepare this context, ensuring that all filesystem directories are in place.

Returns the filenames that the given unit will generate.

Direct dependencies for the given unit.

Returns the RunCustomBuild Unit associated with the given Unit.

If the package does not have a build script, this returns None.

Returns the metadata hash for the RunCustomBuild Unit associated with the given unit.

If the package does not have a build script, this returns None.

Returns the metadata hash for a RunCustomBuild unit.

Returns the list of filenames read by cargo to generate the BuildContext (all Cargo.toml, etc.).

Returns a UnitOutput which represents some information about the output of a unit.

Returns whether when parent depends on dep if it only requires the metadata file from dep.

Returns whether when unit is built whether it should emit metadata as well because some compilations rely on that.

Finds metadata for Doc/Docscrape units.

rustdoc needs a -Cmetadata flag in order to recognize StableCrateIds that refer to items in the crate being documented. The -Cmetadata flag used by reverse-dependencies will be the metadata of the Cargo unit that generated the current library’s rmeta file, which should be a Check unit.

If the current crate has reverse-dependencies, such a Check unit should exist, and so we use that crate’s metadata. If not, we use the crate’s Doc unit so at least examples scraped from the current crate can be used when documenting the current crate.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.