use std::{env, path::PathBuf}; fn main() { let mut builder = cc::Build::new(); let build = builder .file("src/triangle.c") .flag("-DTRILIBRARY") .flag("-DANSI_DECLARATORS"); build.compile("triangle"); let bindings = bindgen::Builder::default() .header("src/triangle.h") .clang_arg("-DTRILIBRARY") .clang_arg("-DANSI_DECLARATORS") .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) .generate() .expect("Unable to generate bindings"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); println!("cargo:rerun-if-changed=src/triangle.h"); println!("cargo:rustc-link-lib=triangle"); }