2022-12-04 10:32:10 +11:00
|
|
|
use std::env;
|
|
|
|
use std::fs::File;
|
|
|
|
use std::io::{BufWriter, Write};
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
|
|
let mut buf = BufWriter::new(Vec::new());
|
|
|
|
cbindgen::generate(crate_dir)
|
|
|
|
.expect("Unable to generate bindings")
|
|
|
|
.write(&mut buf);
|
|
|
|
|
|
|
|
let bytes = buf.into_inner().expect("Unable to extract bytes");
|
|
|
|
let string = String::from_utf8(bytes).expect("Unable to create string");
|
|
|
|
// let string = string.replace("CHD_ERROR_", "CHDERR_");
|
2022-12-05 16:49:00 +11:00
|
|
|
File::create("librashader.h")
|
2022-12-04 10:32:10 +11:00
|
|
|
.expect("Unable to open file")
|
|
|
|
.write_all(string.as_bytes())
|
|
|
|
.expect("Unable to write bindings.")
|
2022-12-05 16:06:37 +11:00
|
|
|
}
|