cc

Struct Tool

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

Configuration used to represent an invocation of a C compiler.

This can be used to figure out what compiler is in use, what the arguments to it are, and what the environment variables look like for the compiler. This can be used to further configure other build systems (e.g. forward along CC and/or CFLAGS) or the to_command method can be used to run the compiler itself.

Implementations§

Source§

impl Tool

Source

pub fn to_command(&self) -> Command

Converts this compiler into a Command that’s ready to be run.

This is useful for when the compiler needs to be executed and the command returned will already have the initial arguments and environment variables configured.

Source

pub fn path(&self) -> &Path

Returns the path for this compiler.

Note that this may not be a path to a file on the filesystem, e.g. “cc”, but rather something which will be resolved when a process is spawned.

Source

pub fn args(&self) -> &[OsString]

Returns the default set of arguments to the compiler needed to produce executables for the target this compiler generates.

Source

pub fn env(&self) -> &[(OsString, OsString)]

Returns the set of environment variables needed for this compiler to operate.

This is typically only used for MSVC compilers currently.

Source

pub fn cc_env(&self) -> OsString

Returns the compiler command in format of CC environment variable. Or empty string if CC env was not present

This is typically used by configure script

Source

pub fn cflags_env(&self) -> OsString

Returns the compiler flags in format of CFLAGS environment variable. Important here - this will not be CFLAGS from env, its internal gcc’s flags to use as CFLAGS This is typically used by configure script

Source

pub fn is_like_gnu(&self) -> bool

Whether the tool is GNU Compiler Collection-like.

Source

pub fn is_like_clang(&self) -> bool

Whether the tool is Clang-like.

Source

pub fn is_like_msvc(&self) -> bool

Whether the tool is MSVC-like.

Trait Implementations§

Source§

impl Clone for Tool

Source§

fn clone(&self) -> Tool

Returns a copy 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 Tool

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Tool

§

impl RefUnwindSafe for Tool

§

impl Send for Tool

§

impl Sync for Tool

§

impl Unpin for Tool

§

impl UnwindSafe for Tool

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.