2020-01-06 18:18:27 +00:00
|
|
|
use std::{env, process};
|
|
|
|
|
2020-01-04 22:10:51 +00:00
|
|
|
fn main() {
|
2020-01-06 18:18:27 +00:00
|
|
|
println!("cargo:rustc-env=PLATFORM={}", env::var("TARGET").unwrap());
|
2020-01-06 18:26:48 +00:00
|
|
|
println!("cargo:rustc-env=BUILD_DATE={}", sh("date +%Y-%m-%d"));
|
2020-01-04 22:10:51 +00:00
|
|
|
println!(
|
2020-01-06 18:18:27 +00:00
|
|
|
"cargo:rustc-env=GIT_REF={}",
|
|
|
|
sh("git rev-parse --short HEAD")
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn sh(args: &str) -> String {
|
|
|
|
let args: Vec<&str> = args.split(" ").collect();
|
|
|
|
let cmd = args[0];
|
|
|
|
let args: Vec<_> = args.iter().skip(1).collect();
|
|
|
|
|
|
|
|
if let Ok(output) = process::Command::new(cmd).args(&args).output() {
|
|
|
|
if !output.status.success() {
|
|
|
|
eprintln!("Error running {} {:?}", cmd, args);
|
|
|
|
process::exit(1);
|
|
|
|
}
|
|
|
|
String::from_utf8(output.stdout).unwrap()
|
|
|
|
} else {
|
|
|
|
String::new()
|
|
|
|
}
|
2020-01-04 22:10:51 +00:00
|
|
|
}
|