Add VST3 option

This commit is contained in:
Ebu
2025-12-04 12:11:29 +01:00
parent a9bd69e461
commit 74428b272d
10 changed files with 119 additions and 67 deletions

View File

@@ -1,6 +1,3 @@
[unstable] [unstable]
unstable-options = true unstable-options = true
bindeps = true bindeps = true
[build]
artifact-dir = "out"

43
Cargo.lock generated
View File

@@ -348,7 +348,6 @@ name = "ebu-plugs"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"airfreshener", "airfreshener",
"helpers",
] ]
[[package]] [[package]]
@@ -477,10 +476,6 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "helpers"
version = "0.1.0"
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.19" version = "0.1.19"
@@ -671,6 +666,7 @@ dependencies = [
"raw-window-handle", "raw-window-handle",
"serde", "serde",
"serde_json", "serde_json",
"vst3-sys",
"widestring", "widestring",
"windows", "windows",
] ]
@@ -1100,6 +1096,43 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" 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]] [[package]]
name = "wasi" name = "wasi"
version = "0.11.1+wasi-snapshot-preview1" version = "0.11.1+wasi-snapshot-preview1"

View File

@@ -3,14 +3,9 @@ name = "ebu-plugs"
version = "0.1.0" version = "0.1.0"
edition = "2024" edition = "2024"
[lib]
crate-type = ["cdylib"]
[dependencies] [dependencies]
airfreshener = { path = "plug-airfreshener", lib = true, artifact = "cdylib" } airfreshener = { path = "plug-airfreshener", lib = true, artifact = "cdylib" }
[build-dependencies]
helpers = { path = "helpers" }
[workspace] [workspace]
members = ["dsp", "helpers", "plug-airfreshener"] members = ["dsp", "plug-airfreshener"]

View File

@@ -1,3 +1,56 @@
fn main() { use std::{env, fs, path::Path};
//helpers::copy_artifact_to_out_dir("airfreshener", "AirFreshener");
#[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");
}
}
}
}
} }

View File

@@ -1,6 +0,0 @@
[package]
name = "helpers"
version = "0.1.0"
edition = "2024"
[dependencies]

View File

@@ -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");
}

View File

@@ -4,14 +4,20 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib", "rlib"]
[dependencies] [dependencies]
dsp = { version = "0.1.0", path = "../dsp" } 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" 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" crossbeam = "0.8.4"
femtovg = "0.19.3" femtovg = "0.19.3"
serde = { version = "1.0.228", features = ["derive"] } serde = { version = "1.0.228", features = ["derive"] }
image = { version = "0.25.9", default-features = false, features = ["png"] } 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"]

View File

@@ -203,6 +203,7 @@ impl Plugin for AirFreshener {
fn deactivate(&mut self) {} fn deactivate(&mut self) {}
} }
#[cfg(not(feature = "vst3"))]
impl ClapPlugin for AirFreshener { impl ClapPlugin for AirFreshener {
const CLAP_ID: &'static str = "com.moist-plugins-gmbh.gain"; const CLAP_ID: &'static str = "com.moist-plugins-gmbh.gain";
const CLAP_DESCRIPTION: Option<&'static str> = Some("A smoothed gain parameter example plugin"); 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); nih_export_clap!(AirFreshener);
#[cfg(feature = "vst3")]
nih_export_vst3!(AirFreshener);

View File

1
src/main.rs Normal file
View File

@@ -0,0 +1 @@
fn main() {}