2023-03-25 13:41:26 +13:00
|
|
|
use std::process::{Command, ExitStatus, Output};
|
2023-03-09 17:32:41 +13:00
|
|
|
|
|
|
|
#[cfg(not(target_os = "windows"))]
|
|
|
|
use std::os::unix::process::ExitStatusExt;
|
|
|
|
|
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
use std::os::windows::process::ExitStatusExt;
|
|
|
|
|
2023-01-30 22:02:43 +13:00
|
|
|
fn main() {
|
2023-12-29 09:21:06 +13:00
|
|
|
println!("cargo:rerun-if-changed=src/");
|
2023-01-30 22:02:43 +13:00
|
|
|
let output = String::from_utf8(
|
|
|
|
Command::new("git")
|
|
|
|
.args(["rev-parse", "HEAD"])
|
|
|
|
.output()
|
|
|
|
.unwrap_or(Output {
|
|
|
|
stdout: vec![],
|
|
|
|
stderr: vec![],
|
|
|
|
status: ExitStatus::from_raw(0),
|
|
|
|
})
|
|
|
|
.stdout,
|
|
|
|
)
|
|
|
|
.unwrap_or_default();
|
|
|
|
let git_hash = if output == String::default() { "dev".into() } else { output };
|
|
|
|
println!("cargo:rustc-env=GIT_HASH={git_hash}");
|
|
|
|
}
|