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<'a>, BuildDeps>,
pub fingerprints: HashMap<Unit<'a>, Arc<Fingerprint>>,
pub mtime_cache: HashMap<PathBuf, FileTime>,
pub compiled: HashSet<Unit<'a>>,
pub build_scripts: HashMap<Unit<'a>, Arc<BuildScripts>>,
pub jobserver: Client,
pub rustc_clients: HashMap<Unit<'a>, Client>,
/* 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<'a>, 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<'a>, 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>>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<'a>, Arc<BuildScripts>>Linking information for each Unit.
See build_map for details.
jobserver: ClientJob server client to manage concurrency with other processes.
rustc_clients: HashMap<Unit<'a>, Client>When we’re in jobserver-per-rustc process mode, this keeps those jobserver clients for each Unit (which eventually becomes a rustc process).
Implementations§
Source§impl<'a, 'cfg> Context<'a, 'cfg>
impl<'a, 'cfg> Context<'a, 'cfg>
pub fn new( config: &'cfg Config, bcx: &'a BuildContext<'a, 'cfg>, unit_dependencies: UnitGraph<'a>, default_kind: CompileKind, ) -> CargoResult<Self>
Sourcepub fn compile(
self,
units: &[Unit<'a>],
export_dir: Option<PathBuf>,
exec: &Arc<dyn Executor>,
) -> CargoResult<Compilation<'cfg>>
pub fn compile( self, units: &[Unit<'a>], export_dir: Option<PathBuf>, exec: &Arc<dyn Executor>, ) -> CargoResult<Compilation<'cfg>>
Starts compilation, waits for it to finish, and returns information about the result of compilation.
Sourcepub fn get_executable(
&mut self,
unit: &Unit<'a>,
) -> CargoResult<Option<PathBuf>>
pub fn get_executable( &mut self, unit: &Unit<'a>, ) -> CargoResult<Option<PathBuf>>
Returns the executable for the specified unit (if any).
pub fn prepare_units( &mut self, export_dir: Option<PathBuf>, units: &[Unit<'a>], ) -> CargoResult<()>
Sourcepub fn prepare(&mut self) -> CargoResult<()>
pub fn prepare(&mut self) -> CargoResult<()>
Prepare this context, ensuring that all filesystem directories are in place.
pub fn files(&self) -> &CompilationFiles<'a, 'cfg>
Sourcepub fn outputs(&self, unit: &Unit<'a>) -> CargoResult<Arc<Vec<OutputFile>>>
pub fn outputs(&self, unit: &Unit<'a>) -> CargoResult<Arc<Vec<OutputFile>>>
Returns the filenames that the given unit will generate.
Sourcepub fn unit_deps(&self, unit: &Unit<'a>) -> &[UnitDep<'a>]
pub fn unit_deps(&self, unit: &Unit<'a>) -> &[UnitDep<'a>]
Direct dependencies for the given unit.
Sourcepub fn find_build_script_unit(&self, unit: Unit<'a>) -> Option<Unit<'a>>
pub fn find_build_script_unit(&self, unit: Unit<'a>) -> Option<Unit<'a>>
Returns the RunCustomBuild Unit associated with the given Unit.
If the package does not have a build script, this returns None.
Sourcepub fn find_build_script_metadata(&self, unit: Unit<'a>) -> Option<Metadata>
pub fn find_build_script_metadata(&self, unit: Unit<'a>) -> Option<Metadata>
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.
Sourcepub fn get_run_build_script_metadata(&self, unit: &Unit<'a>) -> Metadata
pub fn get_run_build_script_metadata(&self, unit: &Unit<'a>) -> Metadata
Returns the metadata hash for a RunCustomBuild unit.
pub fn is_primary_package(&self, unit: &Unit<'a>) -> bool
Sourcepub fn build_plan_inputs(&self) -> CargoResult<Vec<PathBuf>>
pub fn build_plan_inputs(&self) -> CargoResult<Vec<PathBuf>>
Returns the list of filenames read by cargo to generate the BuildContext
(all Cargo.toml, etc.).
Sourcepub fn only_requires_rmeta(&self, parent: &Unit<'a>, dep: &Unit<'a>) -> bool
pub fn only_requires_rmeta(&self, parent: &Unit<'a>, dep: &Unit<'a>) -> bool
Returns whether when parent depends on dep if it only requires the
metadata file from dep.
Sourcepub fn rmeta_required(&self, unit: &Unit<'a>) -> bool
pub fn rmeta_required(&self, unit: &Unit<'a>) -> bool
Returns whether when unit is built whether it should emit metadata as
well because some compilations rely on that.