-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
37 lines (31 loc) · 1.04 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::env;
use std::path::PathBuf;
fn main() {
let out_path = if let Ok(p) = env::var("LINK_PATH") {
PathBuf::from(p)
} else {
PathBuf::from(env::var("OUT_DIR").unwrap())
};
let binding_path = PathBuf::from(env::var("OUT_DIR").unwrap());
std::fs::create_dir_all(out_path.join("evmone")).unwrap();
let dst = cmake::Config::new("evmone")
.profile("Release")
.always_configure(true)
.out_dir(out_path.join("evmone"))
.build_target("evmone")
.build();
println!("cargo:rustc-link-search={}/build/lib", dst.display());
println!("cargo:rustc-link-lib=evmone");
let bindings = bindgen::Builder::default()
.header("evmone.h")
.clang_arg("-Ievmone/include")
.clang_arg("-Ievmone/evmc/include")
.blocklist_type(".*")
.allowlist_function("evmc_create_evmone")
.raw_line("use evmc_sys::evmc_vm;")
.generate()
.unwrap();
bindings
.write_to_file(binding_path.join("bindings.rs"))
.unwrap();
}