use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};
fn main() {
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/refs/heads");
if let Ok(output) = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
{
if output.status.success() {
if let Ok(hash) = String::from_utf8(output.stdout) {
let trimmed = hash.trim();
if !trimmed.is_empty() {
println!("cargo:rustc-env=BATLESS_GIT_HASH={trimmed}");
}
}
}
}
if let Ok(duration) = SystemTime::now().duration_since(UNIX_EPOCH) {
println!(
"cargo:rustc-env=BATLESS_BUILD_TIMESTAMP={}",
duration.as_secs()
);
}
}