Struct Tool
pub struct Tool { /* private fields */ }
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
impl Tool
fn to_command(&self) -> CommandConverts this compiler into a
Commandthat'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.
The command does not inherit the process environment when it is spawned. Its environment is set in full: the copy of the process environment this
Toolwas made with (aBuild's copy, see its docs), thenTool::get_envs.fn path(&self) -> &PathReturns 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.
fn args(&self) -> &[OsString]Returns the default set of arguments to the compiler needed to produce executables for the target this compiler generates.
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.
The first call copies the variables.
Tool::get_envsborrows them instead.fn get_envs(&self) -> impl ExactSizeIterator<Item = (&OsStr, &OsStr)> + DoubleEndedIteratorReturns the environment variables needed for this compiler to operate, in the order
Tool::to_commandsets them, so a later entry for a variable wins over an earlier one.fn cc_env(&self) -> OsStringReturns 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
fn cflags_env(&self) -> OsStringReturns 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
fn is_like_gnu(&self) -> boolWhether the tool is GNU Compiler Collection-like.
fn is_like_clang(&self) -> boolWhether the tool is Clang-like.
fn is_like_msvc(&self) -> boolWhether the tool is MSVC-like.
fn is_like_clang_cl(&self) -> boolWhether the tool is
clang-cl-based MSVC-like.
Trait Implementations
impl Clone for Tool
fn clone(&self) -> Self
impl Debug for Tool
fn fmt(&self, f: &mut Formatter<'_>) -> Result