1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
use std::process::Command; fn main() { let build = String::from_utf8_lossy( &Command::new("git") .args(&["rev-parse", "HEAD"]) .output() .unwrap() .stdout, ) .to_string(); println!( "cargo:rustc-env=DWVSH_BUILD={}", build.get(0..7).unwrap_or(&build) ); }