Skip to content

Commit

Permalink
Add basic Rust bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
axic authored and jakelang committed Mar 13, 2019
1 parent 139985d commit 01660ef
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bindings/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "evmc-sys"
version = "0.0.0"
authors = ["Alex Beregszaszi <[email protected]>"]
edition = "2018"

[build-dependencies]
bindgen = "0.30.0"
25 changes: 25 additions & 0 deletions bindings/rust/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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)
.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();
}
1 change: 1 addition & 0 deletions bindings/rust/evmc.h
5 changes: 5 additions & 0 deletions bindings/rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

0 comments on commit 01660ef

Please sign in to comment.