File tree Expand file tree Collapse file tree 3 files changed +61
-9
lines changed
Expand file tree Collapse file tree 3 files changed +61
-9
lines changed Original file line number Diff line number Diff line change @@ -72,5 +72,8 @@ raw-cpuid = "11.5.0"
7272tempfile = { version = " 3.20.0" }
7373egui_kittest = { version = " 0.32.0" , features = [" eframe" ] }
7474
75+ [build-dependencies ]
76+ winres = " 0.1"
77+
7578[lints .clippy ]
7679uninlined_format_args = " allow"
Original file line number Diff line number Diff line change 1+ use std:: env;
2+ use std:: path:: Path ;
3+
14fn 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}
You can’t perform that action at this time.
0 commit comments