Files
fips/src/version.rs
T
Johnathan Corgan 13c0b70dc3 Add rustfmt formatting policy and reformat codebase
Add rustfmt.toml with stable defaults and apply cargo fmt to all
source files. This establishes a consistent formatting baseline
for CI enforcement.
2026-04-10 08:27:07 +00:00

38 lines
1006 B
Rust

//! Build version information for FIPS binaries.
use std::sync::LazyLock;
/// Package version from Cargo.toml.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
/// Short git commit hash (empty if not available).
const GIT_HASH: &str = env!("FIPS_GIT_HASH");
/// Dirty flag ("-dirty" or empty).
const GIT_DIRTY: &str = env!("FIPS_GIT_DIRTY");
/// Build target triple.
const TARGET: &str = env!("FIPS_TARGET");
/// Short version string for `-V`: `0.1.0 (rev abc1234567)`
#[allow(clippy::const_is_empty)]
static SHORT_VERSION: LazyLock<String> = LazyLock::new(|| {
if GIT_HASH.is_empty() {
VERSION.to_string()
} else {
format!("{VERSION} (rev {GIT_HASH}{GIT_DIRTY})")
}
});
/// Long version string for `--version` with build metadata.
static LONG_VERSION: LazyLock<String> =
LazyLock::new(|| format!("{}\ntarget: {TARGET}", *SHORT_VERSION));
pub fn short_version() -> &'static str {
&SHORT_VERSION
}
pub fn long_version() -> &'static str {
&LONG_VERSION
}