feat: add cbindgen support
This commit is contained in:
23
wfassoc-cdylib/build.rs
Normal file
23
wfassoc-cdylib/build.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
extern crate cbindgen;
|
||||
|
||||
use std::{env, path::Path};
|
||||
|
||||
fn main() {
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
|
||||
let crate_dir_path = Path::new(&crate_dir);
|
||||
let cbindgen_toml_path = crate_dir_path.join("cbindgen.toml");
|
||||
let cbindgen_config = cbindgen::Config::from_file(cbindgen_toml_path)
|
||||
.expect("Unable to load cbindgen configuration file.");
|
||||
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let out_dir_path = Path::new(&out_dir);
|
||||
let wfassoc_h_path = out_dir_path.join("wfassoc.h");
|
||||
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(crate_dir)
|
||||
.with_config(cbindgen_config)
|
||||
.generate()
|
||||
.expect("Unable to generate bindings")
|
||||
.write_to_file(wfassoc_h_path);
|
||||
}
|
||||
Reference in New Issue
Block a user