diff --git a/.cargo/config.toml b/.cargo/config.toml index a9d08b7..ed74f51 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,6 +1,3 @@ [unstable] unstable-options = true bindeps = true - -[build] -artifact-dir = "out" \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index c757355..0c2b860 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -348,7 +348,6 @@ name = "ebu-plugs" version = "0.1.0" dependencies = [ "airfreshener", - "helpers", ] [[package]] @@ -477,10 +476,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "helpers" -version = "0.1.0" - [[package]] name = "hermit-abi" version = "0.1.19" @@ -671,6 +666,7 @@ dependencies = [ "raw-window-handle", "serde", "serde_json", + "vst3-sys", "widestring", "windows", ] @@ -1100,6 +1096,43 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "vst3-com" +version = "0.1.0" +source = "git+https://github.com/robbert-vdh/vst3-sys.git?branch=fix%2Fdrop-box-from-raw#b3ff4d775940f5b476b9d1cca02a90e07e1922a2" +dependencies = [ + "vst3-com-macros", +] + +[[package]] +name = "vst3-com-macros" +version = "0.2.0" +source = "git+https://github.com/robbert-vdh/vst3-sys.git?branch=fix%2Fdrop-box-from-raw#b3ff4d775940f5b476b9d1cca02a90e07e1922a2" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "vst3-com-macros-support", +] + +[[package]] +name = "vst3-com-macros-support" +version = "0.2.0" +source = "git+https://github.com/robbert-vdh/vst3-sys.git?branch=fix%2Fdrop-box-from-raw#b3ff4d775940f5b476b9d1cca02a90e07e1922a2" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "vst3-sys" +version = "0.1.0" +source = "git+https://github.com/robbert-vdh/vst3-sys.git?branch=fix%2Fdrop-box-from-raw#b3ff4d775940f5b476b9d1cca02a90e07e1922a2" +dependencies = [ + "vst3-com", +] + [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 4051255..df1eb9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,14 +3,9 @@ name = "ebu-plugs" version = "0.1.0" edition = "2024" -[lib] -crate-type = ["cdylib"] - [dependencies] airfreshener = { path = "plug-airfreshener", lib = true, artifact = "cdylib" } -[build-dependencies] -helpers = { path = "helpers" } - [workspace] -members = ["dsp", "helpers", "plug-airfreshener"] +members = ["dsp", "plug-airfreshener"] + diff --git a/build.rs b/build.rs index 7f24ae0..35b98da 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,56 @@ -fn main() { - //helpers::copy_artifact_to_out_dir("airfreshener", "AirFreshener"); +use std::{env, fs, path::Path}; + +#[cfg(debug_assertions)] +const CONFIG: &str = "debug"; +#[cfg(not(debug_assertions))] +const CONFIG: &str = "release"; + +#[cfg(target_os = "macos")] +const OS_LIB_EXT: &str = "dylib"; +#[cfg(target_os = "windows")] +const OS_LIB_EXT: &str = "dll"; +#[cfg(target_os = "linux")] +const OS_LIB_EXT: &str = "so"; + +#[cfg(target_os = "macos")] +const OS_NAME: &str = "macOS"; +#[cfg(target_os = "windows")] +const OS_NAME: &str = "Windows"; +#[cfg(target_os = "linux")] +const OS_NAME: &str = "Linux"; + +fn get_output_lib_name(lib_name: &str) -> &'static str { + match lib_name { + "airfreshener" => "AirFreshener", + _ => "Unknown", + } +} + +fn main() { + let target_dir = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap_or("".to_owned())) + .join(format!("target/{CONFIG}")); + let artifact_dir = target_dir.join("deps/artifact"); + + let artifact_dirs = + fs::read_dir(artifact_dir).expect("Failed to read build artifact directory"); + for dir_result in artifact_dirs { + if let Ok(dir) = dir_result { + if let Some(lib_name) = dir.file_name().to_string_lossy().split('-').next() { + let lib_path = dir + .path() + .join(format!("cdylib/lib{lib_name}.{OS_LIB_EXT}")); + if fs::exists(&lib_path).unwrap_or_default() { + let out_lib_name = get_output_lib_name(lib_name); + let out_lib_path = target_dir.join(format!("{out_lib_name}_{OS_NAME}.clap")); + if let Err(err) = fs::copy(&lib_path, &out_lib_path) { + println!( + "cargo::error=Output library lib{lib_name:?}.{OS_LIB_EXT} could not be copied to target: {err}" + ); + } + } else { + println!("cargo::error=Output library lib{lib_name:?}.{OS_LIB_EXT} not found"); + } + } + } + } } diff --git a/helpers/Cargo.toml b/helpers/Cargo.toml deleted file mode 100644 index cb9df2c..0000000 --- a/helpers/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "helpers" -version = "0.1.0" -edition = "2024" - -[dependencies] diff --git a/helpers/src/lib.rs b/helpers/src/lib.rs deleted file mode 100644 index 65f01aa..0000000 --- a/helpers/src/lib.rs +++ /dev/null @@ -1,40 +0,0 @@ -use std::{ - env, fs, - path::{Path, PathBuf}, -}; - -#[cfg(debug_assertions)] -const CONFIG: &str = "debug"; -#[cfg(not(debug_assertions))] -const CONFIG: &str = "release"; - -#[cfg(target_os = "macos")] -const OS_LIB_EXT: &str = "dylib"; -#[cfg(target_os = "windows")] -const OS_LIB_EXT: &str = "dll"; -#[cfg(target_os = "linux")] -const OS_LIB_EXT: &str = "so"; - -#[cfg(target_os = "macos")] -const OS_NAME: &str = "macOS"; -#[cfg(target_os = "windows")] -const OS_NAME: &str = "Windows"; -#[cfg(target_os = "linux")] -const OS_NAME: &str = "Linux"; - -pub fn built_lib_path(lib_name: &str) -> PathBuf { - Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap_or("".to_owned())) - .join(format!("target/{CONFIG}/lib{lib_name}.{OS_LIB_EXT}")) -} - -pub fn copy_artifact_to_out_dir(lib_name: &str, pretty_name: &str) { - let src_path = built_lib_path(lib_name); - - let dst_path = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap_or("".to_owned())).join( - format!("target/build/{CONFIG}/{pretty_name}_{OS_NAME}.clap"), - ); - - fs::create_dir_all(dst_path.parent().unwrap()) - .expect("Failed to create artifact output directory"); - fs::copy(src_path, dst_path).expect("Failed to move artifact"); -} diff --git a/plug-airfreshener/Cargo.toml b/plug-airfreshener/Cargo.toml index 20fc442..2177b3f 100644 --- a/plug-airfreshener/Cargo.toml +++ b/plug-airfreshener/Cargo.toml @@ -4,14 +4,20 @@ version = "0.1.0" edition = "2024" [lib] -crate-type = ["cdylib"] +crate-type = ["cdylib", "rlib"] [dependencies] dsp = { version = "0.1.0", path = "../dsp" } -nih_plug = { git = "https://github.com/robbert-vdh/nih-plug", version = "0.0.0", default-features = false } parking_lot = "0.12.5" -baseview = { git = "https://github.com/RustAudio/baseview", rev = "237d323c729f3aa99476ba3efa50129c5e86cad3", features = ["opengl"]} +baseview = { git = "https://github.com/RustAudio/baseview", rev = "237d323c729f3aa99476ba3efa50129c5e86cad3", features = [ + "opengl", +] } crossbeam = "0.8.4" femtovg = "0.19.3" serde = { version = "1.0.228", features = ["derive"] } -image = { version = "0.25.9", default-features = false, features = ["png"] } \ No newline at end of file +image = { version = "0.25.9", default-features = false, features = ["png"] } +[target.'cfg(target_os = "linux")'.dependencies] +nih_plug = { git = "https://github.com/robbert-vdh/nih-plug", version = "0.0.0", default-features = false } + +[features] +vst3 = ["nih_plug/vst3"] diff --git a/plug-airfreshener/src/lib.rs b/plug-airfreshener/src/lib.rs index 42cd164..c717bb9 100644 --- a/plug-airfreshener/src/lib.rs +++ b/plug-airfreshener/src/lib.rs @@ -203,6 +203,7 @@ impl Plugin for AirFreshener { fn deactivate(&mut self) {} } +#[cfg(not(feature = "vst3"))] impl ClapPlugin for AirFreshener { const CLAP_ID: &'static str = "com.moist-plugins-gmbh.gain"; const CLAP_DESCRIPTION: Option<&'static str> = Some("A smoothed gain parameter example plugin"); @@ -215,4 +216,16 @@ impl ClapPlugin for AirFreshener { ]; } +#[cfg(feature = "vst3")] +impl Vst3Plugin for AirFreshener { + const VST3_CLASS_ID: [u8; 16] = *b"AirFreshener____"; + const VST3_SUBCATEGORIES: &'static [Vst3SubCategory] = + &[Vst3SubCategory::Fx, Vst3SubCategory::Tools]; +} + + +#[cfg(not(feature = "vst3"))] nih_export_clap!(AirFreshener); + +#[cfg(feature = "vst3")] +nih_export_vst3!(AirFreshener); diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..f328e4d --- /dev/null +++ b/src/main.rs @@ -0,0 +1 @@ +fn main() {}