diff --git a/.gitignore b/.gitignore index d61c9287..5e337146 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ **/*.rs.bk Cargo.lock .criterion +**/libproofs.h diff --git a/Cargo.toml b/Cargo.toml index 8973d3a0..3bb8f66a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,8 @@ criterion = "0.2.3" tempfile = "3" proptest = "0.7" +[build-dependencies] +cbindgen = "0.6.0" [[bench]] name = "pedersen" @@ -47,4 +49,4 @@ harness = false [[bench]] name = "drgraph" -harness = false \ No newline at end of file +harness = false diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..bfbb1832 --- /dev/null +++ b/build.rs @@ -0,0 +1,18 @@ +extern crate cbindgen; + +const VERSION: &'static str = env!("CARGO_PKG_VERSION"); + +fn main() { + let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); + + let cfg = cbindgen::Config::from_root_or_default(std::path::Path::new(&crate_dir)); + + cbindgen::Builder::new() + .with_config(cfg) + .with_crate(crate_dir) + .with_header(format!("/* libproofs Header Version {} */", VERSION)) + .with_language(cbindgen::Language::C) + .generate() + .expect("Unable to generate bindings") + .write_to_file("libproofs.h"); +} diff --git a/cbindgen.toml b/cbindgen.toml new file mode 100644 index 00000000..42026e67 --- /dev/null +++ b/cbindgen.toml @@ -0,0 +1,3 @@ +[export] +# A list of symbols to not include in the generated bindings +exclude = ["MerkleTree"]