-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathbuild.rs
30 lines (26 loc) · 895 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let webui_var = std::env::var("AW_WEBUI_DIR");
let path = if let Ok(var_path) = &webui_var {
std::path::Path::new(var_path)
} else {
let path = std::path::Path::new("../aw-webui/dist");
// ensure folder exists, since macro requires it
std::fs::create_dir_all(path)?;
println!("cargo:rustc-env=AW_WEBUI_DIR={}", path.display());
path
};
let path_index = path.join("index.html");
if !path_index.exists() {
println!(
"cargo:warning=`{}` is not built, compiling without webui",
path.display()
);
}
// Rebuild if the webui directory changes
println!("cargo:rerun-if-env-changed=AW_WEBUI_DIR");
if webui_var.is_ok() {
println!("cargo:rerun-if-changed={}", webui_var.unwrap());
}
Ok(())
}