增加文件版本号

This commit is contained in:
zqm
2026-04-08 09:07:49 +08:00
parent 4ff57c8dea
commit a62ceba6de
4 changed files with 53 additions and 2 deletions

View File

@@ -4,10 +4,11 @@ version = 4
[[package]] [[package]]
name = "BootLoader" name = "BootLoader"
version = "0.1.0" version = "1.0.0"
dependencies = [ dependencies = [
"serde_json", "serde_json",
"windows", "windows",
"winres",
] ]
[[package]] [[package]]
@@ -93,6 +94,15 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "toml"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.24" version = "1.0.24"
@@ -216,6 +226,15 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winres"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c"
dependencies = [
"toml",
]
[[package]] [[package]]
name = "zmij" name = "zmij"
version = "1.0.21" version = "1.0.21"

View File

@@ -1,8 +1,11 @@
[package] [package]
name = "BootLoader" name = "BootLoader"
version = "0.1.0" version = "1.0.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
serde_json = "1.0" serde_json = "1.0"
windows = { version = "0.56", features = ["Win32_System_Console", "Win32_Foundation", "Win32_System_ProcessStatus", "Win32_System_Threading"] } windows = { version = "0.56", features = ["Win32_System_Console", "Win32_Foundation", "Win32_System_ProcessStatus", "Win32_System_Threading"] }
[target.'cfg(windows)'.build-dependencies]
winres = "0.1"

View File

@@ -0,0 +1,28 @@
use winres::WindowsResource;
fn main() {
// 仅在 Windows 上处理资源文件
#[cfg(windows)]
{
let mut res = WindowsResource::new();
// 设置 FileVersion = 1.0.0.0
// 编码方式高32位 = (major << 16 | minor)低32位 = (patch << 16 | build)
// 1.0.0.0 => 0x0001_0000_0000_0000
res.set_version_info(winres::VersionInfo::FILEVERSION, 0x0001_0000_0000_0000);
res.set_version_info(winres::VersionInfo::PRODUCTVERSION, 0x0001_0000_0000_0000);
// 设置产品名和公司名
res.set("ProductName", "BootLoader");
res.set("CompanyName", "JoyD");
res.set("FileDescription", "BootLoader Application");
res.set("LegalCopyright", "Copyright JoyD");
if let Err(e) = res.compile() {
eprintln!("Failed to compile resource file: {}", e);
std::process::exit(1);
}
}
println!("cargo:rerun-if-changed=build.rs");
}

View File

@@ -0,0 +1 @@
{"rustc_vv":"rustc 1.94.1 (e408947bf 2026-03-25)\nbinary: rustc\ncommit-hash: e408947bfd200af42db322daf0fadfe7e26d3bd1\ncommit-date: 2026-03-25\nhost: x86_64-pc-windows-msvc\nrelease: 1.94.1\nLLVM version: 21.1.8\n"}