2019-02-02 00:52:22 +00:00
|
|
|
extern crate cbindgen;
|
|
|
|
|
2019-03-06 09:39:34 +00:00
|
|
|
use cbindgen::{Builder, Language};
|
2019-03-05 14:52:18 +00:00
|
|
|
use std::{env, path::Path};
|
2019-02-02 00:52:22 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
2019-03-06 09:39:34 +00:00
|
|
|
|
2019-03-05 14:52:18 +00:00
|
|
|
let out_dir = env::var("OUT_DIR").unwrap();
|
|
|
|
let out_path = Path::new(&out_dir);
|
2019-03-06 09:39:34 +00:00
|
|
|
|
2019-03-05 14:52:18 +00:00
|
|
|
let mut wasmer_h = out_path.to_path_buf();
|
|
|
|
wasmer_h.push("wasmer.h");
|
2019-03-06 09:39:34 +00:00
|
|
|
|
2019-03-05 14:52:18 +00:00
|
|
|
let mut wasmer_hh = out_path.to_path_buf();
|
|
|
|
wasmer_hh.push("wasmer.hh");
|
2019-02-02 00:52:22 +00:00
|
|
|
|
2019-03-06 09:39:34 +00:00
|
|
|
Builder::new()
|
2019-02-05 01:54:12 +00:00
|
|
|
.with_crate(crate_dir.clone())
|
2019-02-02 04:10:36 +00:00
|
|
|
.with_language(Language::C)
|
2019-02-10 00:07:05 +00:00
|
|
|
.with_include_guard("WASMER_H")
|
2019-02-02 00:52:22 +00:00
|
|
|
.generate()
|
2019-02-05 01:54:12 +00:00
|
|
|
.expect("Unable to generate C bindings")
|
2019-03-05 14:52:18 +00:00
|
|
|
.write_to_file(wasmer_h);
|
2019-02-05 01:54:12 +00:00
|
|
|
|
2019-03-06 09:39:34 +00:00
|
|
|
Builder::new()
|
2019-02-05 01:54:12 +00:00
|
|
|
.with_crate(crate_dir)
|
|
|
|
.with_language(Language::Cxx)
|
2019-02-10 00:07:05 +00:00
|
|
|
.with_include_guard("WASMER_H")
|
2019-02-05 01:54:12 +00:00
|
|
|
.generate()
|
|
|
|
.expect("Unable to generate C++ bindings")
|
2019-03-05 14:52:18 +00:00
|
|
|
.write_to_file(wasmer_hh);
|
2019-02-02 00:52:22 +00:00
|
|
|
}
|