Craig Constable 7960ae9218 v1.0.14
- Added metadata to help improve trust

- Updated file version handling to keep version information synced
2026-03-15 09:56:53 +10:00

31 lines
1.0 KiB
Rust

use winres::{VersionInfo, WindowsResource};
fn main() {
let version = env!("CARGO_PKG_VERSION");
// Embed the icon and richer PE version metadata into the executable.
let mut res = WindowsResource::new();
let numeric_version = pack_version(version);
res.set_icon("src/icons/icon.ico")
.set("FileVersion", version)
.set("ProductVersion", version)
.set_version_info(VersionInfo::FILEVERSION, numeric_version)
.set_version_info(VersionInfo::PRODUCTVERSION, numeric_version);
res.compile().expect("Failed to compile Windows resources");
}
fn pack_version(version: &str) -> u64 {
let core = version.split('-').next().unwrap_or(version);
let mut parts = core
.split('.')
.map(|part| part.parse::<u64>().unwrap_or(0));
let major = parts.next().unwrap_or(0).min(u16::MAX as u64);
let minor = parts.next().unwrap_or(0).min(u16::MAX as u64);
let patch = parts.next().unwrap_or(0).min(u16::MAX as u64);
(major << 48) | (minor << 32) | (patch << 16)
}