openstellaris/triangle-sys/build.rs
2023-12-25 20:40:37 -05:00

25 lines
751 B
Rust

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");
}