2026-03-24 11:13:57 +00:00
|
|
|
use std::env;
|
|
|
|
|
use std::fs;
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
|
|
|
let profile = env::var("PROFILE").unwrap();
|
|
|
|
|
|
|
|
|
|
let bindings = cbindgen::Builder::new()
|
|
|
|
|
.with_crate(&crate_dir)
|
|
|
|
|
.with_language(cbindgen::Language::C)
|
|
|
|
|
.with_style(cbindgen::Style::Tag)
|
|
|
|
|
.generate()
|
|
|
|
|
.expect("Unable to generate bindings");
|
|
|
|
|
|
|
|
|
|
let mut buf = Vec::new();
|
|
|
|
|
bindings.write(&mut buf);
|
|
|
|
|
let header = String::from_utf8(buf).unwrap();
|
|
|
|
|
fs::write(
|
|
|
|
|
PathBuf::from(&crate_dir)
|
|
|
|
|
.join("target")
|
|
|
|
|
.join(&profile)
|
|
|
|
|
.join("garnet_rs.h"),
|
2026-03-18 11:25:15 +00:00
|
|
|
header,
|
2026-03-24 11:13:57 +00:00
|
|
|
)
|
|
|
|
|
.unwrap();
|
|
|
|
|
}
|