- Gate MPRIS, tray (zbus/ksni) and the unix-socket single instance to unix; Windows gets stub modules and a loopback-TCP single instance - Use %APPDATA%/%LOCALAPPDATA% on Windows, hide the console window - build.rs embeds the icon and version resource on Windows targets - packaging/appimage.sh builds the AppImage with the libmpv library closure - packaging/mulberry.iss: per-user Inno Setup installer Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
29 lines
1.7 KiB
Rust
29 lines
1.7 KiB
Rust
//! Windows: embed the icon and version resource into mulberry.exe (needs windres on PATH; skipped without it).
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rerun-if-changed=packaging/mulberry.ico");
|
|
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {
|
|
return;
|
|
}
|
|
let out = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
|
let ver = std::env::var("CARGO_PKG_VERSION").unwrap();
|
|
let nums: Vec<&str> = ver.split('.').collect();
|
|
let comma = format!("{},{},{},0", nums[0], nums.get(1).unwrap_or(&"0"), nums.get(2).unwrap_or(&"0"));
|
|
let ico = std::fs::canonicalize("packaging/mulberry.ico").unwrap().to_string_lossy().replace('\\', "/");
|
|
let rc = format!(
|
|
"1 ICON \"{ico}\"\n\
|
|
1 VERSIONINFO\nFILEVERSION {comma}\nPRODUCTVERSION {comma}\nBEGIN\n BLOCK \"StringFileInfo\"\n BEGIN\n BLOCK \"040904b0\"\n BEGIN\n\
|
|
\x20 VALUE \"ProductName\", \"Mulberry\"\n VALUE \"FileDescription\", \"Mulberry music player\"\n VALUE \"FileVersion\", \"{ver}\"\n VALUE \"ProductVersion\", \"{ver}\"\n VALUE \"OriginalFilename\", \"mulberry.exe\"\n\
|
|
\x20 END\n END\n BLOCK \"VarFileInfo\"\n BEGIN\n VALUE \"Translation\", 0x0409, 1200\n END\nEND\n"
|
|
);
|
|
let rc_path = out.join("mulberry.rc");
|
|
std::fs::write(&rc_path, rc).unwrap();
|
|
let obj = out.join("mulberry_res.o");
|
|
let ok = std::process::Command::new("x86_64-w64-mingw32-windres").arg(&rc_path).arg(&obj).status().map(|s| s.success()).unwrap_or(false);
|
|
if ok {
|
|
println!("cargo:rustc-link-arg-bins={}", obj.display());
|
|
} else {
|
|
println!("cargo:warning=windres not available: mulberry.exe has no icon/version resource");
|
|
}
|
|
}
|