Files
mock-server/build.rs
2026-03-26 19:20:22 +08:00

29 lines
1.1 KiB
Rust

fn main() {
// 仅在 Windows 平台上编译资源
if std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default() == "windows" {
let mut res = winres::WindowsResource::new();
// 1. 设置图标路径 (请确保 icons 文件夹下有 icon.ico)
res.set_icon("icons/icon.ico");
// 2. 自动同步 Cargo.toml 中的元数据
// 使用 env! 宏在编译阶段获取 package 信息
res.set("FileDescription", env!("CARGO_PKG_DESCRIPTION"));
res.set("ProductName", "Mock Server");
res.set("ProductVersion", env!("CARGO_PKG_VERSION"));
res.set("FileVersion", env!("CARGO_PKG_VERSION"));
res.set("InternalName", &format!("{}.exe", env!("CARGO_PKG_NAME")));
// 3. 设置版权信息
res.set("LegalCopyright", "Copyright © 2026 Ways");
// 4. 设置语言为中文 (中国)
res.set_language(0x0804);
// 执行编译,如果失败则打印错误并停止
if let Err(e) = res.compile() {
eprintln!("资源编译失败: {}", e);
std::process::exit(1);
}
}
}