Struct gcc::Config [] [src]

pub struct Config {
    // some fields omitted
}

Extra configuration to pass to gcc.

Methods

impl Config
[src]

fn new() -> Config

Construct a new instance of a blank set of configuration.

This builder is finished with the compile function.

fn include<P: AsRef<Path>>(&mut self, dir: P) -> &mut Config

Add a directory to the -I or include path for headers

fn define(&mut self, var: &str, val: Option<&str>) -> &mut Config

Specify a -D variable with an optional value.

fn object<P: AsRef<Path>>(&mut self, obj: P) -> &mut Config

Add an arbitrary object file to link in

fn flag(&mut self, flag: &str) -> &mut Config

Add an arbitrary flag to the invocation of the compiler

fn file<P: AsRef<Path>>(&mut self, p: P) -> &mut Config

Add a file which will be compiled

fn cpp(&mut self, cpp: bool) -> &mut Config

Set C++ support.

The other cpp_* options will only become active if this is set to true.

Set the standard library to link against when compiling with C++ support.

The default value of this property depends on the current target: On OS X Some("c++") is used, when compiling for a Visual Studio based target None is used and for other targets Some("stdc++") is used.

A value of None indicates that no automatic linking should happen, otherwise cargo will link against the specified library.

The given library name must not contain the lib prefix.

fn cpp_set_stdlib(&mut self, cpp_set_stdlib: Option<&str>) -> &mut Config

Force the C++ compiler to use the specified standard library.

Setting this option will automatically set cpp_link_stdlib to the same value.

The default value of this option is always None.

This option has no effect when compiling for a Visual Studio based target.

This option sets the -stdlib flag, which is only supported by some compilers (clang, icc) but not by others (gcc). The library will not detect which compiler is used, as such it is the responsibility of the caller to ensure that this option is only used in conjuction with a compiler which supports the -stdlib flag.

A value of None indicates that no specific C++ standard library should be used, otherwise -stdlib is added to the compile invocation.

The given library name must not contain the lib prefix.

fn target(&mut self, target: &str) -> &mut Config

Configures the target this configuration will be compiling for.

This option is automatically scraped from the TARGET environment variable by build scripts, so it's not required to call this function.

fn host(&mut self, host: &str) -> &mut Config

Configures the host assumed by this configuration.

This option is automatically scraped from the HOST environment variable by build scripts, so it's not required to call this function.

fn opt_level(&mut self, opt_level: u32) -> &mut Config

Configures the optimization level of the generated object files.

This option is automatically scraped from the OPT_LEVEL environment variable by build scripts, so it's not required to call this function.

fn debug(&mut self, debug: bool) -> &mut Config

Configures whether the compiler will emit debug information when generating object files.

This option is automatically scraped from the PROFILE environment variable by build scripts (only enabled when the profile is "debug"), so it's not required to call this function.

fn out_dir<P: AsRef<Path>>(&mut self, out_dir: P) -> &mut Config

Configures the output directory where all object files and static libraries will be located.

This option is automatically scraped from the OUT_DIR environment variable by build scripts, so it's not required to call this function.

fn compiler<P: AsRef<Path>>(&mut self, compiler: P) -> &mut Config

Configures the compiler to be used to produce output.

This option is automatically determined from the target platform or a number of environment variables, so it's not required to call this function.

fn archiver<P: AsRef<Path>>(&mut self, archiver: P) -> &mut Config

Configures the tool used to assemble archives.

This option is automatically determined from the target platform or a number of environment variables, so it's not required to call this function.

fn cargo_metadata(&mut self, cargo_metadata: bool) -> &mut Config

Define whether metadata should be emitted for cargo allowing it to automatically link the binary. Defaults to true.

fn compile(&self, output: &str)

Run the compiler, generating the file output

The name output must begin with lib and end with .a

fn get_compiler(&self) -> Tool

Get the compiler that's in use for this configuration.

This function will return a Tool which represents the culmination of this configuration at a snapshot in time. The returned compiler can be inspected (e.g. the path, arguments, environment) to forward along to other tools, or the to_command method can be used to invoke the compiler itself.

This method will take into account all configuration such as debug information, optimization level, include directories, defines, etc. Additionally, the compiler binary in use follows the standard conventions for this path, e.g. looking at the explicitly set compiler, environment variables (a number of which are inspected here), and then falling back to the default configuration.