Files
pdfcraft/apps/printcraft/build.rs
T
Brandon ThomasandClaude Opus 5.5 51027324e1 Never crash: UI and app shell have no expect/unreachable
Each "checked" `expect` becomes `let … else`, `if let` or `?`, with the obvious fallback (the
dialog closes, the command is ignored, the view refresh is skipped). ui-egui and the three apps
now deny the panic lints. The Windows `build.rs` reports a failed resource step with
`cargo::error` instead of panicking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:12:20 -04:00

30 lines
1.4 KiB
Rust

//! Windows only: embed the app icon and version info (VERSIONINFO) into `printcraft.exe`, so it
//! shows in Explorer, the taskbar, the Start menu and Alt-Tab.
//!
//! On every other target this does nothing. A missing resource compiler is a warning, so a
//! cross-compile from macOS or Linux still links, unless `PRINTCRAFT_REQUIRE_WINRES=1` turns it
//! into an error (for release builds).
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=../../assets/app-icon/printcraft.ico");
println!("cargo:rerun-if-env-changed=PRINTCRAFT_REQUIRE_WINRES");
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {
return;
}
let mut res = winresource::WindowsResource::new();
res.set_icon("../../assets/app-icon/printcraft.ico")
.set("ProductName", "PrintCraft")
.set("FileDescription", "PrintCraft PDF workbench")
.set("LegalCopyright", "Copyright (c) the PrintCraft contributors. MIT OR Apache-2.0.")
.set("OriginalFilename", "printcraft.exe")
.set("InternalName", "printcraft");
if let Err(e) = res.compile() {
if std::env::var_os("PRINTCRAFT_REQUIRE_WINRES").is_some() {
println!("cargo::error=embedding Windows resources failed: {e}");
return;
}
println!("cargo:warning=printcraft.exe built without icon/version resources: {e}");
}
}