Struct cargo::core::compiler::BuildRunner

source ·
pub struct BuildRunner<'a, 'gctx> {
Show 15 fields pub bcx: &'a BuildContext<'a, 'gctx>, pub compilation: Compilation<'gctx>, 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, primary_packages: HashSet<PackageId>, files: Option<CompilationFiles<'a, 'gctx>>, rmeta_required: HashSet<Unit>, pub lto: HashMap<Unit, Lto>, pub metadata_for_doc_units: HashMap<Unit, Metadata>, pub failed_scrape_units: Arc<Mutex<HashSet<Metadata>>>,
}
Expand description

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

Different from the BuildContext, Context is a mutable state used throughout the entire build process. Everything is coordinated through this.

Fields§

§bcx: &'a BuildContext<'a, 'gctx>

Mostly static information about the build task.

§compilation: Compilation<'gctx>

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.

§primary_packages: HashSet<PackageId>

“Primary” packages are the ones the user selected on the command-line with -p flags. If no flags are specified, then it is the defaults based on the current directory and the default workspace members.

§files: Option<CompilationFiles<'a, 'gctx>>

An abstraction of the files and directories that will be generated by the compilation. This is None until after unit_dependencies has been computed.

§rmeta_required: HashSet<Unit>

A set of units which are compiling rlibs and are expected to produce metadata files in addition to the rlib itself.

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

§failed_scrape_units: Arc<Mutex<HashSet<Metadata>>>

Set of metadata of Docscrape units that fail before completion, e.g. because the target has a type error. This is in an Arc<Mutex<..>> because it is continuously updated as the job progresses.

Implementations§

source§

impl<'a, 'gctx> BuildRunner<'a, 'gctx>

source

pub fn new(bcx: &'a BuildContext<'a, 'gctx>) -> CargoResult<Self>

source

pub fn compile( self, exec: &Arc<dyn Executor>, ) -> CargoResult<Compilation<'gctx>>

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

See ops::cargo_compile for a higher-level view of the compile process.

source

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

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

source

pub fn prepare_units(&mut self) -> 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, 'gctx>

source

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

Returns the filenames that the given unit will generate.

source

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

Direct dependencies for the given unit.

source

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.

source

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.

source

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

Returns the metadata hash for a RunCustomBuild unit.

source

pub fn is_primary_package(&self, unit: &Unit) -> 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 unit_output(&self, unit: &Unit, path: &Path) -> UnitOutput

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

source

fn check_collisions(&self) -> CargoResult<()>

Check if any output file name collision happens. See https://github.com/rust-lang/cargo/issues/6313 for more.

source

fn record_units_requiring_metadata(&mut self)

Records the list of units which are required to emit metadata.

Units which depend only on the metadata of others requires the others to actually produce metadata, so we’ll record that here.

source

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.

source

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.

source

pub fn compute_metadata_for_doc_units(&mut self)

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§

§

impl<'a, 'gctx> Freeze for BuildRunner<'a, 'gctx>

§

impl<'a, 'gctx> !RefUnwindSafe for BuildRunner<'a, 'gctx>

§

impl<'a, 'gctx> !Send for BuildRunner<'a, 'gctx>

§

impl<'a, 'gctx> !Sync for BuildRunner<'a, 'gctx>

§

impl<'a, 'gctx> Unpin for BuildRunner<'a, 'gctx>

§

impl<'a, 'gctx> !UnwindSafe for BuildRunner<'a, 'gctx>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 1880 bytes