Struct autotools::Config[][src]

pub struct Config { /* fields omitted */ }

Builder style configuration for a pending autotools build.

Note

Note that host and target have different meanings for Rust than for Gnu autotools. For Rust, the “host” machine is the one where the compiler is running, and the “target” machine is the one where the compiled artifact (library or binary) will be executed. For Gnu autotools, the machine where the compiler is running is called the “build” machine; the one where the compiled artifact will be executed is called the “host” machine; and if the compiled artifact happens to be a cross-compiler, it will generate code for a “target” machine; otherwise “target” will coincide with “host”.

Hence Rust’s host corresponds to Gnu autotools’ “build” and Rust’s target corresponds to their “host” (though the relevant names will sometimes differ slightly).

The host and target methods on this package’s autotools::Config structure (as well as the $HOST and $TARGET variables set by cargo) are understood with their Rust meaning.

When cross-compiling, we try to calculate automatically what Gnu autotools will expect for its “host” value, and supply that to the configure script using a --host="..." argument. If the auto-calculation is incorrect, you can override it with the config_option method, like this:

use autotools;

// Builds the project in the directory located in `libfoo`, installing it
// into $OUT_DIR
let mut cfg = autotools::Config::new("libfoo_source_directory");
cfg.config_option("host", Some("i686-pc-windows-gnu"));
let dst = cfg.build();

println!("cargo:rustc-link-search=native={}", dst.display());
println!("cargo:rustc-link-lib=static=foo");

Implementations

impl Config[src]

pub fn new<P: AsRef<Path>>(path: P) -> Config[src]

Creates a new blank set of configuration to build the project specified at the path path.

pub fn enable_shared(&mut self) -> &mut Config[src]

Enables building as a shared library (--enable-shared).

pub fn disable_shared(&mut self) -> &mut Config[src]

Disables building as a shared library (--disable-shared).

pub fn enable_static(&mut self) -> &mut Config[src]

Enables building as a static library (--enable-static).

pub fn disable_static(&mut self) -> &mut Config[src]

Disables building as a static library (--disable-static).

pub fn make_args(&mut self, flags: Vec<String>) -> &mut Config[src]

Additional arguments to pass through to make.

pub fn config_option<P: AsRef<OsStr>>(
    &mut self,
    opt: P,
    optarg: Option<P>
) -> &mut Config
[src]

Passes --<opt><=optarg> to configure.

pub fn enable<P: AsRef<OsStr>>(
    &mut self,
    opt: P,
    optarg: Option<P>
) -> &mut Config
[src]

Passes --enable-<opt><=optarg> to configure.

pub fn disable<P: AsRef<OsStr>>(
    &mut self,
    opt: P,
    optarg: Option<P>
) -> &mut Config
[src]

Passes --disable-<opt><=optarg> to configure.

pub fn with<P: AsRef<OsStr>>(
    &mut self,
    opt: P,
    optarg: Option<P>
) -> &mut Config
[src]

Passes --with-<opt><=optarg> to configure.

pub fn without<P: AsRef<OsStr>>(
    &mut self,
    opt: P,
    optarg: Option<P>
) -> &mut Config
[src]

Passes --without-<opt><=optarg> to configure.

pub fn cflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config[src]

Adds a custom flag to pass down to the C compiler, supplementing those that this library already passes.

Default flags for the chosen compiler have lowest priority, then any flags from the environment variable $CFLAGS, then any flags specified with this method.

pub fn cxxflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config[src]

Adds a custom flag to pass down to the C++ compiler, supplementing those that this library already passes.

Default flags for the chosen compiler have lowest priority, then any flags from the environment variable $CXXFLAGS, then any flags specified with this method.

pub fn ldflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config[src]

Adds a custom flag to pass down to the linker, supplementing those that this library already passes.

Flags from the environment variable $LDFLAGS have lowest priority, then any flags specified with this method.

pub fn target(&mut self, target: &str) -> &mut Config[src]

Sets the target triple for this compilation.

This is automatically scraped from $TARGET which is set for Cargo build scripts so it’s not necessary to call this from a build script.

See Note on the differences between Rust’s and autotools’ interpretation of “target” (this method assumes the former).

pub fn host(&mut self, host: &str) -> &mut Config[src]

Sets the host triple for this compilation.

This is automatically scraped from $HOST which is set for Cargo build scripts so it’s not necessary to call this from a build script.

See Note on the differences between Rust’s and autotools’ interpretation of “host” (this method assumes the former).

pub fn out_dir<P: AsRef<Path>>(&mut self, out: P) -> &mut Config[src]

Sets the output directory for this compilation.

This is automatically scraped from $OUT_DIR which is set for Cargo build scripts so it’s not necessary to call this from a build script.

pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Config where
    K: AsRef<OsStr>,
    V: AsRef<OsStr>, 
[src]

Configure an environment variable for the configure && make processes spawned by this crate in the build step.

If you want to set $CFLAGS, $CXXFLAGS, or $LDFLAGS, consider using the cflag, cxxflag, or ldflag methods instead, which will append to any external values. Setting those environment variables here will overwrite the external values, and will also discard any flags determined by the chosen compiler.

autotools::Config will automatically pass $CC and $CXX values to the configure script based on the chosen compiler. Setting those variables here will override, and interferes with other parts of this library, so is not recommended.

pub fn reconf<P: AsRef<OsStr>>(&mut self, flags: P) -> &mut Config[src]

Options to pass through to autoreconf prior to configuring the build.

pub fn make_target(&mut self, make_target: &str) -> &mut Config[src]

Build the given make target.

If this function is not called, the build will default to make install.

pub fn insource(&mut self, build_insource: bool) -> &mut Config[src]

Build the library in-source.

This is generally not recommended, but can be required for libraries that make extensive use of nested Makefiles, which cannot be included in out-of-source builds.

pub fn forbid<T: ToString>(&mut self, arg: T) -> &mut Config[src]

Forbid an argument from being added to the configure command.

This can be used to account for non-standard configure scripts.

pub fn build(&mut self) -> PathBuf[src]

Run this configuration, compiling the library with all the configured options.

This will run both the build system generator command as well as the command to build the library.

Auto Trait Implementations

impl RefUnwindSafe for Config

impl Send for Config

impl Sync for Config

impl Unpin for Config

impl UnwindSafe for Config

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.