Skip to content

Commit 1658b55

Browse files
committed
fix
1 parent 462c582 commit 1658b55

File tree

3 files changed

+61
-9
lines changed

3 files changed

+61
-9
lines changed

Cargo.lock

Lines changed: 22 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,8 @@ raw-cpuid = "11.5.0"
7272
tempfile = { version = "3.20.0" }
7373
egui_kittest = { version = "0.32.0", features = ["eframe"] }
7474

75+
[build-dependencies]
76+
winres = "0.1"
77+
7578
[lints.clippy]
7679
uninlined_format_args = "allow"

build.rs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
1+
use std::env;
2+
use std::path::Path;
3+
14
fn main() {
2-
// Windows-specific icon embedding
3-
#[cfg(target_os = "windows")]
4-
{
5-
let mut res = winres::WindowsResource::new();
6-
res.set_icon("assets/DET_LOGO.ico");
7-
res.compile().unwrap();
5+
println!("cargo:rerun-if-changed=assets/DET_LOGO.ico");
6+
7+
let target = env::var("TARGET").unwrap_or_default();
8+
if !target.contains("windows") {
9+
return;
10+
}
11+
12+
let icon_path = Path::new("assets/DET_LOGO.ico");
13+
if !icon_path.exists() {
14+
eprintln!(
15+
"cargo:warning=Windows icon asset missing at {}",
16+
icon_path.display()
17+
);
18+
return;
19+
}
20+
21+
let mut res = winres::WindowsResource::new();
22+
let icon_str = icon_path
23+
.to_str()
24+
.expect("icon path must be valid UTF-8 for the resource compiler");
25+
res.set_icon(icon_str);
26+
27+
if let Ok(version) = env::var("CARGO_PKG_VERSION") {
28+
res.set("FileVersion", &version);
29+
res.set("ProductVersion", &version);
30+
}
31+
32+
if let Ok(product_name) = env::var("CARGO_PKG_NAME") {
33+
res.set("ProductName", &product_name);
34+
}
35+
36+
if let Err(err) = res.compile() {
37+
panic!("Failed to embed Windows resources: {err}");
838
}
939
}

0 commit comments

Comments
 (0)