2021-05-23 14:06:35 +10:00
|
|
|
use std::{
|
|
|
|
env,
|
|
|
|
path::{self, PathBuf},
|
|
|
|
};
|
2021-04-20 07:21:44 +10:00
|
|
|
|
|
|
|
fn find_mgba_library() -> Option<&'static str> {
|
2021-05-23 10:34:56 +10:00
|
|
|
const POTENTIAL_LIBRARY_LOCATIONS: &[&str] =
|
|
|
|
&["/usr/lib/libmgba.so.0.9", "/usr/local/lib/libmgba.so.0.9"];
|
2021-04-20 07:21:44 +10:00
|
|
|
|
|
|
|
POTENTIAL_LIBRARY_LOCATIONS
|
|
|
|
.iter()
|
|
|
|
.find(|file_path| path::Path::new(file_path).exists())
|
|
|
|
.copied()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2021-05-23 10:34:56 +10:00
|
|
|
let mgba_library = find_mgba_library().expect("Need mgba 0.9 installed");
|
2021-04-20 07:21:44 +10:00
|
|
|
|
|
|
|
cc::Build::new()
|
|
|
|
.file("c/test-runner.c")
|
|
|
|
.object(mgba_library)
|
|
|
|
.include("c/include")
|
|
|
|
.compile("test-runner");
|
2021-05-23 14:06:35 +10:00
|
|
|
|
|
|
|
let bindings = bindgen::Builder::default()
|
|
|
|
.header("c/test-runner.h")
|
|
|
|
.generate()
|
|
|
|
.expect("Unable to generate bindings");
|
|
|
|
|
|
|
|
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
|
|
bindings
|
|
|
|
.write_to_file(out_path.join("runner-bindings.rs"))
|
|
|
|
.expect("Couldn't write bindings!");
|
2021-04-20 07:21:44 +10:00
|
|
|
}
|