Skip to main content

Context

Struct Context 

Source
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: Client

Job 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>

Source

pub fn new( config: &'cfg Config, bcx: &'a BuildContext<'a, 'cfg>, unit_dependencies: UnitGraph<'a>, default_kind: CompileKind, ) -> CargoResult<Self>

Source

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.

Source

pub fn get_executable( &mut self, unit: &Unit<'a>, ) -> CargoResult<Option<PathBuf>>

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

Source

pub fn prepare_units( &mut self, export_dir: Option<PathBuf>, units: &[Unit<'a>], ) -> CargoResult<()>

Source

pub fn prepare(&mut self) -> CargoResult<()>

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

Source

pub fn files(&self) -> &CompilationFiles<'a, 'cfg>

Source

pub fn outputs(&self, unit: &Unit<'a>) -> CargoResult<Arc<Vec<OutputFile>>>

Returns the filenames that the given unit will generate.

Source

pub fn unit_deps(&self, unit: &Unit<'a>) -> &[UnitDep<'a>]

Direct dependencies for the given unit.

Source

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.

Source

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.

Source

pub fn get_run_build_script_metadata(&self, unit: &Unit<'a>) -> Metadata

Returns the metadata hash for a RunCustomBuild unit.

Source

pub fn is_primary_package(&self, unit: &Unit<'a>) -> bool

Source

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.).

Source

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.

Source

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.

Source

pub fn new_jobserver(&mut self) -> CargoResult<Client>

Auto Trait Implementations§

§

impl<'a, 'cfg> Freeze for Context<'a, 'cfg>

§

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>

§

impl<'a, 'cfg> UnsafeUnpin for Context<'a, 'cfg>

§

impl<'a, 'cfg> !UnwindSafe for Context<'a, 'cfg>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.