use std::process::Command;
fn main() {
add_git_revision();
let target = std::env::var("TARGET").unwrap();
if target.contains("windows") {
add_exe_resources();
}
}
fn add_exe_resources() {
println!("cargo:rerun-if-changed=resources");
embed_resource::compile("resources/app.rc", embed_resource::NONE)
.manifest_required()
.expect("failed to embed resources");
}
fn add_git_revision() {
let rev = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()
.and_then(|o| o.status.success().then_some(o.stdout))
.and_then(|v| String::from_utf8(v).ok())
.map_or_else(|| "unknown".to_string(), |s| s.trim().to_string());
println!("cargo:rustc-env=GIT_REVISION={rev}",);
}