use std::env;
use std::path::{Path, PathBuf};
fn main() {
let sameboy: PathBuf = cmake::build(Path::new("SameBoy"));
println!("cargo:rustc-link-search={}", sameboy.display());
println!("cargo:rustc-link-lib=sameboy");
let core = PathBuf::from("SameBoy/Core")
.canonicalize()
.expect("should have a Core dir in SameBoy");
let bindings = bindgen::Builder::default()
.header(core.join("gb.h").to_str().unwrap())
.allowlist_type("GB_.*")
.allowlist_function("GB_.*")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate()
.expect("failed to generate bindings");
let out = PathBuf::from(env::var("OUT_DIR").unwrap()).canonicalize().expect("should have an out dir");
let bindings_path = out.join("bindings.rs");
bindings.write_to_file(bindings_path).expect("failed to write bindings");
}