2021-07-04 02:33:15 +10:00
|
|
|
use std::{env, path::PathBuf};
|
2021-04-20 07:21:44 +10:00
|
|
|
|
2021-07-04 02:33:15 +10:00
|
|
|
const MGBA_VERSION: &str = "0.9.1";
|
2021-04-20 07:21:44 +10:00
|
|
|
|
|
|
|
fn main() {
|
2021-07-04 02:33:15 +10:00
|
|
|
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
|
|
let mgba_directory = out_path.join(format!("mgba-{}", MGBA_VERSION));
|
|
|
|
std::process::Command::new("bash")
|
|
|
|
.arg("build-mgba.sh")
|
|
|
|
.arg(MGBA_VERSION)
|
|
|
|
.arg(&out_path)
|
|
|
|
.output()
|
|
|
|
.expect("should be able to build mgba");
|
2021-07-04 03:22:49 +10:00
|
|
|
println!("cargo:rustc-link-search={}", out_path.to_str().unwrap());
|
2021-07-04 02:33:15 +10:00
|
|
|
println!("cargo:rustc-link-lib=static={}", "mgba-cycle");
|
|
|
|
println!("cargo:rustc-link-lib=elf");
|
2021-04-20 07:21:44 +10:00
|
|
|
|
|
|
|
cc::Build::new()
|
|
|
|
.file("c/test-runner.c")
|
2021-07-04 02:33:15 +10:00
|
|
|
.include(&mgba_directory.join("include"))
|
|
|
|
.static_flag(true)
|
2021-04-20 07:21:44 +10:00
|
|
|
.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");
|
|
|
|
|
|
|
|
bindings
|
2021-07-04 02:33:15 +10:00
|
|
|
.write_to_file(&out_path.join("runner-bindings.rs"))
|
2021-05-23 14:06:35 +10:00
|
|
|
.expect("Couldn't write bindings!");
|
2021-04-20 07:21:44 +10:00
|
|
|
}
|