# Struct cargo::core::compiler::context::compilation_files::CompilationFiles

source ·

    pub struct CompilationFiles<'a, 'cfg> {
        pub(super) host: Layout,
        pub(super) target: HashMap<CompileTarget, Layout>,
        export_dir: Option<PathBuf>,
        roots: Vec<Unit>,
        ws: &'a Workspace<'cfg>,
        metas: HashMap<Unit, MetaInfo>,
        outputs: HashMap<Unit, LazyCell<Arc<Vec<OutputFile>>>>,
    }

Expand description

Collection of information about the files emitted by the compiler, and the output directory structure.

## Fields§

§`host: Layout`

The target directory layout for the host (and target if it is the same as host).

§`target: HashMap<CompileTarget, Layout>`

The target directory layout for the target (if different from then host).

§`export_dir: Option<PathBuf>`

Additional directory to include a copy of the outputs.

§`roots: Vec<Unit>`

The root targets requested by the user on the command line (does not include dependencies).

§`ws: &'a Workspace<'cfg>`§`metas: HashMap<Unit, MetaInfo>`

Metadata hash to use for each unit.

§`outputs: HashMap<Unit, LazyCell<Arc<Vec<OutputFile>>>>`

For each Unit, a list all files produced.

## Implementations§

source§

### impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg>

source

#### pub(super) fn new( cx: &Context<'a, 'cfg>, host: Layout, target: HashMap<CompileTarget, Layout> ) -> CompilationFiles<'a, 'cfg>

source

#### pub fn layout(&self, kind: CompileKind) -> &Layout

Returns the appropriate directory layout for either a plugin or not.

source

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

Gets the metadata for the given unit.

See `Metadata` and `fingerprint` module for more.

source

#### pub fn use_extra_filename(&self, unit: &Unit) -> bool

Returns whether or not `-C extra-filename` is used to extend the output filenames to make them unique.

source

#### pub fn target_short_hash(&self, unit: &Unit) -> String

Gets the short hash based only on the `PackageId`. Used for the metadata when `metadata` returns `None`.

source

#### pub fn out_dir(&self, unit: &Unit) -> PathBuf

Returns the directory where the artifacts for the given unit are initially created.

source

#### pub fn export_dir(&self) -> Option<PathBuf>

Additional export directory from `--out-dir`.

source

#### fn pkg_dir(&self, unit: &Unit) -> String

Directory name to use for a package in the form `NAME-HASH`.

Note that some units may share the same directory, so care should be taken in those cases!

source

#### pub fn host_dest(&self) -> &Path

Returns the final artifact path for the host (`/…/target/debug`)

source

#### pub fn host_root(&self) -> &Path

Returns the root of the build output tree for the host (`/…/target`)

source

#### pub fn host_deps(&self) -> &Path

Returns the host `deps` directory path.

source

#### pub fn deps_dir(&self, unit: &Unit) -> &Path

Returns the directories where Rust crate dependencies are found for the specified unit.

source

#### pub fn fingerprint_dir(&self, unit: &Unit) -> PathBuf

Directory where the fingerprint for the given unit should go.

source

#### pub fn fingerprint_file_path(&self, unit: &Unit, prefix: &str) -> PathBuf

Returns the path for a file in the fingerprint directory.

The “prefix” should be something to distinguish the file from other files in the fingerprint directory.

source

#### pub fn message_cache_path(&self, unit: &Unit) -> PathBuf

Path where compiler output is cached.

source

#### pub fn build_script_dir(&self, unit: &Unit) -> PathBuf

Returns the directory where a compiled build script is stored. `/path/to/target/{debug,release}/build/PKG-HASH`

source

#### fn artifact_dir(&self, unit: &Unit) -> PathBuf

Returns the directory for compiled artifacts files. `/path/to/target/{debug,release}/deps/artifact/KIND/PKG-HASH`

source

#### pub fn build_script_run_dir(&self, unit: &Unit) -> PathBuf

Returns the directory where information about running a build script is stored. `/path/to/target/{debug,release}/build/PKG-HASH`

source

#### pub fn build_script_out_dir(&self, unit: &Unit) -> PathBuf

Returns the “OUT_DIR” directory for running a build script. `/path/to/target/{debug,release}/build/PKG-HASH/out`

source

#### pub fn bin_link_for_target( &self, target: &Target, kind: CompileKind, bcx: &BuildContext<'_, '_> ) -> CargoResult<PathBuf>

Returns the path to the executable binary for the given bin target.

This should only to be used when a `Unit` is not available.

source

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

Returns the filenames that the given unit will generate.

Note: It is not guaranteed that all of the files will be generated.

source

#### fn uplift_to( &self, unit: &Unit, file_type: &FileType, from_path: &Path ) -> Option<PathBuf>

Returns the path where the output for the given unit and FileType should be uplifted to.

Returns `None` if the unit shouldn’t be uplifted (for example, a dependent rlib).

source

#### fn calc_outputs( &self, unit: &Unit, bcx: &BuildContext<'a, 'cfg> ) -> CargoResult<Arc<Vec<OutputFile>>>

Calculates the filenames that the given unit will generate. Should use `CompilationFiles::outputs` instead as it caches the result of this function.

source

#### fn calc_outputs_rustc( &self, unit: &Unit, bcx: &BuildContext<'a, 'cfg> ) -> CargoResult<Vec<OutputFile>>

Computes the actual, full pathnames for all the files generated by rustc.

The `OutputFile` also contains the paths where those files should be “uplifted” to.

## Auto Trait Implementations§

§

### impl<'a, 'cfg> !RefUnwindSafe for CompilationFiles<'a, 'cfg>

§

### impl<'a, 'cfg> !Send for CompilationFiles<'a, 'cfg>

§

### impl<'a, 'cfg> !Sync for CompilationFiles<'a, 'cfg>

§

### impl<'a, 'cfg> Unpin for CompilationFiles<'a, 'cfg>

§

### impl<'a, 'cfg> !UnwindSafe for CompilationFiles<'a, 'cfg>

## Blanket Implementations§

source§

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

source§

#### fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more
source§

### impl<T> Borrow<T> for Twhere T: ?Sized,

source§

#### fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

### impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

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

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

#### 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 Twhere 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> Same<T> for T

§

#### type Output = T

Should always be `Self`
source§

### impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

#### 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 Twhere U: TryFrom<T>,

§

#### 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 Twhere V: MultiLane<T>,

§

#### fn vzip(self) -> V

source§

### impl<T> WithSubscriber for T

source§

#### 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
source§

#### 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:472 bytes