2019-03-13 12:41:04 +00:00
|
|
|
extern crate bindgen;
|
|
|
|
|
|
|
|
use std::env;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
fn gen_bindings() {
|
|
|
|
let bindings = bindgen::Builder::default()
|
|
|
|
.header("evmc.h")
|
|
|
|
// See https://github.com/rust-lang-nursery/rust-bindgen/issues/947
|
|
|
|
.trust_clang_mangling(false)
|
|
|
|
.generate_comments(true)
|
|
|
|
// https://github.com/rust-lang-nursery/rust-bindgen/issues/947#issuecomment-327100002
|
|
|
|
.layout_tests(false)
|
2019-03-13 19:31:41 +00:00
|
|
|
// do not generate an empty enum for EVMC_ABI_VERSION
|
|
|
|
.constified_enum("")
|
|
|
|
// generate Rust enums for each evmc enum
|
|
|
|
.rustified_enum("*")
|
2019-03-13 12:41:04 +00:00
|
|
|
.generate()
|
|
|
|
.expect("Unable to generate bindings");
|
|
|
|
|
|
|
|
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
|
|
bindings
|
|
|
|
.write_to_file(out_path.join("bindings.rs"))
|
|
|
|
.expect("Couldn't write bindings!");
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
gen_bindings();
|
|
|
|
}
|