Function vergen::vergen[][src]

pub fn vergen(flags: ConstantsFlags) -> Result<()>

Create a version.rs file in OUT_DIR, and write up to 7 constants into it.

Example build.rs

fn main() {
    let mut flags = ConstantsFlags::all();
    flags.toggle(COMPILE_TIME);
    vergen(flags).expect("Unable to generate constants!");
}

Example Output (All Flags Enabled)

/// Compile Time (UTC)
const COMPILE_TIME: &str = "2018-08-09T15:15:57.282334589+00:00";

/// Compile Time - Short (UTC)
const COMPILE_TIME_SHORT: &str = "2018-08-09";

/// Commit SHA
const SHA: &str = "75b390dc6c05a6a4aa2791cc7b3934591803bc22";

/// Commit SHA - Short
const SHA_SHORT: &str = "75b390d";

/// Commit Date
const COMMIT_DATE: &str = "'2018-08-08'";

/// Target Triple
const TARGET_TRIPLE: &str = "x86_64-unknown-linux-gnu";

/// Semver
const SEMVER: &str = "v0.1.0-pre.0";

/// Semver (Lightweight)
pub const SEMVER_LIGHTWEIGHT: &str = "v0.1.0-pre.0";