Files
meatshell/build.rs
2026-06-19 03:09:53 +08:00

31 lines
1.4 KiB
Rust

fn main() {
// Bundle the gettext `.po` translations under `lang/` so the UI's `@tr(...)`
// strings can switch language at runtime via slint::select_bundled_translation.
// Source language is Chinese (the msgids); `lang/<lc>/LC_MESSAGES/meatshell.po`
// provides other locales. No per-component context, so msgids are the raw
// Chinese strings.
println!("cargo:rerun-if-changed=lang");
slint_build::compile_with_config(
"ui/app.slint",
slint_build::CompilerConfiguration::new()
.with_style("fluent".into())
.with_bundled_translations("lang")
.with_default_translation_context(slint_build::DefaultTranslationContext::None),
)
.expect("Slint build failed");
// Embed the application icon into the Windows executable so it shows up in
// Explorer, the taskbar and shortcuts. Build scripts run on the host, so a
// Linux -> Windows cross build must check the target OS via Cargo env vars
// instead of `#[cfg(windows)]`.
println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS");
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {
println!("cargo:rerun-if-changed=assets/meatshell.ico");
let mut res = winresource::WindowsResource::new();
res.set_icon("assets/meatshell.ico");
if let Err(e) = res.compile() {
println!("cargo:warning=failed to embed Windows icon: {e}");
}
}
}