separate binaries
This commit is contained in:
parent
e456e24f06
commit
451c4f0fde
19 changed files with 108 additions and 74 deletions
68
Cargo.lock
generated
68
Cargo.lock
generated
|
@ -648,6 +648,16 @@ version = "0.6.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
|
||||
|
||||
[[package]]
|
||||
name = "cli"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"ctrlc",
|
||||
"frontend-common",
|
||||
"gb-emu-lib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.50"
|
||||
|
@ -1322,6 +1332,25 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "frontend-common"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"chrono",
|
||||
"cpal",
|
||||
"futures",
|
||||
"gb-emu-lib",
|
||||
"gilrs",
|
||||
"image",
|
||||
"nokhwa",
|
||||
"raw-window-handle 0.5.2",
|
||||
"send_wrapper",
|
||||
"serde",
|
||||
"winit",
|
||||
"winit_input_helper",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.29"
|
||||
|
@ -1420,31 +1449,6 @@ dependencies = [
|
|||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gb-emu"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cacao",
|
||||
"chrono",
|
||||
"clap",
|
||||
"cpal",
|
||||
"ctrlc",
|
||||
"futures",
|
||||
"gb-emu-lib",
|
||||
"gilrs",
|
||||
"image",
|
||||
"nokhwa",
|
||||
"objc2 0.3.0-beta.3",
|
||||
"raw-window-handle 0.5.2",
|
||||
"send_wrapper",
|
||||
"serde",
|
||||
"twinc_emu_vst",
|
||||
"uuid 1.6.1",
|
||||
"winit",
|
||||
"winit_input_helper",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gb-emu-lib"
|
||||
version = "0.5.0"
|
||||
|
@ -1624,6 +1628,20 @@ dependencies = [
|
|||
"bitflags 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gui"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cacao",
|
||||
"cpal",
|
||||
"frontend-common",
|
||||
"gb-emu-lib",
|
||||
"objc2 0.3.0-beta.3",
|
||||
"raw-window-handle 0.5.2",
|
||||
"twinc_emu_vst",
|
||||
"uuid 1.6.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
[workspace]
|
||||
members = ["lib", "gb-emu", "gb-vst", "gb-vst/xtask"]
|
||||
default-members = ["gb-emu"]
|
||||
members = ["lib", "frontend-common", "gb-vst", "gb-vst/xtask", "gui", "cli"]
|
||||
default-members = ["cli"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.dependencies]
|
||||
gb-emu-lib = { path = "./lib", features = ["config"] }
|
||||
frontend-common = { path = "./frontend-common" }
|
||||
baseview = { git = "https://github.com/italicsjenga/baseview" }
|
||||
nih_plug = { git = "https://github.com/italicsjenga/nih-plug", branch = "raw-window-handle-0.5.0" }
|
||||
nih_plug_xtask = { git = "https://github.com/italicsjenga/nih-plug", branch = "raw-window-handle-0.5.0" }
|
||||
|
|
13
cli/Cargo.toml
Normal file
13
cli/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "cli"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[package.metadata.bundle]
|
||||
identifier = "com.alexjanka.TWINC.cli"
|
||||
|
||||
[dependencies]
|
||||
frontend-common = { workspace = true }
|
||||
gb-emu-lib = { workspace = true }
|
||||
clap = { version = "4.4", features = ["derive"] }
|
||||
ctrlc = "3.4"
|
|
@ -3,7 +3,7 @@
|
|||
#[cfg(feature = "camera")]
|
||||
use camera::Webcam;
|
||||
use clap::{ArgGroup, Parser, Subcommand, ValueEnum};
|
||||
use gb_emu::{audio, debug::Debugger, window::winit_manager::WinitWindowManager};
|
||||
use frontend_common::{audio, debug::Debugger, window::winit_manager::WinitWindowManager};
|
||||
use gb_emu_lib::{
|
||||
config::ConfigManager,
|
||||
connect::{EmulatorCoreTrait, EmulatorMessage, SerialTarget, SramType, StdoutType},
|
||||
|
@ -15,11 +15,6 @@ use std::{
|
|||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
#[cfg(all(feature = "vulkan", feature = "pixels"))]
|
||||
compile_error!("select only one rendering backend!");
|
||||
#[cfg(all(not(feature = "vulkan"), not(feature = "pixels")))]
|
||||
compile_error!("select one rendering backend!");
|
||||
|
||||
#[derive(Subcommand, Debug, Clone, Copy)]
|
||||
enum Commands {
|
||||
PrintConfig {
|
||||
|
@ -104,7 +99,7 @@ struct Args {
|
|||
record: bool,
|
||||
}
|
||||
|
||||
impl From<Args> for gb_emu::RunOptions {
|
||||
impl From<Args> for frontend_common::RunOptions {
|
||||
fn from(value: Args) -> Self {
|
||||
Self {
|
||||
rom: value
|
||||
|
@ -143,7 +138,7 @@ fn main() {
|
|||
)
|
||||
.ok(),
|
||||
ConfigType::Standalone => config_manager
|
||||
.load_custom_config::<gb_emu::StandaloneConfig>()
|
||||
.load_custom_config::<frontend_common::StandaloneConfig>()
|
||||
.and_then(|v| ConfigManager::get_custom_config_string(v).ok()),
|
||||
}
|
||||
} else {
|
||||
|
@ -153,7 +148,7 @@ fn main() {
|
|||
)
|
||||
.ok(),
|
||||
ConfigType::Standalone => ConfigManager::get_custom_config_string(
|
||||
gb_emu::StandaloneConfig::default(),
|
||||
frontend_common::StandaloneConfig::default(),
|
||||
)
|
||||
.ok(),
|
||||
}
|
||||
|
@ -175,10 +170,10 @@ fn main() {
|
|||
.unwrap();
|
||||
}
|
||||
let (record, mute, debug) = (args.record, args.mute, args.debug);
|
||||
let prepared = gb_emu::prepare(args.into(), receiver);
|
||||
let prepared = frontend_common::prepare(args.into(), receiver);
|
||||
let (output, stream) = audio::create_output(mute);
|
||||
let mut window_manager = WinitWindowManager::new(sender, stream, record);
|
||||
let mut core = gb_emu::run(prepared, &mut window_manager, output);
|
||||
let mut core = frontend_common::run(prepared, &mut window_manager, output);
|
||||
if debug {
|
||||
let mut debugger = Debugger::new(Box::new(core));
|
||||
let mut since = Instant::now();
|
|
@ -1,15 +1,11 @@
|
|||
[package]
|
||||
name = "gb-emu"
|
||||
name = "frontend-common"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
description = "TWINC Game Boy (CGB/DMG) emulator"
|
||||
description = "Frontend common library for TWINC Game Boy (CGB/DMG) emulator"
|
||||
|
||||
[package.metadata.bundle]
|
||||
identifier = "com.alexjanka.TWINC"
|
||||
[package.metadata.bundle.bin.cli]
|
||||
identifier = "com.alexjanka.TWINC.cli"
|
||||
[package.metadata.bundle.bin.gui]
|
||||
identifier = "com.alexjanka.TWINC.gui"
|
||||
|
||||
[features]
|
||||
default = ["vulkan-static"]
|
||||
|
@ -25,11 +21,9 @@ force-crossplatform-ui = []
|
|||
|
||||
[dependencies]
|
||||
gb-emu-lib = { workspace = true }
|
||||
clap = { version = "4.4", features = ["derive"] }
|
||||
gilrs = "0.10"
|
||||
cpal = "0.15"
|
||||
futures = "0.3"
|
||||
ctrlc = "3.4"
|
||||
nokhwa = { version = "0.10", features = [
|
||||
"input-avfoundation",
|
||||
], optional = true }
|
||||
|
@ -41,9 +35,3 @@ serde = { version = "1.0", features = ["derive"] }
|
|||
image = { version = "0.24", default-features = false, features = ["png"] }
|
||||
bytemuck = "1.14"
|
||||
chrono = "0.4"
|
||||
twinc_emu_vst = { path = "../gb-vst", default-features = false }
|
||||
uuid = { version = "1.6", features = ["v4", "fast-rng"] }
|
||||
|
||||
[target.'cfg(any(target_os = "macos"))'.dependencies]
|
||||
cacao = { git = "https://github.com/italicsjenga/cacao" }
|
||||
objc = { version = "=0.3.0-beta.3", package = "objc2" }
|
|
@ -133,12 +133,13 @@ pub fn prepare(
|
|||
|
||||
let will_be_cgb = rom.rom_type == CgbRomType::CgbOnly || config.prefer_cgb;
|
||||
|
||||
let shader_path = if will_be_cgb {
|
||||
config.vulkan_config.cgb_shader_path.as_ref()
|
||||
} else {
|
||||
config.vulkan_config.dmg_shader_path.as_ref()
|
||||
}
|
||||
.map(|v| config_manager.dir().join(v));
|
||||
let shader_path =
|
||||
if will_be_cgb {
|
||||
config.vulkan_config.cgb_shader_path.as_ref()
|
||||
} else {
|
||||
config.vulkan_config.dmg_shader_path.as_ref()
|
||||
}
|
||||
.map(|v| config_manager.dir().join(v));
|
||||
|
||||
let resizable = shader_path.is_some()
|
||||
&& if will_be_cgb {
|
||||
|
@ -180,11 +181,12 @@ where
|
|||
{
|
||||
let configs = access_config();
|
||||
|
||||
let window = window_manager.add_main(
|
||||
prepared.scale_override,
|
||||
prepared.shader_path,
|
||||
prepared.resizable,
|
||||
);
|
||||
let window =
|
||||
window_manager.add_main(
|
||||
prepared.scale_override,
|
||||
prepared.shader_path,
|
||||
prepared.resizable,
|
||||
);
|
||||
|
||||
let tile_window = if prepared.tile_window {
|
||||
Some(window_manager.add(configs.standalone_config.scale_factor, None, false))
|
19
gui/Cargo.toml
Normal file
19
gui/Cargo.toml
Normal file
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "gui"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[package.metadata.bundle]
|
||||
identifier = "com.alexjanka.TWINC.gui"
|
||||
|
||||
[dependencies]
|
||||
frontend-common = { workspace = true }
|
||||
gb-emu-lib = { workspace = true }
|
||||
twinc_emu_vst = { path = "../gb-vst", default-features = false }
|
||||
|
||||
[target.'cfg(any(target_os = "macos"))'.dependencies]
|
||||
cacao = { git = "https://github.com/italicsjenga/cacao" }
|
||||
objc = { version = "=0.3.0-beta.3", package = "objc2" }
|
||||
uuid = { version = "1.6", features = ["v4", "fast-rng"] }
|
||||
raw-window-handle = { version = "0.5" }
|
||||
cpal = "0.15"
|
|
@ -13,7 +13,7 @@ use cacao::{
|
|||
core_foundation::base::TCFTypeRef,
|
||||
};
|
||||
use cpal::Stream;
|
||||
use gb_emu::window::{RendererChannel, WindowManager};
|
||||
use frontend_common::window::{RendererChannel, WindowManager};
|
||||
use gb_emu_lib::{
|
||||
connect::{EmulatorMessage, RendererMessage, ResolutionData},
|
||||
renderer::{RendererBackend, RendererBackendManager, WindowOptions},
|
||||
|
@ -279,12 +279,9 @@ impl WindowDelegate for CacaoWindow {
|
|||
const NAME: &'static str = "EmulatorWindow";
|
||||
|
||||
fn did_load(&mut self, window: Window) {
|
||||
#[cfg(feature = "vulkan")]
|
||||
let options = WindowOptions {
|
||||
shader_path: self.shader_path.clone(),
|
||||
};
|
||||
#[cfg(feature = "pixels")]
|
||||
let options = WindowOptions {};
|
||||
|
||||
self.backend = Some(RendererBackend::new(
|
||||
self.resolutions,
|
|
@ -7,7 +7,7 @@ use cacao::appkit::window::{Window, WindowConfig, WindowStyle, WindowToolbarStyl
|
|||
use cacao::appkit::{App, AppDelegate};
|
||||
use cacao::filesystem::FileSelectPanel;
|
||||
use cacao::notification_center::Dispatcher;
|
||||
use gb_emu::audio;
|
||||
use frontend_common::audio;
|
||||
use gb_emu_lib::connect::{EmulatorCoreTrait, EmulatorMessage};
|
||||
use raw_window_handle::{AppKitDisplayHandle, RawDisplayHandle};
|
||||
use uuid::Uuid;
|
||||
|
@ -73,9 +73,9 @@ impl Default for TwincUiApp {
|
|||
},
|
||||
PreferencesUi::new(),
|
||||
)),
|
||||
current_game: RwLock::new(CacaoWindowManager::new(RawDisplayHandle::AppKit(
|
||||
AppKitDisplayHandle::empty(),
|
||||
))),
|
||||
current_game: RwLock::new(
|
||||
CacaoWindowManager::new(RawDisplayHandle::AppKit(AppKitDisplayHandle::empty()))
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,11 +99,12 @@ impl Dispatcher for TwincUiApp {
|
|||
AppMessage::Core(CoreMessage::OpenRom(path)) => {
|
||||
let (sender, receiver) = channel::<EmulatorMessage>();
|
||||
sender.send(EmulatorMessage::Start).unwrap();
|
||||
let prepared = gb_emu::prepare(gb_emu::RunOptions::new(path), receiver);
|
||||
let prepared =
|
||||
frontend_common::prepare(frontend_common::RunOptions::new(path), receiver);
|
||||
let (output, stream) = audio::create_output(false);
|
||||
let mut window_manager = self.current_game.write().unwrap();
|
||||
window_manager.update_handles(sender, stream);
|
||||
let mut core = gb_emu::run(prepared, &mut *window_manager, output);
|
||||
let mut core = frontend_common::run(prepared, &mut *window_manager, output);
|
||||
let handle = std::thread::Builder::new()
|
||||
.name(String::from("EmuCore"))
|
||||
.spawn(move || loop {
|
|
@ -4,7 +4,7 @@ use cacao::{
|
|||
layout::Layout,
|
||||
view::{View, ViewDelegate},
|
||||
};
|
||||
use gb_emu::StandaloneConfig;
|
||||
use frontend_common::StandaloneConfig;
|
||||
use gb_emu_lib::config::{Config, ConfigManager, ResolutionOverride};
|
||||
|
||||
use crate::macos::dispatch;
|
Loading…
Add table
Reference in a new issue