From 70378be6e9ef22841f8d7c3e2687db44f6c06957 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 26 Feb 2022 20:12:08 +0100 Subject: [PATCH] Replace --bundle-vst3 with export detection We'll need this for when we support other plugin formats. --- .github/workflows/test.yml | 2 +- README.md | 2 +- plugins/diopser/README.md | 4 ++-- xtask/src/main.rs | 19 +++++++++---------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 649890b5..42d10dea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -109,7 +109,7 @@ jobs: run: | packages=$(cargo xtask known-packages) for package in $packages; do - cargo xtask bundle "$package" --bundle-vst3 --release + cargo xtask bundle "$package" --release done - name: Determine build archive name diff --git a/README.md b/README.md index a6c00ed6..ce6af54a 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ in the `plugins` directory in the following way, replacing `gain` with the name of the plugin: ```shell -cargo xtask bundle gain --release --bundle-vst3 +cargo xtask bundle gain --release ``` ### Example plugins diff --git a/plugins/diopser/README.md b/plugins/diopser/README.md index e78047af..bb6fe30a 100644 --- a/plugins/diopser/README.md +++ b/plugins/diopser/README.md @@ -38,7 +38,7 @@ After installing [Rust](https://rustup.rs/) with the nightly toolchain you can compile Diopser as follows ```shell -cargo +nightly xtask bundle gain --release --bundle-vst3 +cargo +nightly xtask bundle gain --release ``` If you don't have access to a nightly compiler (`rustup default nightly && rustup update`), @@ -46,5 +46,5 @@ then you can compile a version without SIMD at a 2x penalty by disabling the SIMD feature: ```shell -cargo xtask bundle gain --release --bundle-vst3 --no-default-features +cargo xtask bundle gain --release --no-default-features ``` diff --git a/xtask/src/main.rs b/xtask/src/main.rs index ba6fe18e..49f2ffdf 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -7,8 +7,7 @@ use std::process::Command; mod symbols; -const USAGE_STRING: &str = - "Usage: cargo xtask bundle [--release] [--target ] [--bundle-vst3]"; +const USAGE_STRING: &str = "Usage: cargo xtask bundle [--release] [--target ]"; /// The base birectory for the bundler's output. const BUNDLE_HOME: &str = "target/bundled"; @@ -40,7 +39,7 @@ fn main() -> Result<()> { .context(format!("Missing package name\n\n{USAGE_STRING}"))?; let other_args: Vec<_> = args.collect(); - bundle(&package, other_args) + bundle(&package, &other_args) } // This is only meant to be used by the CI, since using awk for this can be a bit spotty on // macOS @@ -50,22 +49,17 @@ fn main() -> Result<()> { } // TODO: The macOS version has not been tested -fn bundle(package: &str, mut args: Vec) -> Result<()> { +fn bundle(package: &str, args: &[String]) -> Result<()> { let bundle_name = match load_bundler_config()?.and_then(|c| c.get(package).cloned()) { Some(PackageConfig { name: Some(name) }) => name, _ => package.to_string(), }; let mut is_release_build = false; - let mut bundle_vst3 = false; let mut cross_compile_target: Option = None; for arg_idx in (0..args.len()).rev() { let arg = &args[arg_idx]; match arg.as_str() { - "--bundle-vst3" => { - bundle_vst3 = true; - args.remove(arg_idx); - } "--release" => is_release_build = true, "--target" => { // When cross compiling we should generate the correct bundle type @@ -104,6 +98,11 @@ fn bundle(package: &str, mut args: Vec) -> Result<()> { bail!("Could not find built library at '{}'", lib_path.display()); } + // We'll detect the pugin formats supported by the plugin binary and create bundled accordingly + // TODO: Support VST2 and CLAP here + let bundle_vst3 = symbols::exported(&lib_path, "GetPluginFactory") + .with_context(|| format!("Could not parse '{}'", lib_path.display()))?; + eprintln!(); if bundle_vst3 { let vst3_lib_path = Path::new(BUNDLE_HOME).join(vst3_bundle_library_name( @@ -126,7 +125,7 @@ fn bundle(package: &str, mut args: Vec) -> Result<()> { eprintln!("Created a VST3 bundle at '{}'", vst3_bundle_home.display()); } else { - eprintln!("Not creating any plugin bundles") + eprintln!("Not creating any plugin bundles because the package does not export any plugins") } Ok(())