Skip to content

Commit

Permalink
Check in generated bindgen bindings (#52)
Browse files Browse the repository at this point in the history
* Check in generated bindgen bindings

This commit checks in the bindgen-generated bindings for the binaryen
project, along with a test that ensures that the generated bindings are
up to date and don't need to be regenerated. Additionally you can run
tests locally with `BLESS=1` to regenerate the header file to
automatically generate it.

* Add diff output to test

* Only bind some functions
  • Loading branch information
alexcrichton authored Mar 20, 2020
1 parent abe2bab commit b79731a
Show file tree
Hide file tree
Showing 6 changed files with 2,725 additions and 22 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ env:
- CC=clang CXX=clang++
- CC=gcc-7 CXX=g++-7
script:
- rustup component add rustfmt
- cargo build --all --verbose
# Run tests with --test-threads=1 as it looks like the linker runs out of memory
# when linking doctests in parallel.
Expand Down
5 changes: 4 additions & 1 deletion binaryen-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ exclude = [
]

[build-dependencies]
bindgen = "0.52.0"
cmake = "0.1.25"
cc = "1.0.4"
regex = "1"
heck = "0.3"

[dev-dependencies]
bindgen = "0.52.0"
diff = "0.1"
19 changes: 0 additions & 19 deletions binaryen-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
extern crate bindgen;
extern crate cc;
extern crate cmake;
extern crate heck;
Expand All @@ -11,23 +10,6 @@ use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;

fn gen_bindings() {
let bindings = bindgen::Builder::default()
.header("wrapper.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!");
}

#[derive(Clone, PartialEq, Debug)]
struct Pass {
id: String,
Expand Down Expand Up @@ -156,7 +138,6 @@ fn main() {
}

gen_passes();
gen_bindings();

let target = env::var("TARGET").ok();
if target.map_or(false, |target| target.contains("emscripten")) {
Expand Down
Loading

0 comments on commit b79731a

Please sign in to comment.