evmc/bindings/rust/evmc-sys/build.rs

35 lines
1011 B
Rust

/* EVMC: Ethereum Client-VM Connector API.
* Copyright 2019 The EVMC Authors.
* Licensed under the Apache License, Version 2.0.
*/
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)
// do not generate an empty enum for EVMC_ABI_VERSION
.constified_enum("")
// generate Rust enums for each evmc enum
.rustified_enum("*")
.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();
}