Skip to content

Commit 448312d

Browse files
authored
fix: improve AW_WEBUI_DIR handling (#424)
1 parent 2e3298e commit 448312d

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

aw-server/build.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
use std::error::Error;
22

33
fn main() -> Result<(), Box<dyn Error>> {
4-
// if aw-webui/dist does not exist or is empty, print a warning
5-
let path = std::path::Path::new("../aw-webui/dist");
4+
let webui_var = std::env::var("AW_WEBUI_DIR");
5+
let path = if let Ok(var_path) = &webui_var {
6+
std::path::Path::new(var_path)
7+
} else {
8+
let path = std::path::Path::new("../aw-webui/dist");
9+
// ensure folder exists, since macro requires it
10+
std::fs::create_dir_all(path)?;
11+
println!("cargo:rustc-env=AW_WEBUI_DIR={}", path.display());
12+
path
13+
};
14+
615
let path_index = path.join("index.html");
716
if !path_index.exists() {
8-
println!("cargo:warning=`./aw-webui/dist` is not built, compiling without webui");
17+
println!(
18+
"cargo:warning=`{}` is not built, compiling without webui",
19+
path.display()
20+
);
921
}
1022

11-
// ensure folder exists, since macro requires it
12-
std::fs::create_dir_all(path)?;
13-
println!("cargo:rustc-env=AW_WEBUI_DIR=../aw-webui/dist");
14-
1523
Ok(())
1624
}

0 commit comments

Comments
 (0)