1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#[cfg(windows)]
use std::path::Path;
#[cfg(windows)]
use std::process::Command;
fn main() {
#[cfg(windows)]
{
let rc_path = Path::new("res/librius.rc");
// Rebuild only if the .rc file changes
println!("cargo:rerun-if-changed=res/librius.rc");
if rc_path.exists() {
// Compile the .rc file into a .res file using windres
// For MSVC toolchains, ensure MinGW is available in PATH
let result = Command::new("windres")
.env("PATH", "X:\\mingw64\\bin") // Adjust path if MinGW is installed elsewhere
.args(["res/librius.rc", "-O", "coff", "-o", "res/librius.res"])
.status();
match result {
Ok(status) if status.success() => {
// Link the compiled resource file into the final executable
println!("cargo:rustc-link-arg=res/librius.res");
}
Ok(status) => {
println!(
"cargo:warning=windres exited with non-zero status: {:?}",
status.code()
);
}
Err(_) => {
println!("cargo:warning=windres not found or failed to execute.");
}
}
} else {
println!("cargo:warning=res/librius.rc not found, skipping icon embedding.");
}
}
// Non-Windows platforms: no resource embedding required.
}