use std::env;
use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};
fn main() {
println!("cargo:rustc-env=GIT_VERSION={}", env!("CARGO_PKG_VERSION"));
if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() {
if let Ok(commit) = String::from_utf8(output.stdout) {
println!("cargo:rustc-env=GIT_COMMIT={}", commit.trim());
}
}
if let Ok(target) = env::var("TARGET") {
println!("cargo:rustc-env=BUILD_PLATFORM={}", target);
}
if let Ok(build_time) = SystemTime::now().duration_since(UNIX_EPOCH) {
println!("cargo:rustc-env=BUILD_TIMESTAMP={}", build_time.as_secs());
}
}