pub struct Options { /* private fields */ }
Expand description
Selects which information built
should retrieve and write as Rust code.
Used in conjunction with write_built_file_with_opts
.
Implementations§
source§impl Options
impl Options
sourcepub fn set_compiler(&mut self, enabled: bool) -> &mut Self
pub fn set_compiler(&mut self, enabled: bool) -> &mut Self
Detecting and writing the version of RUSTC
and RUSTDOC
.
Call the values of RUSTC
and RUSTDOC
as provided by Cargo to get a version string. The
result will something like
pub const RUSTC_VERSION: &str = "rustc 1.15.0";
pub const RUSTDOC_VERSION: &str = "rustdoc 1.15.0";
sourcepub fn set_git(&mut self, enabled: bool) -> &mut Self
pub fn set_git(&mut self, enabled: bool) -> &mut Self
Detecting and writing the tag or commit-id and a flag to indicate a dirty working directory of the crate’s git repository (if any).
This option is only available if built
was compiled with the
git2
feature.
Try to open the git-repository at manifest_location
and retrieve HEAD
tag or commit id. The result will be something like
pub const GIT_VERSION: Option<&str> = Some("0.1");
pub const GIT_DIRTY: Option<bool> = Some(false);
pub const GIT_COMMIT_HASH: Option<&str> = Some("18b2eabfb47998c296f9d5183f617f1b1cc2d321");
pub const GIT_COMMIT_HASH_SHORT: Option<&str> = Some("18b2eab");
pub const GIT_HEAD_REF: Option<&str> = Some("refs/heads/master");
Notice that GIT_HEAD_REF
is None
if HEAD
is detached or not valid UTF-8.
Continuous Integration platforms like Travis
and AppVeyor
will
do shallow clones, causing libgit2
to be unable to get a meaningful
result. GIT_VERSION
and GIT_DIRTY
will therefor always be None
if
a CI-platform is detected.
sourcepub fn set_ci(&mut self, enabled: bool) -> &mut Self
pub fn set_ci(&mut self, enabled: bool) -> &mut Self
Detecting and writing the Continuous Integration Platforms we are running on.
Detect various CI-platforms (named or not) and write something like
pub const CI_PLATFORM: Option<&str> = Some("AppVeyor");
sourcepub fn set_env(&mut self, enabled: bool) -> &mut Self
pub fn set_env(&mut self, enabled: bool) -> &mut Self
Detecting various information provided through the environment, especially Cargo.
built
writes something like
#[doc="The full version."]
pub const PKG_VERSION: &str = "1.2.3-rc1";
#[doc="The major version."]
pub const PKG_VERSION_MAJOR: &str = "1";
#[doc="The minor version."]
pub const PKG_VERSION_MINOR: &str = "2";
#[doc="The patch version."]
pub const PKG_VERSION_PATCH: &str = "3";
#[doc="The pre-release version."]
pub const PKG_VERSION_PRE: &str = "rc1";
#[doc="A colon-separated list of authors."]
pub const PKG_AUTHORS: &str = "Joe:Bob:Harry:Potter";
#[doc="The name of the package."]
pub const PKG_NAME: &str = "testbox";
#[doc="The description."]
pub const PKG_DESCRIPTION: &str = "xobtset";
#[doc="The home page."]
pub const PKG_HOMEPAGE: &str = "localhost";
#[doc="The target triple that was being compiled for."]
pub const TARGET: &str = "x86_64-apple-darwin";
#[doc="The host triple of the rust compiler."]
pub const HOST: &str = "x86_64-apple-darwin";
#[doc="`release` for release builds, `debug` for other builds."]
pub const PROFILE: &str = "debug";
#[doc="The compiler that cargo resolved to use."]
pub const RUSTC: &str = "rustc";
#[doc="The documentation generator that cargo resolved to use."]
pub const RUSTDOC: &str = "rustdoc";
#[doc="Value of OPT_LEVEL for the profile used during compilation."]
pub const OPT_LEVEL: &str = "0";
#[doc="The parallelism that was specified during compilation."]
pub const NUM_JOBS: u32 = 8;
#[doc="Value of DEBUG for the profile used during compilation."]
pub const DEBUG: bool = true;
sourcepub fn set_dependencies(&mut self, enabled: bool) -> &mut Self
pub fn set_dependencies(&mut self, enabled: bool) -> &mut Self
Parsing Cargo.lock
and writing lists of dependencies and their versions.
For this to work, Cargo.lock
needs to actually be there; this is (usually)
only true for executables and not for libraries. Cargo will only create a
Cargo.lock
for the top-level crate in a dependency-tree. In case
of a library, the top-level crate will decide which crate/version
combination to compile and there will be no Cargo.lock
while the library
gets compiled as a dependency.
Parsing Cargo.lock
instead of Cargo.toml
allows us to serialize the
precise versions Cargo chose to compile. One can’t, however, distinguish
build-dependencies
, dev-dependencies
and dependencies
. Furthermore,
some dependencies never show up if Cargo had not been forced to
actually use them (e.g. dev-dependencies
with cargo test
never
having been executed).
/// An array of effective dependencies as documented by `Cargo.lock`
pub const DEPENDENCIES: [(&str, &str); 2] = [("built", "0.1.0"), ("time", "0.1.36")];
/// The effective dependencies as a comma-separated string.
pub const DEPENDENCIES_STR: &str = "built 0.1.0, time 0.1.36";
sourcepub fn set_features(&mut self, enabled: bool) -> &mut Self
pub fn set_features(&mut self, enabled: bool) -> &mut Self
Writing features enabled during build.
One should not rely on this besides convenient debug output. If the runtime
depends on enabled features, use #[cfg(feature = "foo")]
instead.
/// The features that were enabled during compilation.
pub const FEATURES: [&str; 2] = ["DEFAULT", "WAYLAND"];
/// The features as a comma-separated string.
pub const FEATURES_STR: &str = "DEFAULT, WAYLAND";
/// The features as above, as lowercase strings.
pub const FEATURES_LOWERCASE: [&str; 2] = ["default", "wayland"];
/// The feature-string as above, from lowercase strings.
pub const FEATURES_LOWERCASE_STR: &str = "default, wayland";
sourcepub fn set_time(&mut self, enabled: bool) -> &mut Self
pub fn set_time(&mut self, enabled: bool) -> &mut Self
Writing the current timestamp.
This option is only available if built
is compiled with the
chrono
feature.
If built
is included as a runtime-dependency, it can parse the
string-representation into a time:Tm
with the help
of built::util::strptime()
.
/// The built-time in RFC2822, UTC
pub const BUILT_TIME_UTC: &str = "Tue, 14 Feb 2017 01:12:35 GMT";
sourcepub fn set_cfg(&mut self, enabled: bool) -> &mut Self
pub fn set_cfg(&mut self, enabled: bool) -> &mut Self
Writing the configuration attributes.
built
writes something like
/// The target architecture, given by `CARGO_CFG_TARGET_ARCH`.
pub const CFG_TARGET_ARCH: &str = "x86_64";
/// The endianness, given by `CARGO_CFG_TARGET_ENDIAN`.
pub const CFG_ENDIAN: &str = "little";
/// The toolchain-environment, given by `CARGO_CFG_TARGET_ENV`.
pub const CFG_ENV: &str = "gnu";
/// The OS-family, given by `CARGO_CFG_TARGET_FAMILY`.
pub const CFG_FAMILY: &str = "unix";
/// The operating system, given by `CARGO_CFG_TARGET_OS`.
pub const CFG_OS: &str = "linux";
/// The pointer width, given by `CARGO_CFG_TARGET_POINTER_WIDTH`.
pub const CFG_POINTER_WIDTH: &str = "64";
Trait Implementations§
source§impl Default for Options
impl Default for Options
source§fn default() -> Options
fn default() -> Options
A new struct with almost all options enabled.
Parsing and writing information about dependencies is disabled by default
because this information is not available for crates compiled as dependencies;
only the top-level crate gets to do this. See set_dependencies()
for
further information.