fn main() {
git_version();
log_directives();
}
fn git_version() {
let git_hash = std::process::Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()
.and_then(|o| if o.status.success() { Some(o.stdout) } else { None })
.and_then(|stdout| String::from_utf8(stdout).ok())
.map(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
println!("cargo:rustc-env=GIT_HASH={git_hash}");
}
fn log_directives() {
println!("cargo:rerun-if-changed=.cargo/log_directives");
if let Ok(directives) = std::fs::read_to_string(".cargo/log_directives") {
let directives = directives.trim();
if !directives.is_empty() {
println!("cargo:rustc-env=LOG_DIRECTIVES={directives}");
}
}
}