mirror of https://github.com/xvxx/phetch
show build details on About screen
parent
1d9a2b0f01
commit
af449a6402
@ -1,6 +1,26 @@
|
||||
use std::{env, process};
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rustc-env=PLATFORM={}", env::var("TARGET").unwrap());
|
||||
println!("cargo:rustc-env=BUILD_DATE={}", sh("date"));
|
||||
println!(
|
||||
"cargo:rustc-env=PLATFORM={}",
|
||||
std::env::var("TARGET").unwrap()
|
||||
);
|
||||
"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()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue