extern crate bindgen; extern crate cmake; use std::env; use std::path::PathBuf; fn main() { let mut dst = cmake::Config::new("wavm") .define("WAVM_ENABLE_STATIC_LINKING", "ON") .define("WAVM_ENABLE_FUZZ_TARGETS", "OFF") .define("WAVM_ENABLE_UNWIND", "ON") .register_dep("LLVM") .build_target("libWAVM") .build(); dst.push("build"); println!("cargo:rustc-link-search=native={}", dst.display()); println!("cargo:rustc-link-lib=static=WAVM"); let bindings = bindgen::Builder::default() .header("src/wrapper.hpp") .clang_args( [ "-I", "src", "-I", "wavm/Include", "-I", &format!("{}/include", dst.display()), "-std=c++17", ] .iter(), ) .whitelist_type("wasm_.*") .whitelist_function("wasm_.*") .whitelist_function("WAVM::.*") .default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: false, }) .enable_cxx_namespaces() .raw_line("#[allow(bad_style)]") .derive_debug(true) .generate() .expect("Unable to generate bindings"); let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_dir.join("bindings.rs")) .expect("Could not write bindings"); }