use regex::escape;
use std::path::PathBuf;
fn build_binding(header_name: &str) {
let emscripten_headers_path = PathBuf::from("emscripten/cache/sysroot/include");
let out_path = PathBuf::from("src");
bindgen::Builder::default()
.header(
emscripten_headers_path
.join(format!("emscripten/{}.h", header_name))
.to_string_lossy(),
)
.clang_arg(format!("-I{}", emscripten_headers_path.to_string_lossy()))
.allowlist_file(format!(
"{}.*",
escape(
&emscripten_headers_path
.join("emscripten/")
.to_string_lossy()
)
))
.generate()
.expect(&format!("Unable to generate bindings for {}", header_name))
.write_to_file(out_path.join(format!("{}.rs", header_name)))
.expect(&format!("Unable to write bindings for {}", header_name));
}
fn main() {
build_binding("emscripten");
build_binding("html5");
build_binding("console");
build_binding("websocket");
}