use std::process::Command; fn main() { // Git information let git_hash = Command::new("git") .args(["rev-parse", "--short", "HEAD"]) .output() .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()) .unwrap_or_else(|_| "unknown".to_string()); let build_time = chrono::Utc::now().to_rfc3339(); println!("cargo:rustc-env=GIT_HASH={}", git_hash); println!("cargo:rustc-env=BUILD_TIME={}", build_time); let rustc_version = Command::new("rustc") .arg("--version") .output() .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()) .unwrap_or_else(|_| "unknown".to_string()); println!("cargo:rustc-env=RUSTC_VERSION={}", rustc_version); }