support static libretro

This commit is contained in:
lifning 2021-11-11 16:08:50 -08:00
parent 76cab25acb
commit 1ea5a2a69b
4 changed files with 13 additions and 5 deletions

View File

@ -20,3 +20,6 @@ itertools = "0.10"
rand = "0.8"
rand_xoshiro = "0.6"
regex = "1.5"
[features]
static = ["ferretro_components/static"]

1
lib/README.txt Normal file
View File

@ -0,0 +1 @@
put "libretro.a" here if you wish to compile with the "static" feature.

BIN
lib/libretro.a Normal file

Binary file not shown.

View File

@ -37,11 +37,11 @@ mod gui;
#[derive(StructOpt)]
struct Opt {
/// Core module to use.
/// Core module to use. If not provided, falls back to statically-linked core.
#[structopt(short, long, parse(from_os_str))]
core: PathBuf,
core: Option<PathBuf>,
/// ROM to load using the core.
#[structopt(short, long, parse(from_os_str))]
#[structopt(parse(from_os_str))]
rom: PathBuf,
/// System directory, often containing BIOS files
#[structopt(short, long, parse(from_os_str))]
@ -65,7 +65,11 @@ struct Zretro {
impl Zretro {
fn new(opt: Opt) -> Result<Self> {
let mut emu = RetroComponentBase::new(&opt.core);
let mut emu = match &opt.core {
Some(core_path) => RetroComponentBase::new(core_path),
None if cfg!(feature = "static") => RetroComponentBase::new_static(),
_ => panic!("--core is required when frontend is not built with the 'static' feature."),
};
let sys_info = emu.libretro_core().get_system_info();
let title = format!(
@ -83,7 +87,7 @@ impl Zretro {
emu.register_component(PathBufComponent {
sys_path: opt.system.clone(),
libretro_path: Some(opt.core.to_path_buf()),
libretro_path: opt.core.clone(),
core_assets_path: None,
save_path: Some(std::env::temp_dir()),
})?;