//! Puts the page into the binary. The page is what `trunk build --release` writes to //! `crates/ui/dist`; until it has been built, a placeholder page stands in for it. use std::path::Path; const PLACEHOLDER: &str = "
The server is running and its API answers, but the page
that draws it is missing. Run just build in the repository (it runs
trunk build --release in crates/ui) and start sccache-dash again.
";
fn main() {
let crates = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap())
.parent()
.expect("crates/server has a parent")
.to_path_buf();
let dist = crates.join("ui").join("dist");
// Checked on every build, so the page is picked up as soon as `trunk build` has made it.
println!(
"cargo:rerun-if-changed={}",
dist.join("index.html").display()
);
let site = if dist.join("index.html").is_file() {
dist
} else {
let out = Path::new(&std::env::var("OUT_DIR").unwrap()).join("site");
std::fs::create_dir_all(&out).unwrap();
std::fs::write(out.join("index.html"), PLACEHOLDER).unwrap();
out
};
println!("cargo:rustc-env=DASH_SITE={}", site.display());
}