Skip to content

Commit

Permalink
simplified build
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed May 8, 2022
1 parent 845e381 commit 4f1ac2a
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions bindings/rust/evmc-loader/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ extern crate cmake;

use cmake::Config;
use std::env;
use std::path::{Path, PathBuf};
use std::path::PathBuf;

fn main() {
let dst = Config::new("../../../").build();

println!("cargo:rustc-link-lib=static=evmc-loader");
println!(
"cargo:rustc-link-search=native={}/build/lib/loader",
dst.display()
);

fn gen_bindings() {
let bindings = bindgen::Builder::default()
.header("loader.h")
.generate_comments(false)
// do not generate an empty enum for EVMC_ABI_VERSION
.constified_enum("")
// generate Rust enums for each evmc enum
.rustified_enum("*")
// force deriving the Hash trait on basic types (address, bytes32)
.derive_hash(true)
// force deriving the PratialEq trait on basic types (address, bytes32)
.derive_partialeq(true)
.allowlist_type("evmc_.*")
.allowlist_function("evmc_.*")
// TODO: consider removing this
Expand All @@ -31,17 +35,5 @@ fn gen_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 gen_loader() {
let build_dir = Config::new("../../../").build();
let loader_path = Path::new(&build_dir).join("build/lib/loader");
println!("cargo:rustc-link-search=native={}", loader_path.display());
println!("cargo:rustc-link-lib=static=evmc-loader");
}

fn main() {
gen_loader();
gen_bindings();
.expect("Could not write bindings");
}

0 comments on commit 4f1ac2a

Please sign in to comment.