use std::path::PathBuf;
use std::process::Command;
pub fn build(project_dir: &str, build_dir: &str) {
run_meson(project_dir, build_dir);
}
fn run_meson(lib: &str, dir: &str) {
if !is_configured(dir) {
run_command(lib, "meson", &[".", dir]);
}
run_command(dir, "ninja", &[]);
}
fn run_command(dir: &str, name: &str, args: &[&str]) {
let mut cmd = Command::new(name);
cmd.current_dir(dir);
if args.len() > 0 {
cmd.args(args);
}
let status = cmd.status().expect("cannot run command");
assert!(status.success());
}
fn is_configured(dir: &str) -> bool {
let mut path = PathBuf::from(dir);
path.push("build.ninja");
return path.as_path().exists();
}