// TEMPLATE for apps/gridcraft/build.rs (copied from DesignCraft by the release-tooling setup; // apps/gridcraft didn't exist yet). Move it there and add to apps/gridcraft/Cargo.toml: // // [build-dependencies] // # Icon + VERSIONINFO for gridcraft.exe; build.rs only uses it when the target is Windows. // winresource = "0.1" // // and to apps/gridcraft/src/main.rs (package.ps1 checks the exe is a GUI-subsystem binary): // // #![cfg_attr(all(target_os = "windows", not(debug_assertions)), windows_subsystem = "windows")] // // package.ps1 sets GRIDCRAFT_REQUIRE_WINRES=1 so release builds fail without the resources. //! Windows only: embed the app icon and version info (VERSIONINFO) into `gridcraft.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 `GRIDCRAFT_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/gridcraft.ico"); println!("cargo:rerun-if-env-changed=GRIDCRAFT_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/gridcraft.ico") .set("ProductName", "GridCraft") .set("FileDescription", "GridCraft spreadsheet") .set("CompanyName", "Learning Machines LLC") .set("LegalCopyright", "Copyright (c) the GridCraft authors. MIT OR Apache-2.0.") .set("OriginalFilename", "gridcraft.exe") .set("InternalName", "gridcraft"); if let Err(e) = res.compile() { if std::env::var_os("GRIDCRAFT_REQUIRE_WINRES").is_some() { eprintln!("embedding Windows resources failed: {e}"); std::process::exit(1); } println!("cargo:warning=gridcraft.exe built without icon/version resources: {e}"); } }