Embed app icon in Windows executable

This commit is contained in:
2026-06-01 05:39:38 +02:00
parent 166f2463b5
commit 8edae70cc9
3 changed files with 28 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
fn main() {
// Embed icon on Windows (via windres for cross-compilation support)
#[cfg(target_os = "windows")]
{
let out_dir = std::env::var("OUT_DIR").unwrap();
let rc_path = "resources/app.rc";
let res_path = format!("{}/app.res", out_dir);
let status = std::process::Command::new("x86_64-w64-mingw32-windres")
.args([rc_path, "-O", "coff", "-o", &res_path])
.status();
if let Ok(s) = status {
if s.success() {
println!("cargo:rustc-link-arg={}", res_path);
return;
}
}
// Fallback: try plain windres
let status = std::process::Command::new("windres")
.args([rc_path, "-O", "coff", "-o", &res_path])
.status();
if let Ok(s) = status {
if s.success() {
println!("cargo:rustc-link-arg={}", res_path);
}
}
}
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 353 KiB

+1
View File
@@ -0,0 +1 @@
1 ICON "app.ico"