-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.rs
More file actions
29 lines (25 loc) · 1.05 KB
/
build.rs
File metadata and controls
29 lines (25 loc) · 1.05 KB
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
// build.rs - 构建时生成图标文件
use std::env;
use std::path::Path;
fn main() {
// 只在 Windows 平台上设置图标
if env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" {
// 检查是否存在 icon.ico 文件
let icon_path = Path::new("resources/icons/icon.ico");
if icon_path.exists() {
// 设置 Windows 图标
println!("cargo:rustc-link-arg-bins=/SUBSYSTEM:WINDOWS");
println!("cargo:rustc-link-arg-bins=/ENTRY:mainCRTStartup");
// 如果有 .rc 文件,可以在这里处理
let rc_path = Path::new("resources/app.rc");
if rc_path.exists() {
println!("cargo:rerun-if-changed=resources/app.rc");
// 这里可以添加资源编译逻辑
}
}
}
// 监听图标文件变化
println!("cargo:rerun-if-changed=resources/icons/icon.svg");
println!("cargo:rerun-if-changed=resources/icons/icon.ico");
println!("cargo:rerun-if-changed=resources/icons/icon.icns");
}