Files
fips/build.rs
Johnathan Corgan c086ee3edf Add build version metadata, changelog, and version display
Embed git commit hash, dirty flag, and target triple in all binaries
via a zero-dependency build.rs. Wire clap short/long version output
so -V shows "0.1.0 (rev abc1234)" and --version adds the target
triple. Log version at daemon startup.

Add version field to show_status control socket API response. Show
the daemon's version in fipstop's tab bar title and Runtime section.

Add CHANGELOG.md in Keep a Changelog format with the 0.1.0-alpha
release (2026-02-24) and unreleased work since then.
2026-03-08 02:19:33 +00:00

40 lines
1.2 KiB
Rust

use std::process::Command;
fn main() {
// Git commit hash (short)
let git_hash = Command::new("git")
.args(["rev-parse", "--short=10", "HEAD"])
.output()
.ok()
.filter(|o| o.status.success())
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
.unwrap_or_default();
println!("cargo:rustc-env=FIPS_GIT_HASH={git_hash}");
// Dirty working tree
let dirty = Command::new("git")
.args(["status", "--porcelain"])
.output()
.ok()
.filter(|o| o.status.success())
.map(|o| !o.stdout.is_empty())
.unwrap_or(false);
if dirty {
println!("cargo:rustc-env=FIPS_GIT_DIRTY=-dirty");
} else {
println!("cargo:rustc-env=FIPS_GIT_DIRTY=");
}
// Build target triple
if let Ok(target) = std::env::var("TARGET") {
println!("cargo:rustc-env=FIPS_TARGET={target}");
}
// Rebuild when commits change
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/refs/");
// Support reproducible builds (Debian packaging)
println!("cargo:rerun-if-env-changed=SOURCE_DATE_EPOCH");
}