mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 09:31:34 +11:00
build mgba
This commit is contained in:
parent
2bbb755138
commit
7ab17d7a4e
16
mgba-test-runner/build-mgba.sh
Normal file
16
mgba-test-runner/build-mgba.sh
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MGBA_VERSION=$1
|
||||||
|
OUT_DIRECTORY=$2
|
||||||
|
|
||||||
|
cd ${OUT_DIRECTORY}
|
||||||
|
curl -L https://github.com/mgba-emu/mgba/archive/refs/tags/${MGBA_VERSION}.tar.gz -o mgba-${MGBA_VERSION}.tar.gz
|
||||||
|
tar -xvf mgba-${MGBA_VERSION}.tar.gz
|
||||||
|
cd mgba-${MGBA_VERSION}
|
||||||
|
rm -rf build
|
||||||
|
mkdir -p build
|
||||||
|
cd build
|
||||||
|
cmake .. -DBUILD_STATIC=ON -DBUILD_SHARED=OFF -DDISABLE_FRONTENDS=ON -DBUILD_GL=OFF -DBUILD_GLES2=OFF -DUSE_DISCORD_RPC=OFF -DUSE_PNG=OFF
|
||||||
|
make
|
||||||
|
|
||||||
|
cp libmgba.a ../../libmgba-cycle.a
|
|
@ -1,25 +1,25 @@
|
||||||
use std::{
|
use std::{env, path::PathBuf};
|
||||||
env,
|
|
||||||
path::{self, PathBuf},
|
|
||||||
};
|
|
||||||
|
|
||||||
fn find_mgba_library() -> Option<&'static str> {
|
const MGBA_VERSION: &str = "0.9.1";
|
||||||
const POTENTIAL_LIBRARY_LOCATIONS: &[&str] =
|
|
||||||
&["/usr/lib/libmgba.so.0.9", "/usr/local/lib/libmgba.so.0.9"];
|
|
||||||
|
|
||||||
POTENTIAL_LIBRARY_LOCATIONS
|
|
||||||
.iter()
|
|
||||||
.find(|file_path| path::Path::new(file_path).exists())
|
|
||||||
.copied()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mgba_library = find_mgba_library().expect("Need mgba 0.9 installed");
|
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");
|
||||||
|
println!("cargo:rustc-link-search={}", out_path.to_str().unwrap());
|
||||||
|
println!("cargo:rustc-link-lib=static={}", "mgba-cycle");
|
||||||
|
println!("cargo:rustc-link-lib=z");
|
||||||
|
println!("cargo:rustc-link-lib=elf");
|
||||||
|
|
||||||
cc::Build::new()
|
cc::Build::new()
|
||||||
.file("c/test-runner.c")
|
.file("c/test-runner.c")
|
||||||
.object(mgba_library)
|
.include(&mgba_directory.join("include"))
|
||||||
.include("c/vendor")
|
.static_flag(true)
|
||||||
.compile("test-runner");
|
.compile("test-runner");
|
||||||
|
|
||||||
let bindings = bindgen::Builder::default()
|
let bindings = bindgen::Builder::default()
|
||||||
|
@ -27,8 +27,7 @@ fn main() {
|
||||||
.generate()
|
.generate()
|
||||||
.expect("Unable to generate bindings");
|
.expect("Unable to generate bindings");
|
||||||
|
|
||||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
||||||
bindings
|
bindings
|
||||||
.write_to_file(out_path.join("runner-bindings.rs"))
|
.write_to_file(&out_path.join("runner-bindings.rs"))
|
||||||
.expect("Couldn't write bindings!");
|
.expect("Couldn't write bindings!");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue