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>,
/* 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.
Implementations
sourceimpl<'a, 'cfg> Context<'a, 'cfg>
impl<'a, 'cfg> Context<'a, 'cfg>
pub fn new(bcx: &'a BuildContext<'a, 'cfg>) -> CargoResult<Self>
sourcepub fn compile(self, exec: &Arc<dyn Executor>) -> CargoResult<Compilation<'cfg>>
pub fn compile(self, 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) -> CargoResult<Option<PathBuf>>
pub fn get_executable(&mut self, unit: &Unit) -> CargoResult<Option<PathBuf>>
Returns the executable for the specified unit (if any).
pub fn prepare_units(&mut self) -> 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) -> CargoResult<Arc<Vec<OutputFile>>>
pub fn outputs(&self, unit: &Unit) -> CargoResult<Arc<Vec<OutputFile>>>
Returns the filenames that the given unit will generate.
sourcepub fn find_build_script_unit(&self, unit: &Unit) -> Option<Unit>
pub fn find_build_script_unit(&self, unit: &Unit) -> Option<Unit>
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) -> Option<Metadata>
pub fn find_build_script_metadata(&self, unit: &Unit) -> 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) -> Metadata
pub fn get_run_build_script_metadata(&self, unit: &Unit) -> Metadata
Returns the metadata hash for a RunCustomBuild unit.
pub fn is_primary_package(&self, unit: &Unit) -> 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 unit_output(&self, unit: &Unit, path: &Path) -> UnitOutput
pub fn unit_output(&self, unit: &Unit, path: &Path) -> UnitOutput
Returns a UnitOutput
which represents some information about the
output of a unit.
sourcepub fn only_requires_rmeta(&self, parent: &Unit, dep: &Unit) -> bool
pub fn only_requires_rmeta(&self, parent: &Unit, dep: &Unit) -> bool
Returns whether when parent
depends on dep
if it only requires the
metadata file from dep
.
sourcepub fn rmeta_required(&self, unit: &Unit) -> bool
pub fn rmeta_required(&self, unit: &Unit) -> bool
Returns whether when unit
is built whether it should emit metadata as
well because some compilations rely on that.
pub fn new_jobserver(&mut self) -> CargoResult<Client>
Auto Trait Implementations
impl<'a, 'cfg> !RefUnwindSafe for Context<'a, 'cfg>
impl<'a, 'cfg> !Send for Context<'a, 'cfg>
impl<'a, 'cfg> !Sync for Context<'a, 'cfg>
impl<'a, 'cfg> Unpin for Context<'a, 'cfg> where
'cfg: 'a,
impl<'a, 'cfg> !UnwindSafe for Context<'a, 'cfg>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more