Quince/build.rs
astar76 2949d7a0a1 Add the --gallery page and release packaging
- quince --gallery shows every control in every state, light/dark/AMOLED
  and four seeds; "--gallery over" runs the real chrome on a made-up film.
- Fix: a toast's action button was drawn under the toast; the disabled
  play triangle showed a seam where its halves overlap.
- tools/package.sh (from Mulberry's): tar.gz, AppImage, Arch, .deb, Nix,
  Windows installer and portable zip; installer.sh, LICENSE, build.rs for
  the exe's icon and version, Inno Setup script, PKGBUILD.
- Release notes for 0.1.0 in docs/releases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 07:10:38 -06:00

29 lines
1.7 KiB
Rust

//! Windows: embed the icon and version resource into quince.exe (needs windres on PATH; skipped without it).
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=packaging/quince.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/quince.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\", \"Quince\"\n VALUE \"FileDescription\", \"Quince video player\"\n VALUE \"FileVersion\", \"{ver}\"\n VALUE \"ProductVersion\", \"{ver}\"\n VALUE \"OriginalFilename\", \"quince.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("quince.rc");
std::fs::write(&rc_path, rc).unwrap();
let obj = out.join("quince_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: quince.exe has no icon/version resource");
}
}