[][src]Struct built::Options

pub struct Options { /* fields omitted */ }

Selects which information built should retrieve and write as Rust code.

Methods

impl Options[src]

pub fn set_compiler(&mut self, enabled: bool) -> &mut Self[src]

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";

pub fn set_git(&mut self, enabled: bool) -> &mut Self[src]

Detecting and writing the tag or commit id of the crate's git repository (if any).

This option is only available if built was compiled with the serialized_git 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");

Continuous Integration platforms like Travis and AppVeyor will do shallow clones, causing libgit2 to be unable to get a meaningful result. The GIT_VERSION will therefor always be None if a CI-platform is detected.

pub fn set_ci(&mut self, enabled: bool) -> &mut Self[src]

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");

pub fn set_env(&mut self, enabled: bool) -> &mut Self[src]

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;

pub fn set_dependencies(&mut self, enabled: bool) -> &mut Self[src]

Parsing Cargo.lockand 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";

pub fn set_features(&mut self, enabled: bool) -> &mut Self[src]

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";

pub fn set_time(&mut self, enabled: bool) -> &mut Self[src]

Writing the current timestamp.

This option is only available if built is compiled with the serialized_time 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 RFC822, UTC
pub const BUILT_TIME_UTC: &str = "Tue, 14 Feb 2017 01:12:35 GMT";

pub fn set_cfg(&mut self, enabled: bool) -> &mut Self[src]

Writing the configuration attributes.

built writes something like

/// The target architecture, given by `cfg!(target_arch)`.
pub const CFG_TARGET_ARCH: &str = "x86_64";
/// The endianness, given by `cfg!(target_endian)`.
pub const CFG_ENDIAN: &str = "little";
/// The toolchain-environment, given by `cfg!(target_env)`.
pub const CFG_ENV: &str = "gnu";
/// The OS-family, given by `cfg!(target_family)`.
pub const CFG_FAMILY: &str = "unix";
/// The operating system, given by `cfg!(target_os)`.
pub const CFG_OS: &str = "linux";
/// The pointer width, given by `cfg!(target_pointer_width)`.
pub const CFG_POINTER_WIDTH: &str = "64";

Trait Implementations

impl Default for Options[src]

fn default() -> Options[src]

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.

Auto Trait Implementations

impl Send for Options

impl Unpin for Options

impl Sync for Options

impl UnwindSafe for Options

impl RefUnwindSafe for Options

Blanket Implementations

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

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

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.

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.

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

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

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