Struct autotools::Config

source ·
pub struct Config { /* private fields */ }
Expand description

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§

source§

impl Config

source

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

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

source

pub fn try_new<P: AsRef<Path>>(path: P) -> Result<Config, String>

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

source

pub fn enable_shared(&mut self) -> &mut Config

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

source

pub fn disable_shared(&mut self) -> &mut Config

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

source

pub fn enable_static(&mut self) -> &mut Config

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

source

pub fn disable_static(&mut self) -> &mut Config

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

source

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

Additional arguments to pass through to make.

source

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

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

source

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

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

source

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

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

source

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

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

source

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

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

source

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

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.

source

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

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.

source

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

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.

source

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

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).

source

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

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).

source

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

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.

source

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

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.

source

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

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

source

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

Build the given make target.

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

source

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

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.

source

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

Forbid an argument from being added to the configure command.

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

source

pub fn fast_build(&mut self, fast: bool) -> &mut Config

Enable fast building (which skips over configure if there is no) change in the configuration parameters.

source

pub fn configure(&mut self) -> PathBuf

Run this configuration

This will run only the build system generator.

source

pub fn try_configure(&mut self) -> Result<PathBuf, String>

Try to run this configuration

This will run only the build system generator, returning an error message on failure.

source

pub fn build(&mut self) -> PathBuf

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.

source

pub fn try_build(&mut self) -> Result<PathBuf, String>

Try to 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. If it fails it will return an error message

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.