2024-05-12 17:15:30 +02:00
|
|
|
extern crate cbindgen;
|
|
|
|
|
|
|
|
use std::env;
|
2024-05-12 20:25:06 +02:00
|
|
|
|
2024-05-12 17:15:30 +02:00
|
|
|
use cbindgen::Language;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
|
|
|
2024-05-12 20:25:06 +02:00
|
|
|
let out_dir = env::var("SP2_INCLUDE_DIR")
|
|
|
|
.or(env::var("OUT_DIR"))
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
println!("cargo::warning={out_dir}");
|
|
|
|
|
|
|
|
println!("cargo::rerun-if-changed=src");
|
|
|
|
println!("cargo::rerun-if-env-changed=SP2_INCLUDE_DIR");
|
|
|
|
println!("cargo::rerun-if-env-changed=OUT_DIR");
|
2024-05-12 18:28:53 +02:00
|
|
|
|
2024-05-12 17:15:30 +02:00
|
|
|
cbindgen::Builder::new()
|
|
|
|
.with_crate(crate_dir)
|
|
|
|
.with_item_prefix("sp2_")
|
|
|
|
.with_language(Language::C)
|
2024-05-12 18:28:53 +02:00
|
|
|
.with_cpp_compat(true)
|
|
|
|
.with_parse_expand_all_features(true)
|
2024-05-12 17:15:30 +02:00
|
|
|
.generate()
|
|
|
|
.expect("Unable to generate bindings")
|
2024-05-12 20:25:06 +02:00
|
|
|
.write_to_file(format!("{out_dir}/sp2-bindings.h"));
|
2024-05-12 17:15:30 +02:00
|
|
|
}
|