fix: improve winres icon embedding, log success/failure, auto-detect windres path
This commit is contained in:
parent
00380e07f3
commit
716d10e87c
1 changed files with 20 additions and 3 deletions
|
|
@ -11,12 +11,29 @@ fn main() {
|
|||
|
||||
// Embed Windows icon when cross-compiling for Windows
|
||||
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {
|
||||
// Find windres: prefer arch-prefixed, fall back to plain windres
|
||||
let windres = if std::process::Command::new("x86_64-w64-mingw32-windres")
|
||||
.arg("--version")
|
||||
.output()
|
||||
.is_ok()
|
||||
{
|
||||
"x86_64-w64-mingw32-windres"
|
||||
} else {
|
||||
"windres"
|
||||
};
|
||||
|
||||
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_windres_path(windres);
|
||||
res.set_ar_path("x86_64-w64-mingw32-ar");
|
||||
res.compile().unwrap_or_else(|e| eprintln!("winres warning: {e}"));
|
||||
|
||||
match res.compile() {
|
||||
Ok(_) => println!("cargo:warning=Icon embedded successfully via {windres}"),
|
||||
Err(e) => {
|
||||
println!("cargo:warning=winres failed: {e}");
|
||||
println!("cargo:warning=windres path used: {windres}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue