Add basic Rust bindings

This commit is contained in:
Alex Beregszaszi 2019-03-13 13:41:04 +01:00
parent f6b10594ce
commit 58906e218b
6 changed files with 49 additions and 0 deletions

View File

@ -24,3 +24,6 @@ serialize = {major}
search = EVMC_ABI_VERSION = {current_version}
replace = EVMC_ABI_VERSION = {new_version}
[bumpversion:file:bindings/rust/Cargo.toml]
search = version = \"{current_version}\"

3
bindings/rust/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/target
**/*.rs.bk
/Cargo.lock

12
bindings/rust/Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "evmc-sys"
version = "6.2.0-dev"
authors = ["Alex Beregszaszi <alex@rtfs.hu>"]
license = "Apache-2.0"
repository = "https://github.com/ethereum/evmc"
description = "Bindings to EVMC (low-level)"
categories = ["external-ffi-bindings"]
edition = "2018"
[build-dependencies]
bindgen = "0.48.0"

25
bindings/rust/build.rs Normal file
View File

@ -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
bindings/rust/evmc.h Symbolic link
View File

@ -0,0 +1 @@
../../include/evmc/evmc.h

5
bindings/rust/src/lib.rs Normal file
View File

@ -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"));