Struct BuildEnv

Source
pub struct BuildEnv { /* private fields */ }
Expand description

Allow retrieval of values pretaining to a build process that may be related to the target and/or host triple.

Implementations§

Source§

impl BuildEnv

Source

pub fn from_env() -> Result<BuildEnv, VarError<String>>

Use environment variables (such as those set by cargo) to determine values for target and host via the environment variables TARGET and HOST.

Source

pub fn new_cross(host: String, target: String) -> BuildEnv

Construct a BuildEnv where the host and target may be different.

Source

pub fn new(trip: String) -> BuildEnv

Construct a BuildEnv where target and host are the same.

Source

pub fn target(&self) -> &str

The target we’re supplying values for

Source

pub fn host(&self) -> &str

The host we’re supplying values for

Source

pub fn used_env_vars(&self) -> impl Iterator<Item = &OsString>

Get the env vars that have been used by build-env queries so far

Source

pub fn cargo_print_used_env_vars(&self)

Print the used environment variables in the form interpreted by cargo: cargo:rerun-if-env-changed=FOO

Source

pub fn mark_used(&mut self, var: OsString)

Source

pub fn var<K: AsRef<OsStr>>(&mut self, var_base: K) -> Option<OsString>

Query the environment for a value, trying the most specific first, before querying more general variables.

  1. <var>_<target> - for example, CC_x86_64-unknown-linux-gnu
  2. <var>_<target_with_underscores> - for example, CC_x86_64_unknown_linux_gnu
  3. <build-kind>_<var> - for example, HOST_CC or TARGET_CFLAGS
  4. <var> - a plain CC, AR as above.
Source

pub fn var_str<K: AsRef<OsStr> + Debug + Any>( &mut self, var_base: K, ) -> Option<Result<String, VarError<K>>>

The same as [var()], but converts the return to an OsString and provides a useful error message

Trait Implementations§

Source§

impl Clone for BuildEnv

Source§

fn clone(&self) -> BuildEnv

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BuildEnv

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.