fabro/lib/crates/fabro-cli/build.rs
Bryan Helmkamp 1b3d3d900b Move git SHA/build date from fabro-util to fabro-cli build.rs
fabro-util is a low-level crate depended on by almost everything, so its
build.rs reruns cascaded through the whole workspace. fabro-cli is the
leaf binary — nothing depends on it, so rebuilds are limited to just
that one crate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-13 15:03:12 -04:00

23 lines
736 B
Rust

fn main() {
println!("cargo:rerun-if-changed=../../../.git/HEAD");
let sha = std::process::Command::new("git")
.args(["rev-list", "-1", "HEAD"])
.output()
.ok()
.and_then(|o| {
if o.status.success() {
String::from_utf8(o.stdout)
.ok()
.map(|s| s.trim().to_string())
} else {
None
}
})
.unwrap_or_default();
let short_sha = if sha.len() >= 7 { &sha[..7] } else { &sha };
println!("cargo:rustc-env=FABRO_GIT_SHA={short_sha}");
let build_date = chrono::Utc::now().format("%Y-%m-%d").to_string();
println!("cargo:rustc-env=FABRO_BUILD_DATE={build_date}");
}