use std::env;
use std::path::{Path, PathBuf};
fn main() {
let root =
PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").expect("cargo sets the manifest dir"));
let bundle = root.join("assets").join("index.html");
let placeholder = root.join("assets").join("placeholder.html");
println!("cargo::rerun-if-changed=assets/index.html");
println!("cargo::rerun-if-changed=assets/placeholder.html");
let (source, kind) = if bundle.is_file() {
(bundle, "built")
} else {
println!(
"cargo::warning=assets/index.html has not been built, so the editor's page is a \
placeholder. Run ./Deploy.ps1 (or `bun run --cwd Web build`) to build it."
);
(placeholder, "placeholder")
};
let out =
Path::new(&env::var_os("OUT_DIR").expect("cargo sets the output dir")).join("index.html");
if let Err(e) = std::fs::copy(&source, &out) {
panic!("copying {} to {}: {e}", source.display(), out.display());
}
println!("cargo::rustc-env=TABLE_EDITOR_BUNDLE={kind}");
}