Compare commits

...

4 commits

Author SHA1 Message Date
Alex Janka 7ab8bcf308 xtask: build/run 2024-08-11 12:24:33 +10:00
Alex Janka 138e77bb4c cli/gui: expose renderer as feature 2024-08-11 12:21:16 +10:00
Alex Janka 1efe321c05 xtask: move to workspace root 2024-08-10 16:03:18 +10:00
Alex Janka 8ab1581899 dep update 2024-08-10 16:02:18 +10:00
13 changed files with 547 additions and 74 deletions

View file

@ -1,8 +1,7 @@
[alias] [alias]
xtask = "run --package xtask --release --" xtask = "run --package xtask --"
[profile.dev] [profile.dev]
opt-level = 1
lto = false lto = false
[profile.release] [profile.release]

115
Cargo.lock generated
View file

@ -159,9 +159,9 @@ dependencies = [
[[package]] [[package]]
name = "anstyle" name = "anstyle"
version = "1.0.7" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
[[package]] [[package]]
name = "anstyle-parse" name = "anstyle-parse"
@ -203,8 +203,7 @@ dependencies = [
[[package]] [[package]]
name = "anymap" name = "anymap"
version = "1.0.0-beta.2" version = "1.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://git.alexjanka.com/alex/anymap#c70cb7def9064810d7ca2a006a2cc7a2419e11bd"
checksum = "8f1f8f5a6f3d50d89e3797d7593a50f96bb2aaa20ca0cc7be1fb673232c91d72"
[[package]] [[package]]
name = "arbitrary" name = "arbitrary"
@ -565,9 +564,9 @@ checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.16.1" version = "1.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83"
dependencies = [ dependencies = [
"bytemuck_derive", "bytemuck_derive",
] ]
@ -793,9 +792,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.5.9" version = "4.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -808,9 +807,9 @@ source = "git+https://github.com/robbert-vdh/clap-sys.git?branch=feature/cstr-ma
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.5.9" version = "4.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -821,9 +820,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "4.5.8" version = "4.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
@ -1475,9 +1474,9 @@ dependencies = [
[[package]] [[package]]
name = "env_logger" name = "env_logger"
version = "0.11.3" version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -1643,7 +1642,7 @@ dependencies = [
"futures", "futures",
"gb-emu-lib", "gb-emu-lib",
"gilrs", "gilrs",
"image 0.25.1", "image 0.25.2",
"log", "log",
"nokhwa", "nokhwa",
"raw-window-handle 0.6.2", "raw-window-handle 0.6.2",
@ -1874,9 +1873,9 @@ dependencies = [
[[package]] [[package]]
name = "gilrs" name = "gilrs"
version = "0.10.8" version = "0.10.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f226b8f4d9bc7da93de8efd8747c6b1086409ca3f4b6d51e9a7f5461a9183fe" checksum = "dfb8c78963a8856a5b10015c9349176ff5edbc8095384d52aada467a848bc03a"
dependencies = [ dependencies = [
"fnv", "fnv",
"gilrs-core", "gilrs-core",
@ -2424,12 +2423,12 @@ dependencies = [
[[package]] [[package]]
name = "image" name = "image"
version = "0.25.1" version = "0.25.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd54d660e773627692c524beaad361aca785a4f9f5730ce91f42aabe5bce3d11" checksum = "99314c8a2152b8ddb211f924cdae532d8c5e4c8bb54728e12fff1b0cd5963a10"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"byteorder", "byteorder-lite",
"color_quant", "color_quant",
"exr", "exr",
"gif", "gif",
@ -2738,7 +2737,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
"windows-targets 0.48.5", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@ -2844,7 +2843,7 @@ source = "git+https://git.alexjanka.com/alex/librashader#be4c634614454d1432c602c
dependencies = [ dependencies = [
"array-concat", "array-concat",
"bytemuck", "bytemuck",
"image 0.25.1", "image 0.25.2",
"librashader-common", "librashader-common",
"librashader-preprocess", "librashader-preprocess",
"librashader-presets", "librashader-presets",
@ -2880,7 +2879,7 @@ source = "git+https://git.alexjanka.com/alex/librashader#be4c634614454d1432c602c
dependencies = [ dependencies = [
"array-concat", "array-concat",
"bytemuck", "bytemuck",
"image 0.25.1", "image 0.25.2",
"librashader-cache", "librashader-cache",
"librashader-common", "librashader-common",
"librashader-preprocess", "librashader-preprocess",
@ -3139,9 +3138,9 @@ dependencies = [
[[package]] [[package]]
name = "naga" name = "naga"
version = "22.0.0" version = "22.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09eeccb9b50f4f7839b214aa3e08be467159506a986c18e0702170ccf720a453" checksum = "8bd5a652b6faf21496f2cfd88fc49989c8db0825d1f6746b1a71a6ede24a63ad"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bit-set", "bit-set",
@ -3228,7 +3227,7 @@ dependencies = [
[[package]] [[package]]
name = "nih_plug" name = "nih_plug"
version = "0.0.0" version = "0.0.0"
source = "git+https://git.alexjanka.com/alex/nih-plug#0e54080a1d29ae057c1f74590eff7972ec3986d2" source = "git+https://git.alexjanka.com/alex/nih-plug#a03f406bd502239a6c32a9ec4779649d443da780"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"anymap", "anymap",
@ -3265,7 +3264,7 @@ dependencies = [
[[package]] [[package]]
name = "nih_plug_derive" name = "nih_plug_derive"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.alexjanka.com/alex/nih-plug#0e54080a1d29ae057c1f74590eff7972ec3986d2" source = "git+https://git.alexjanka.com/alex/nih-plug#a03f406bd502239a6c32a9ec4779649d443da780"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -3275,7 +3274,7 @@ dependencies = [
[[package]] [[package]]
name = "nih_plug_xtask" name = "nih_plug_xtask"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.alexjanka.com/alex/nih-plug#0e54080a1d29ae057c1f74590eff7972ec3986d2" source = "git+https://git.alexjanka.com/alex/nih-plug#a03f406bd502239a6c32a9ec4779649d443da780"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cargo_metadata", "cargo_metadata",
@ -4325,18 +4324,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.204" version = "1.0.205"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.204" version = "1.0.205"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -4345,11 +4344,12 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.120" version = "1.0.122"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da"
dependencies = [ dependencies = [
"itoa", "itoa",
"memchr",
"ryu", "ryu",
"serde", "serde",
] ]
@ -4508,6 +4508,28 @@ version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "strum"
version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
dependencies = [
"heck",
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.71",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.109" version = "1.0.109"
@ -5191,9 +5213,9 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
[[package]] [[package]]
name = "wgpu" name = "wgpu"
version = "22.0.0" version = "22.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c87e07e87a179614940ad845397e03201847453a37b43a31a3b54eee2e6e32ce" checksum = "e1d1c4ba43f80542cf63a0a6ed3134629ae73e8ab51e4b765a67f3aa062eb433"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"cfg_aliases 0.1.1", "cfg_aliases 0.1.1",
@ -5833,11 +5855,32 @@ version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193"
[[package]]
name = "xshell"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db0ab86eae739efd1b054a8d3d16041914030ac4e01cd1dca0cf252fd8b6437"
dependencies = [
"xshell-macros",
]
[[package]]
name = "xshell-macros"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d422e8e38ec76e2f06ee439ccc765e9c6a9638b9e7c9f2e8255e4d41e8bd852"
[[package]] [[package]]
name = "xtask" name = "xtask"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cargo_metadata",
"clap",
"env_logger",
"log",
"nih_plug_xtask", "nih_plug_xtask",
"strum",
"xshell",
] ]
[[package]] [[package]]

View file

@ -1,13 +1,13 @@
[workspace] [workspace]
members = ["lib", "frontend-common", "gb-vst", "gb-vst/xtask", "gui", "cli"] members = ["lib", "frontend-common", "gb-vst", "xtask", "gui", "cli"]
default-members = ["cli"] default-members = ["cli"]
resolver = "2" resolver = "2"
[workspace.dependencies] [workspace.dependencies]
log = "0.4.20" log = "0.4.22"
env_logger = "0.11.1" env_logger = "0.11.5"
thiserror = "1.0" thiserror = "1.0.63"
raw-window-handle = "0.6" raw-window-handle = "0.6.2"
gb-emu-lib = { path = "./lib", features = ["config"] } gb-emu-lib = { path = "./lib", features = ["config"] }
frontend-common = { path = "./frontend-common" } frontend-common = { path = "./frontend-common" }
baseview = { git = "https://git.alexjanka.com/alex/baseview", default-features = false } baseview = { git = "https://git.alexjanka.com/alex/baseview", default-features = false }
@ -26,3 +26,6 @@ ash-window = "0.13.0"
[patch."https://github.com/RustAudio/baseview.git"] [patch."https://github.com/RustAudio/baseview.git"]
baseview = { git = "https://git.alexjanka.com/alex/baseview" } baseview = { git = "https://git.alexjanka.com/alex/baseview" }
[patch.crates-io]
anymap = { git = "https://git.alexjanka.com/alex/anymap" }

View file

@ -7,11 +7,17 @@ description = "TWINC Game Boy (CGB/DMG) emulator CLI"
[package.metadata.bundle] [package.metadata.bundle]
identifier = "com.alexjanka.TWINC.cli" identifier = "com.alexjanka.TWINC.cli"
[features]
default = ["wgpu"]
wgpu = ["frontend-common/wgpu"]
pixels = ["frontend-common/pixels"]
vulkan = ["frontend-common/vulkan"]
[dependencies] [dependencies]
frontend-common = { workspace = true } frontend-common = { workspace = true }
gb-emu-lib = { workspace = true } gb-emu-lib = { workspace = true }
clap = { version = "4.4", features = ["derive"] } clap = { version = "4.5.15", features = ["derive"] }
ctrlc = "3.4" ctrlc = "3.4.4"
log = { workspace = true } log = { workspace = true }
env_logger = { workspace = true } env_logger = { workspace = true }
anyhow = { version = "1.0.86", features = ["backtrace"] } anyhow = { version = "1.0.86", features = ["backtrace"] }

View file

@ -5,7 +5,7 @@ edition = "2021"
description = "Frontend common library for TWINC Game Boy (CGB/DMG) emulator" description = "Frontend common library for TWINC Game Boy (CGB/DMG) emulator"
[features] [features]
default = ["wgpu"] default = []
pixels = ["gb-emu-lib/pixels-renderer"] pixels = ["gb-emu-lib/pixels-renderer"]
vulkan = ["gb-emu-lib/vulkan-renderer", "gb-emu-lib/vulkan-debug"] vulkan = ["gb-emu-lib/vulkan-renderer", "gb-emu-lib/vulkan-debug"]
vulkan-static = ["vulkan", "gb-emu-lib/vulkan-static"] vulkan-static = ["vulkan", "gb-emu-lib/vulkan-static"]
@ -14,19 +14,19 @@ wgpu = ["gb-emu-lib/wgpu-renderer"]
[dependencies] [dependencies]
gb-emu-lib = { workspace = true } gb-emu-lib = { workspace = true }
gilrs = "0.10" gilrs = "0.10.9"
cpal = { version = "0.15", features = ["jack"] } cpal = { version = "0.15.3", features = ["jack"] }
futures = "0.3" futures = "0.3.30"
nokhwa = { version = "0.10", features = [ nokhwa = { version = "0.10.4", features = [
"input-avfoundation", "input-avfoundation",
], optional = true } ], optional = true }
send_wrapper = { version = "0.6.0", optional = true } send_wrapper = { version = "0.6.0", optional = true }
winit = { version = "0.29.15", features = ["rwh_05"] } winit = { version = "0.29.15", features = ["rwh_05"] }
winit_input_helper = "0.16" winit_input_helper = "0.16.0"
raw-window-handle = { workspace = true } raw-window-handle = { workspace = true }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0.205", features = ["derive"] }
image = { version = "0.25.1", default-features = false, features = ["png"] } image = { version = "0.25.2", default-features = false, features = ["png"] }
bytemuck = "1.14" bytemuck = "1.16.3"
chrono = "0.4" chrono = "0.4.38"
log = { workspace = true } log = { workspace = true }
anyhow = "1.0.86" anyhow = "1.0.86"

View file

@ -28,7 +28,7 @@ nih_plug = { workspace = true, features = [
], optional = true } ], optional = true }
baseview = { workspace = true, optional = true } baseview = { workspace = true, optional = true }
async-ringbuf = { version = "0.2.1", optional = true } async-ringbuf = { version = "0.2.1", optional = true }
futures = { version = "0.3", optional = true } futures = { version = "0.3.30", optional = true }
keyboard-types = { version = "0.6.2", optional = true } keyboard-types = { version = "0.6.2", optional = true }
raw-window-handle = { workspace = true } raw-window-handle = { workspace = true }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0.205", features = ["derive"] }

View file

@ -1,3 +0,0 @@
fn main() -> nih_plug_xtask::Result<()> {
nih_plug_xtask::main()
}

View file

@ -9,10 +9,13 @@ identifier = "com.alexjanka.TWINC.gui"
osx_file_extensions = [[["Game Boy ROM", "Viewer"], ["gb", "gbc"]]] osx_file_extensions = [[["Game Boy ROM", "Viewer"], ["gb", "gbc"]]]
[features] [features]
default = ["macos-ui", "crossplatform-ui"] default = ["wgpu", "macos-ui", "crossplatform-ui"]
macos-ui = ["cacao", "objc", "uuid"] macos-ui = ["cacao", "objc", "uuid"]
crossplatform-ui = ["gtk", "adw", "glib-build-tools"] crossplatform-ui = ["gtk", "adw", "glib-build-tools"]
force-crossplatform-ui = ["crossplatform-ui"] force-crossplatform-ui = ["crossplatform-ui"]
wgpu = ["frontend-common/wgpu"]
pixels = ["frontend-common/pixels"]
vulkan = ["frontend-common/vulkan"]
[dependencies] [dependencies]
adw = { version = "0.7.0", package = "libadwaita", features = [ adw = { version = "0.7.0", package = "libadwaita", features = [
@ -26,18 +29,17 @@ gtk = { version = "0.9.0", package = "gtk4", features = [
], optional = true } ], optional = true }
twinc_emu_vst = { path = "../gb-vst", default-features = false } twinc_emu_vst = { path = "../gb-vst", default-features = false }
raw-window-handle = { workspace = true } raw-window-handle = { workspace = true }
cpal = "0.15" cpal = "0.15.3"
log = { workspace = true } log = { workspace = true }
env_logger = { workspace = true } env_logger = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0.205", features = ["derive"] }
anyhow = "1.0.86" anyhow = "1.0.86"
[target.'cfg(any(target_os = "macos"))'.dependencies] [target.'cfg(any(target_os = "macos"))'.dependencies]
cacao = { git = "https://git.alexjanka.com/alex/cacao", optional = true } cacao = { git = "https://git.alexjanka.com/alex/cacao", optional = true }
objc = { version = "=0.3.0-beta.3", package = "objc2", optional = true } objc = { version = "=0.3.0-beta.3", package = "objc2", optional = true }
uuid = { version = "1.6", features = ["v4", "fast-rng"], optional = true } uuid = { version = "1.10.0", features = ["v4", "fast-rng"], optional = true }
[build-dependencies] [build-dependencies]
glib-build-tools = { version = "0.20.0", optional = true } glib-build-tools = { version = "0.20.0", optional = true }

View file

@ -37,10 +37,10 @@ rand = "0.8.5"
async-ringbuf = "0.2.1" async-ringbuf = "0.2.1"
futures = "0.3.30" futures = "0.3.30"
itertools = "0.13.0" itertools = "0.13.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0.205", features = ["derive"] }
serde_with = "3.0" serde_with = "3.9.0"
bytemuck = "1.14" bytemuck = "1.16.3"
num-traits = "0.2" num-traits = "0.2.19"
pixels = { git = "https://git.alexjanka.com/alex/pixels", optional = true } pixels = { git = "https://git.alexjanka.com/alex/pixels", optional = true }
ash = { workspace = true, features = ["linked"], optional = true } ash = { workspace = true, features = ["linked"], optional = true }
ash-window = { workspace = true, optional = true } ash-window = { workspace = true, optional = true }
@ -48,16 +48,16 @@ raw-window-handle = { workspace = true }
librashader = { workspace = true, optional = true } librashader = { workspace = true, optional = true }
librashader-presets = { workspace = true, optional = true } librashader-presets = { workspace = true, optional = true }
librashader-common = { workspace = true, optional = true } librashader-common = { workspace = true, optional = true }
directories = { version = "5.0", optional = true } directories = { version = "5.0.1", optional = true }
ron = { version = "0.8", optional = true } ron = { version = "0.8.1", optional = true }
lazy_static = "1.4" lazy_static = "1.5.0"
wgpu = { version = "22.0.0", optional = true } wgpu = { version = "22.1.0", optional = true }
thiserror = { workspace = true } thiserror = { workspace = true }
log = { workspace = true } log = { workspace = true }
anyhow = "1.0.86" anyhow = "1.0.86"
[build-dependencies] [build-dependencies]
naga = { version = "22.0.0", optional = true, features = [ naga = { version = "22.1.0", optional = true, features = [
"wgsl-in", "wgsl-in",
"spv-out", "spv-out",
] } ] }

View file

@ -6,4 +6,10 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
clap = { version = "4.5.15", features = ["derive"] }
strum = { version = "0.26.3", features = ["derive"] }
xshell = "0.2.6"
cargo_metadata = "0.18.1"
nih_plug_xtask = { workspace = true } nih_plug_xtask = { workspace = true }
log = { workspace = true }
env_logger = { workspace = true }

57
xtask/src/args.rs Normal file
View file

@ -0,0 +1,57 @@
use clap::Parser;
use crate::types::*;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
#[command(subcommand)]
pub command: Commands,
#[arg(long)]
/// Defaults to CARGO_WORKSPACE_DIR/build, unless XTASK_TARGET_DIR is set.
pub target_dir: Option<std::path::PathBuf>,
#[arg(long)]
/// Build in debug mode instead of release mode
pub debug: bool,
}
#[derive(clap::Subcommand, Debug)]
pub enum Commands {
#[command(allow_external_subcommands = true)]
Bundle,
#[command(allow_external_subcommands = true)]
BundleUniversal,
Build(BuildArgs),
#[command(allow_external_subcommands = true)]
Run(RunArgs),
}
#[derive(clap::Args, Debug)]
#[command(group(clap::ArgGroup::new("platforms").args(["platform","all_platforms"]).required(true)))]
#[command(group(clap::ArgGroup::new("binaries").args(["binary","all_binaries"]).required(true)))]
pub struct BuildArgs {
#[arg(long, short)]
pub platform: Vec<Platform>,
#[arg(long)]
pub all_platforms: bool,
#[arg(long, short)]
pub binary: Vec<Binary>,
#[arg(long)]
pub all_binaries: bool,
#[arg(long, short)]
pub renderer: Vec<Renderer>,
}
#[derive(clap::Args, Debug)]
pub struct RunArgs {
#[arg(long, short)]
pub platform: Option<Platform>,
#[arg(long, short)]
pub binary: Option<Binary>,
#[arg(long, short)]
pub renderer: Option<Renderer>,
}

264
xtask/src/main.rs Normal file
View file

@ -0,0 +1,264 @@
use clap::Parser;
use strum::IntoEnumIterator;
use xshell::Shell;
use args::*;
use types::*;
mod args;
mod types;
static METADATA: std::sync::OnceLock<cargo_metadata::Metadata> = std::sync::OnceLock::new();
static OUTPUT_DIR: std::sync::OnceLock<std::path::PathBuf> = std::sync::OnceLock::new();
fn executable_dir(binary: Binary, platform: Platform, renderer: Renderer) -> String {
format!(
"{}_{}_{}",
binary.name(),
platform.as_target(),
renderer.as_feature()
)
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "info");
}
env_logger::init();
let args = Args::parse();
let metadata = cargo_metadata::MetadataCommand::new().exec()?;
let target_dir = args
.target_dir
.or(std::env::var("XTASK_TARGET_DIR")
.ok()
.map(std::path::PathBuf::from))
.unwrap_or_else(|| std::path::PathBuf::from(&metadata.target_directory).join("xbuild"));
OUTPUT_DIR.set(target_dir).map_err(|_| CouldntSetOnceLock)?;
METADATA.set(metadata).map_err(|_| CouldntSetOnceLock)?;
match args.command {
Commands::Bundle | Commands::BundleUniversal => {
let args = std::env::args().skip(1).collect::<Vec<_>>();
nih_plug_xtask::main_with_args("cargo xtask", args.into_iter())?;
Ok(())
}
Commands::Build(build_args) => build(build_args, args.debug),
Commands::Run(run_args) => run(run_args, args.debug),
}
}
fn build(args: BuildArgs, debug: bool) -> Result<(), Box<dyn std::error::Error>> {
let platforms = if args.all_platforms {
Platform::iter().collect()
} else {
args.platform
};
log::info!("platforms: {platforms:?}");
let binaries = if args.all_binaries {
Binary::iter().collect()
} else {
args.binary
};
log::info!("binaries: {binaries:?}");
let renderers = if args.renderer.is_empty() {
vec![Renderer::Wgpu]
} else {
args.renderer
};
log::info!("renderers: {renderers:?}");
for binary in binaries {
for platform in &platforms {
for renderer in &renderers {
build_binary(binary, *platform, *renderer, debug)?;
}
}
}
Ok(())
}
fn run(args: RunArgs, debug: bool) -> Result<(), Box<dyn std::error::Error>> {
let platform = args.platform.unwrap_or(Platform::host_platform());
let binary = args.binary.unwrap_or(Binary::get_default());
let renderer = args.renderer.unwrap_or(Renderer::Wgpu);
match binary {
Binary::Gui => run_gui(platform, renderer, debug),
Binary::Cli => run_cli(platform, renderer, debug),
Binary::Vst => {
eprintln!("twinc_emu_vst doesn't support standalone usage!");
std::process::exit(1);
}
}
}
fn build_binary(
binary: Binary,
platform: Platform,
renderer: Renderer,
debug: bool,
) -> Result<(), Box<dyn std::error::Error>> {
let output_dir = OUTPUT_DIR
.get()
.unwrap()
.join(executable_dir(binary, platform, renderer));
std::fs::create_dir_all(&output_dir)?;
match binary {
Binary::Gui => build_gui(output_dir, platform, renderer, debug),
Binary::Cli => build_cli(output_dir, platform, renderer, debug),
Binary::Vst => build_vst(platform, renderer, debug),
}
}
fn build_gui(
output_dir: std::path::PathBuf,
platform: Platform,
renderer: Renderer,
debug: bool,
) -> Result<(), Box<dyn std::error::Error>> {
let ui = platform.ui();
run_build(
"gui",
platform,
renderer,
debug,
Some(["-F", ui].into_iter().map(String::from).collect()),
output_dir,
)
}
fn run_gui(
platform: Platform,
renderer: Renderer,
debug: bool,
) -> Result<(), Box<dyn std::error::Error>> {
let ui = platform.ui();
let _ = cargo_exec(
"run",
"gui",
platform,
renderer,
debug,
Some(["-F", ui].into_iter().map(String::from).collect()),
)?;
Ok(())
}
fn build_cli(
output_dir: std::path::PathBuf,
platform: Platform,
renderer: Renderer,
debug: bool,
) -> Result<(), Box<dyn std::error::Error>> {
run_build("cli", platform, renderer, debug, None, output_dir)
}
fn run_cli(
platform: Platform,
renderer: Renderer,
debug: bool,
) -> Result<(), Box<dyn std::error::Error>> {
let args = std::env::args().skip(1).collect::<Vec<_>>();
let additional_flags = args
.iter()
.position(|arg| arg == "--")
.map(|extra_args_index| args[extra_args_index..].to_vec());
let _ = cargo_exec("run", "cli", platform, renderer, debug, additional_flags)?;
Ok(())
}
fn run_build(
package: &str,
platform: Platform,
renderer: Renderer,
debug: bool,
additional_flags: Option<Vec<String>>,
output_dir: std::path::PathBuf,
) -> Result<(), Box<dyn std::error::Error>> {
for (name, executable_path) in cargo_exec(
"build",
package,
platform,
renderer,
debug,
additional_flags,
)?
.filter_map(|m| as_artifact(m.ok()?))
.filter_map(|a| a.executable.map(|e| (a.target.name, e)))
{
std::fs::copy(executable_path, output_dir.join(name))?;
}
Ok(())
}
fn cargo_exec(
verb: &str,
package: &str,
platform: Platform,
renderer: Renderer,
debug: bool,
additional_flags: Option<Vec<String>>,
) -> Result<
impl Iterator<Item = std::io::Result<cargo_metadata::Message>>,
Box<dyn std::error::Error>,
> {
let sh = Shell::new()?;
let target = platform.as_target();
let release = if debug { "" } else { "--release" };
let renderer = renderer.as_feature();
let args=format!("{verb} -p {package} --target {target} {release} --no-default-features -F {renderer} --message-format=json");
let args = args.split_whitespace().map(|s| s.to_string());
let args = if let Some(additional_flags) = additional_flags {
args.chain(additional_flags).collect::<Vec<_>>()
} else {
args.collect::<Vec<_>>()
};
let output = sh.cmd("cargo").args(args).read()?;
Ok(cargo_metadata::Message::parse_stream(std::io::Cursor::new(
output,
)))
}
fn as_artifact(message: cargo_metadata::Message) -> Option<cargo_metadata::Artifact> {
if let cargo_metadata::Message::CompilerArtifact(a) = message {
Some(a)
} else {
None
}
}
fn build_vst(
platform: Platform,
renderer: Renderer,
debug: bool,
) -> Result<(), Box<dyn std::error::Error>> {
let mut args = if platform == Platform::Mac {
vec!["bundle-universal"]
} else {
vec!["bundle", "--target", platform.as_target()]
};
if !debug {
args.push("--release");
}
let more_args = "-p twinc_emu_vst --no-default-features -F plugin";
for arg in more_args.split_whitespace() {
args.push(arg);
}
args.push("-F");
args.push(renderer.as_feature());
nih_plug_xtask::main_with_args("cargo xtask", args.into_iter().map(String::from))?;
Ok(())
}

96
xtask/src/types.rs Normal file
View file

@ -0,0 +1,96 @@
#[derive(clap::ValueEnum, Clone, Copy, Debug, strum::EnumIter, PartialEq, Eq)]
pub enum Platform {
Windows,
Linux,
Mac,
}
impl Platform {
pub fn as_target(&self) -> &str {
match self {
Platform::Windows => "x86_64-pc-windows-gnu",
Platform::Linux => "x86_64-unknown-linux-gnu",
Platform::Mac => "aarch64-apple-darwin",
}
}
pub fn ui(&self) -> &str {
match self {
Platform::Windows | Platform::Linux => "crossplatform-ui",
Platform::Mac => "macos-ui",
}
}
pub fn host_platform() -> Self {
if cfg!(target_os = "windows") {
Self::Windows
} else if cfg!(target_os = "macos") {
Self::Mac
} else if cfg!(target_os = "linux") {
Self::Linux
} else {
todo!()
}
}
}
#[derive(clap::ValueEnum, Clone, Copy, Debug, strum::EnumIter, PartialEq, Eq)]
pub enum Binary {
Gui,
Cli,
Vst,
}
impl Binary {
pub fn name(&self) -> &str {
match self {
Binary::Gui => "gui",
Binary::Cli => "cli",
Binary::Vst => "vst",
}
}
pub fn get_default() -> Self {
Self::Cli
}
}
#[derive(clap::ValueEnum, Clone, Copy, Debug, strum::EnumIter, PartialEq, Eq)]
pub enum Renderer {
Wgpu,
Vulkan,
Pixels,
}
impl Renderer {
pub fn as_feature(&self) -> &str {
match self {
Renderer::Wgpu => "wgpu",
Renderer::Vulkan => "vulkan",
Renderer::Pixels => "pixels",
}
}
}
#[derive(Debug)]
pub struct CouldntSetOnceLock;
impl std::fmt::Display for CouldntSetOnceLock {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Debug::fmt(&self, f)
}
}
impl std::error::Error for CouldntSetOnceLock {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
None
}
fn description(&self) -> &str {
"description() is deprecated; use Display"
}
fn cause(&self) -> Option<&dyn std::error::Error> {
self.source()
}
}