Skip to main content

BuildContext

Struct BuildContext 

Source
pub struct BuildContext<'a, 'cfg> {
    pub ws: &'a Workspace<'cfg>,
    pub config: &'cfg Config,
    pub profiles: Profiles,
    pub build_config: &'a BuildConfig,
    pub extra_compiler_args: HashMap<Unit<'a>, Vec<String>>,
    pub packages: &'a PackageSet<'cfg>,
    pub units: &'a UnitInterner<'a>,
    pub target_data: RustcTargetData,
    pub skip_units: RefCell<HashSet<Unit<'a>>>,
}
Expand description

The build context, containing all information about a build task.

It is intended that this is mostly static information. Stuff that mutates during the build can be found in the parent Context. (I say mostly, because this has internal caching, but nothing that should be observable or require &mut.)

Fields§

§ws: &'a Workspace<'cfg>

The workspace the build is for.

§config: &'cfg Config

The cargo configuration.

§profiles: Profiles§build_config: &'a BuildConfig§extra_compiler_args: HashMap<Unit<'a>, Vec<String>>

Extra compiler args for either rustc or rustdoc.

§packages: &'a PackageSet<'cfg>

Package downloader.

§units: &'a UnitInterner<'a>

Source of interning new units as they’re created.

§target_data: RustcTargetData

Information about rustc and the target platform.

§skip_units: RefCell<HashSet<Unit<'a>>>

Units which should be skipped, use in dependency builds

Implementations§

Source§

impl<'a, 'cfg> BuildContext<'a, 'cfg>

Source

pub fn new( ws: &'a Workspace<'cfg>, packages: &'a PackageSet<'cfg>, config: &'cfg Config, build_config: &'a BuildConfig, profiles: Profiles, units: &'a UnitInterner<'a>, extra_compiler_args: HashMap<Unit<'a>, Vec<String>>, target_data: RustcTargetData, ) -> CargoResult<BuildContext<'a, 'cfg>>

Source

pub fn rustc(&self) -> &Rustc

Source

pub fn linker(&self, kind: CompileKind) -> Option<PathBuf>

Gets the user-specified linker for a particular host or target.

Source

pub fn host_triple(&self) -> InternedString

Gets the host architecture triple.

For example, x86_64-unknown-linux-gnu, would be

  • machine: x86_64,
  • hardware-platform: unknown,
  • operating system: linux-gnu.
Source

pub fn jobs(&self) -> u32

Gets the number of jobs specified for this build.

Source

pub fn rustflags_args(&self, unit: &Unit<'_>) -> &[String]

Source

pub fn rustdocflags_args(&self, unit: &Unit<'_>) -> &[String]

Source

pub fn show_warnings(&self, pkg: PackageId) -> bool

Source

pub fn extra_args_for(&self, unit: &Unit<'a>) -> Option<&Vec<String>>

Source

pub fn script_override( &self, lib_name: &str, kind: CompileKind, ) -> Option<&BuildOutput>

If a build script is overridden, this returns the BuildOutput to use.

lib_name is the links library name and kind is whether it is for Host or Target.

Auto Trait Implementations§

§

impl<'a, 'cfg> !Freeze for BuildContext<'a, 'cfg>

§

impl<'a, 'cfg> !RefUnwindSafe for BuildContext<'a, 'cfg>

§

impl<'a, 'cfg> !Send for BuildContext<'a, 'cfg>

§

impl<'a, 'cfg> !Sync for BuildContext<'a, 'cfg>

§

impl<'a, 'cfg> Unpin for BuildContext<'a, 'cfg>

§

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

§

impl<'a, 'cfg> !UnwindSafe for BuildContext<'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.