forked from 1b-agent/fieldcraft-upstream
The window's Wayland app_id / X11 class is io.github.jyviko.fieldcraft, the id the release packages use for the .desktop entry and the macOS bundle (#72). Windows builds embed assets/app-icon/icon.ico in fieldcraft.exe through embed-resource (MIT, a build dependency only). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm
21 lines
989 B
Rust
21 lines
989 B
Rust
//! Windows builds embed the application icon (assets/app-icon/icon.ico) in `fieldcraft.exe`, so
|
|
//! Explorer, the taskbar and shortcuts show it. Other targets need nothing here.
|
|
#![forbid(unsafe_code)]
|
|
|
|
use std::path::PathBuf;
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let icon = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?).join("../../assets/app-icon/icon.ico");
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rerun-if-changed={}", icon.display());
|
|
if std::env::var("CARGO_CFG_TARGET_OS")? != "windows" {
|
|
return Ok(());
|
|
}
|
|
let out = PathBuf::from(std::env::var("OUT_DIR")?);
|
|
let rc = out.join("fieldcraft.rc");
|
|
std::fs::write(&rc, format!("1 ICON \"{}\"\n", icon.display().to_string().replace('\\', "/")))?;
|
|
// Missing resource tools are a build error, rather than silently shipping a generic icon.
|
|
embed_resource::compile_for(&rc, ["fieldcraft"], embed_resource::NONE).manifest_required()?;
|
|
Ok(())
|
|
}
|