Update README
This commit is contained in:
parent
6f40465aa0
commit
a6b582d6cc
2 changed files with 4 additions and 26 deletions
|
|
@ -63,6 +63,8 @@ Just a regular Rust binary build process.
|
|||
|
||||
cargo build --release
|
||||
|
||||
The "webui" feature requires npm and python3 installed.
|
||||
|
||||
## Useful options
|
||||
|
||||
### -v <log-level>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use anyhow::{bail, Context};
|
|||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
fn run(cwd: &Path, cmd: &str) -> anyhow::Result<()> {
|
||||
fn run_cmd(cwd: &Path, cmd: &str) -> anyhow::Result<()> {
|
||||
#[cfg(target_os = "windows")]
|
||||
let (shell, shell_args) = ("powershell", ["-command"].as_slice());
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
|
|
@ -39,33 +39,9 @@ fn main() {
|
|||
|
||||
println!("cargo:rerun-if-changed={}", webui_src_dir.to_str().unwrap());
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
let (shell, shell_args) = ("powershell", ["-command"].as_slice());
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let (shell, shell_args) = ("bash", ["-c"].as_slice());
|
||||
|
||||
// Run "npm install && npm run build" in the webui directory
|
||||
for cmd in ["npm install", "npm run build"] {
|
||||
// Run "npm install" in the webui directory
|
||||
let output = Command::new(shell)
|
||||
.args(shell_args)
|
||||
.arg(cmd)
|
||||
.current_dir(webui_dir)
|
||||
.output()
|
||||
.with_context(|| format!("Failed to execute {} in {:?}", cmd, webui_dir))
|
||||
.unwrap();
|
||||
|
||||
if !output.status.success() {
|
||||
panic!(
|
||||
"\"{}\" failed\n\nstderr: {}\n\nstdout: {}",
|
||||
cmd,
|
||||
String::from_utf8_lossy(&output.stderr),
|
||||
String::from_utf8_lossy(&output.stdout)
|
||||
);
|
||||
}
|
||||
|
||||
// Optionally print the stdout output if you want to see the build logs
|
||||
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||
run_cmd(webui_dir, cmd).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue