snolc / build.rs

github - master - back to tree - upstream
use std::process::Command; fn main() { println!("cargo::rerun-if-changed=.git/HEAD"); println!("cargo::rerun-if-changed=.git/index"); let commit = Command::new("git") .args(["rev-parse", "HEAD"]) .output() .ok() .filter(|output| output.status.success()) .and_then(|output| String::from_utf8(output.stdout).ok()) .map(|commit| commit.trim().to_owned()) .filter(|commit| !commit.is_empty()) .unwrap_or_else(|| "unknown".to_owned()); println!("cargo::rustc-env=SNOLC_COMMIT={commit}"); }