22 lines
916 B
Rust
22 lines
916 B
Rust
fn main() {
|
|
let hash = std::process::Command::new("git")
|
|
.args(["rev-parse", "--short", "HEAD"])
|
|
.output()
|
|
.ok()
|
|
.and_then(|o| String::from_utf8(o.stdout).ok())
|
|
.unwrap_or_default();
|
|
let hash = hash.trim();
|
|
println!("cargo:rustc-env=GIT_COMMIT={}", if hash.is_empty() { "unknown" } else { hash });
|
|
println!("cargo:rerun-if-changed=.git/HEAD");
|
|
|
|
// Embed Windows icon when cross-compiling for Windows
|
|
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {
|
|
let mut res = winres::WindowsResource::new();
|
|
res.set_icon("../../assets/icon.ico");
|
|
// Set cross-compile toolkit (mingw-w64)
|
|
res.set_toolkit_path("/usr");
|
|
res.set_windres_path("x86_64-w64-mingw32-windres");
|
|
res.set_ar_path("x86_64-w64-mingw32-ar");
|
|
res.compile().unwrap_or_else(|e| eprintln!("winres warning: {e}"));
|
|
}
|
|
}
|