[][src]Function vergen::generate_version_rs

pub fn generate_version_rs(flags: ConstantsFlags) -> Result<(), Error>
Deprecated since 2.0.0:

Please use generate_cargo_keys instead

Create a version.rs file in OUT_DIR and write the toggled on constants to the file.

Example build.rs

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

Example Output (All Flags Enabled)

/// Build Timestamp (UTC)
pub const VERGEN_BUILD_TIMESTAMP: &str = "2018-08-09T15:15:57.282334589+00:00";

/// Build Date - Short (UTC)
pub const VERGEN_BUILD_DATE: &str = "2018-08-09";

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

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

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

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

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

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

Include the constants in your code (Version 1.x.x only)

This example is not tested
include!(concat!(env!("OUT_DIR"), "/version.rs"));

format!("{} {} blah {}", VERGEN_BUILD_TIMESTAMP, VERGEN_SHA, VERGEN_SEMVER)