()
| 16 | } |
| 17 | |
| 18 | fn build_console() -> Result<(), Box<dyn std::error::Error>> { |
| 19 | let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?); |
| 20 | let ui_dir = manifest_dir.join("ui"); |
| 21 | let out_dir = PathBuf::from(env::var("OUT_DIR")?); |
| 22 | let output = out_dir.join("console_v1.html"); |
| 23 | |
| 24 | emit_rerun_if_changed(&manifest_dir.join("build.rs"))?; |
| 25 | emit_rerun_tree(&ui_dir)?; |
| 26 | |
| 27 | ensure_command("node", &["--version"], "Node.js")?; |
| 28 | ensure_command( |
| 29 | npm_cmd(), |
| 30 | &["--version"], |
| 31 | "npm (normally bundled with Node.js)", |
| 32 | )?; |
| 33 | |
| 34 | if should_run_npm_ci(&ui_dir)? { |
| 35 | run( |
| 36 | npm_cmd(), |
| 37 | &["ci"], |
| 38 | &ui_dir, |
| 39 | &[], |
| 40 | "Install VMM UI dependencies with `npm ci`", |
| 41 | )?; |
| 42 | } |
| 43 | |
| 44 | let output_str = output |
| 45 | .to_str() |
| 46 | .ok_or("OUT_DIR path contains non-UTF-8 characters")?; |
| 47 | run( |
| 48 | "node", |
| 49 | &["build.mjs"], |
| 50 | &ui_dir, |
| 51 | &[("DSTACK_UI_OUT", output_str)], |
| 52 | "Build VMM UI", |
| 53 | )?; |
| 54 | |
| 55 | if !output.exists() { |
| 56 | return Err(format!( |
| 57 | "UI build succeeded but {} was not created", |
| 58 | output.display() |
| 59 | ) |
| 60 | .into()); |
| 61 | } |
| 62 | |
| 63 | Ok(()) |
| 64 | } |
| 65 | |
| 66 | fn emit_rerun_tree(path: &Path) -> Result<(), Box<dyn std::error::Error>> { |
| 67 | if !path.exists() { |
no test coverage detected