use std::path::Path;
fn main() {
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR is set by cargo");
let dest = Path::new(&out_dir).join("unit.wasm");
println!("cargo:rerun-if-changed=web/unit.wasm");
let src = Path::new("web/unit.wasm");
if src.exists() {
std::fs::copy(src, &dest).expect("copy web/unit.wasm into OUT_DIR");
} else {
std::fs::write(&dest, []).expect("write unit.wasm stub into OUT_DIR");
}
let is_stub = std::fs::metadata(&dest).map(|m| m.len() == 0).unwrap_or(true);
if is_stub {
println!(
"cargo:warning=web/unit.wasm not present — the embedded web UI is a \
stub in this build (/unit.wasm will return 404). Run `just wasm` \
and rebuild to bundle the real one."
);
}
}