use std::env; use std::path::PathBuf; fn main() { let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); let client_src = PathBuf::from(&manifest_dir).join("../client/src"); println!("cargo:rerun-if-changed=../client/src/net/pxl8_protocol.h"); println!("cargo:rerun-if-changed=../client/src/core/pxl8_types.h"); let bindings = bindgen::Builder::default() .header(client_src.join("net/pxl8_protocol.h").to_str().unwrap()) .clang_arg(format!("-I{}", client_src.join("core").display())) .use_core() .rustified_enum(".*") .generate() .expect("Unable to generate bindings"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_path.join("protocol.rs")) .expect("Couldn't write bindings"); }