use std::process::Command; use std::time::{SystemTime, UNIX_EPOCH}; fn main() { let git_hash = 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()); let build_ts = SystemTime::now() .duration_since(UNIX_EPOCH) .map(|d| d.as_secs()) .unwrap_or(0); println!("cargo:rustc-env=CORROSION_GIT_HASH={git_hash}"); println!("cargo:rustc-env=CORROSION_BUILD_TS={build_ts}"); println!("cargo:rerun-if-changed=../.git/HEAD"); }