extern crate gcc;
use std::process::Command;
use std::env;
fn debug() -> bool {
match env::var("DEBUG") {
Ok(s) => s == "true",
Err(_) => false
}
}
fn mode() -> &'static str {
if debug() { "Debug" } else { "Release" }
}
fn object_path(libname: &str) -> String {
format!("build/{}/obj.target/{}/src/{}.o", mode(), libname, libname)
}
fn build_object_file() {
Command::new("npm").arg("install").status().ok().unwrap();
Command::new("npm").arg("run").arg(if debug() { "configure-debug" } else { "configure-release" }).status().ok().unwrap();
Command::new("npm").arg("run").arg(if debug() { "build-debug" } else { "build-release" }).status().ok().unwrap();
}
fn link_library() {
gcc::Config::new()
.object(object_path("nanny"))
.compile("libnanny.a");
}
fn main() {
build_object_file();
link_library();
}