fn main() {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
for asset in ["assets/game/pieces/1/index.json", "assets/game/icons1x"] {
assert!(
root.join(asset).exists(),
"Missing {asset}. Run: bun tools/setup-assets.ts"
);
}
let sounds = root.join("assets/game/sounds");
let inventory: serde_json::Value = serde_json::from_slice(
&std::fs::read(sounds.join("index.json"))
.expect("Missing sound inventory; run tools/extract-assets.ts --sounds-only"),
)
.expect("Sound inventory JSON");
for clip in inventory["clips"].as_array().expect("Sound clips") {
let name = clip["name"].as_str().expect("Sound name");
let path = sounds.join(format!("{name}.ogg"));
assert!(path.is_file(), "Missing embedded sound {name}");
println!("cargo:rerun-if-changed={}", path.display());
}
println!(
"cargo:rerun-if-changed={}",
sounds.join("index.json").display()
);
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {
let icon = root.join("assets/game/factorio.ico");
println!("cargo:rerun-if-changed={}", icon.display());
assert!(
icon.is_file(),
"Missing icon. Run: bun tools/extract-assets.ts"
);
winresource::WindowsResource::new()
.set_icon(icon.to_str().expect("UTF-8 icon path"))
.set("ProductName", "Factorio Mod Manager")
.set("FileDescription", "Factorio Mod Manager")
.compile()
.expect("Compile the Windows icon resource");
}
slint_build::compile_with_config(
root.join("src/view/app.slint"),
slint_build::CompilerConfiguration::new()
.with_style("fluent".into())
.embed_resources(slint_build::EmbedResourcesKind::EmbedFiles),
)
.expect("Compile the Manage view");
}