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
sourceimpl Config
impl Config
sourcepub fn new<P: AsRef<Path>>(path: P) -> Config
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
.
Enables building as a shared library (--enable-shared
).
Disables building as a shared library (--disable-shared
).
sourcepub fn enable_static(&mut self) -> &mut Config
pub fn enable_static(&mut self) -> &mut Config
Enables building as a static library (--enable-static
).
sourcepub fn disable_static(&mut self) -> &mut Config
pub fn disable_static(&mut self) -> &mut Config
Disables building as a static library (--disable-static
).
sourcepub fn make_args(&mut self, flags: Vec<String>) -> &mut Config
pub fn make_args(&mut self, flags: Vec<String>) -> &mut Config
Additional arguments to pass through to make
.
sourcepub fn config_option<P: AsRef<OsStr>>(
&mut self,
opt: P,
optarg: Option<P>
) -> &mut Config
pub fn config_option<P: AsRef<OsStr>>(
&mut self,
opt: P,
optarg: Option<P>
) -> &mut Config
Passes --<opt><=optarg>
to configure.
sourcepub fn enable<P: AsRef<OsStr>>(
&mut self,
opt: P,
optarg: Option<P>
) -> &mut Config
pub fn enable<P: AsRef<OsStr>>(
&mut self,
opt: P,
optarg: Option<P>
) -> &mut Config
Passes --enable-<opt><=optarg>
to configure.
sourcepub fn disable<P: AsRef<OsStr>>(
&mut self,
opt: P,
optarg: Option<P>
) -> &mut Config
pub fn disable<P: AsRef<OsStr>>(
&mut self,
opt: P,
optarg: Option<P>
) -> &mut Config
Passes --disable-<opt><=optarg>
to configure.
sourcepub fn with<P: AsRef<OsStr>>(
&mut self,
opt: P,
optarg: Option<P>
) -> &mut Config
pub fn with<P: AsRef<OsStr>>(
&mut self,
opt: P,
optarg: Option<P>
) -> &mut Config
Passes --with-<opt><=optarg>
to configure.
sourcepub fn without<P: AsRef<OsStr>>(
&mut self,
opt: P,
optarg: Option<P>
) -> &mut Config
pub fn without<P: AsRef<OsStr>>(
&mut self,
opt: P,
optarg: Option<P>
) -> &mut Config
Passes --without-<opt><=optarg>
to configure.
sourcepub fn cflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config
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.
sourcepub fn cxxflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config
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.
sourcepub fn ldflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config
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.
sourcepub fn target(&mut self, target: &str) -> &mut Config
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).
sourcepub fn host(&mut self, host: &str) -> &mut Config
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).
sourcepub fn out_dir<P: AsRef<Path>>(&mut self, out: P) -> &mut Config
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.
sourcepub fn env<K, V>(&mut self, key: K, value: V) -> &mut Config where
K: AsRef<OsStr>,
V: AsRef<OsStr>,
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.
sourcepub fn reconf<P: AsRef<OsStr>>(&mut self, flags: P) -> &mut Config
pub fn reconf<P: AsRef<OsStr>>(&mut self, flags: P) -> &mut Config
Options to pass through to autoreconf
prior to configuring the build.
sourcepub fn make_target(&mut self, make_target: &str) -> &mut Config
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
.
sourcepub fn insource(&mut self, build_insource: bool) -> &mut Config
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.
sourcepub fn forbid<T: ToString>(&mut self, arg: T) -> &mut Config
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.
sourcepub fn fast_build(&mut self, fast: bool) -> &mut Config
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.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more