use std::process::Command;
fn main() {
cc::Build::new()
.cpp(true)
.file("cpp/rng_shim.cpp")
.std("c++17")
.warnings(true)
.compile("rng_shim");
println!("cargo:rerun-if-changed=cpp/rng_shim.cpp");
let git_hash = std::env::var("GIT_SHORT_HASH")
.ok()
.filter(|s| !s.is_empty() && s != "unknown")
.unwrap_or_else(|| {
Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()
.filter(|o| o.status.success())
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
.unwrap_or_else(|| "unknown".to_string())
});
println!("cargo:rustc-env=GIT_SHORT_HASH={}", git_hash);
let build_ts = Command::new("date")
.args(["-u", "+%Y-%m-%dT%H:%M:%SZ"])
.output()
.ok()
.filter(|o| o.status.success())
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
println!("cargo:rustc-env=BUILD_TIMESTAMP={}", build_ts);
println!("cargo:rerun-if-changed=.git/HEAD");
}