use std::ffi::OsStr;
use std::fs;
use std::path::Path;
+use std::process::Command;
fn main() {
+ commit_info();
compress_man();
println!(
"cargo:rustc-env=RUST_HOST_TARGET={}",
let encoder = ar.into_inner().unwrap();
encoder.finish().unwrap();
}
+
+fn commit_info() {
+ if !Path::new(".git").exists() {
+ return;
+ }
+ let output = match Command::new("git")
+ .arg("log")
+ .arg("-1")
+ .arg("--date=short")
+ .arg("--format=%H %h %cd")
+ .arg("--abbrev=9")
+ .output()
+ {
+ Ok(output) if output.status.success() => output,
+ _ => return,
+ };
+ let stdout = String::from_utf8(output.stdout).unwrap();
+ let mut parts = stdout.split_whitespace();
+ let mut next = || parts.next().unwrap();
+ println!("cargo:rustc-env=CARGO_COMMIT_HASH={}", next());
+ println!("cargo:rustc-env=CARGO_COMMIT_SHORT_HASH={}", next());
+ println!("cargo:rustc-env=CARGO_COMMIT_DATE={}", next())
+}