fn main() {
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let manifest_path = std::path::Path::new(&manifest_dir);
let wasm_sysroot = manifest_path.join("wasm-sysroot");
println!("cargo::metadata=PATH={}", wasm_sysroot.display());
let target = std::env::var("TARGET").unwrap_or_default();
if target.contains("wasm") {
let mut build = cc::Build::new();
build
.include(&wasm_sysroot.join("src"))
.include(&wasm_sysroot)
.opt_level_str("z") .warnings(false)
.target(&target)
.host(&target);
build.file(wasm_sysroot.join("src/stdlib.c"));
build.file(wasm_sysroot.join("src/stdio.c"));
build.file(wasm_sysroot.join("src/ctype.c"));
build.file(wasm_sysroot.join("src/string.c"));
build.compile("arborium_sysroot");
println!("cargo:rerun-if-changed={}", wasm_sysroot.display());
println!("cargo:rerun-if-changed=build.rs");
}
}