Add bundler support for VST2 plugins
This commit is contained in:
parent
8e0597b780
commit
4e9f64f494
|
@ -148,12 +148,17 @@ pub fn bundle(package: &str, args: &[String]) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll detect the pugin formats supported by the plugin binary and create bundled accordingly
|
// We'll detect the pugin formats supported by the plugin binary and create bundled accordingly
|
||||||
// TODO: Support VST2 at some point
|
// NOTE: NIH-plug does not support VST2, but we'll support bundling VST2 plugins anyways because
|
||||||
|
// this bundler can also be used standalone.
|
||||||
let bundle_clap = symbols::exported(&lib_path, "clap_entry")
|
let bundle_clap = symbols::exported(&lib_path, "clap_entry")
|
||||||
.with_context(|| format!("Could not parse '{}'", lib_path.display()))?;
|
.with_context(|| format!("Could not parse '{}'", lib_path.display()))?;
|
||||||
|
// We'll ignore the platofrm-specific entry points for VST2 plugins since there's no reason to
|
||||||
|
// create a new Rust VST2 plugin that doesn't work in modern DAWs
|
||||||
|
let bundle_vst2 = symbols::exported(&lib_path, "VSTPluginMain")
|
||||||
|
.with_context(|| format!("Could not parse '{}'", lib_path.display()))?;
|
||||||
let bundle_vst3 = symbols::exported(&lib_path, "GetPluginFactory")
|
let bundle_vst3 = symbols::exported(&lib_path, "GetPluginFactory")
|
||||||
.with_context(|| format!("Could not parse '{}'", lib_path.display()))?;
|
.with_context(|| format!("Could not parse '{}'", lib_path.display()))?;
|
||||||
let bundled_plugin = bundle_clap || bundle_vst3;
|
let bundled_plugin = bundle_clap || bundle_vst2 || bundle_vst3;
|
||||||
|
|
||||||
eprintln!();
|
eprintln!();
|
||||||
if bundle_clap {
|
if bundle_clap {
|
||||||
|
@ -177,6 +182,27 @@ pub fn bundle(package: &str, args: &[String]) -> Result<()> {
|
||||||
|
|
||||||
eprintln!("Created a CLAP bundle at '{}'", clap_bundle_home.display());
|
eprintln!("Created a CLAP bundle at '{}'", clap_bundle_home.display());
|
||||||
}
|
}
|
||||||
|
if bundle_vst2 {
|
||||||
|
let vst2_bundle_library_name = vst2_bundle_library_name(&bundle_name, compilation_target);
|
||||||
|
let vst2_lib_path = Path::new(BUNDLE_HOME).join(&vst2_bundle_library_name);
|
||||||
|
|
||||||
|
fs::create_dir_all(vst2_lib_path.parent().unwrap())
|
||||||
|
.context("Could not create VST2 bundle directory")?;
|
||||||
|
reflink::reflink_or_copy(&lib_path, &vst2_lib_path)
|
||||||
|
.context("Could not copy library to VST2 bundle")?;
|
||||||
|
|
||||||
|
// VST2 only uses bundles on macOS, so we'll just take the first component of the library
|
||||||
|
// name instead
|
||||||
|
let vst2_bundle_home = Path::new(BUNDLE_HOME).join(
|
||||||
|
Path::new(&vst2_bundle_library_name)
|
||||||
|
.components()
|
||||||
|
.next()
|
||||||
|
.expect("Malformed VST2 library path"),
|
||||||
|
);
|
||||||
|
maybe_create_macos_bundle_metadata(package, &vst2_bundle_home, compilation_target)?;
|
||||||
|
|
||||||
|
eprintln!("Created a VST2 bundle at '{}'", vst2_bundle_home.display());
|
||||||
|
}
|
||||||
if bundle_vst3 {
|
if bundle_vst3 {
|
||||||
let vst3_lib_path =
|
let vst3_lib_path =
|
||||||
Path::new(BUNDLE_HOME).join(vst3_bundle_library_name(&bundle_name, compilation_target));
|
Path::new(BUNDLE_HOME).join(vst3_bundle_library_name(&bundle_name, compilation_target));
|
||||||
|
@ -290,6 +316,16 @@ fn clap_bundle_library_name(package: &str, target: CompilationTarget) -> String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// On Linux and Windows VST2 plugins are regular library files, and on macOS they are put in a
|
||||||
|
/// bundle.
|
||||||
|
fn vst2_bundle_library_name(package: &str, target: CompilationTarget) -> String {
|
||||||
|
match target {
|
||||||
|
CompilationTarget::Linux64 | CompilationTarget::Linux32 => format!("{package}.so"),
|
||||||
|
CompilationTarget::Windows64 | CompilationTarget::Windows32 => format!("{package}.dll"),
|
||||||
|
CompilationTarget::Mac64 => format!("{package}.vst/Contents/MacOS/{package}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The full path to the library file inside of a VST3 bundle, including the leading `.vst3`
|
/// The full path to the library file inside of a VST3 bundle, including the leading `.vst3`
|
||||||
/// directory.
|
/// directory.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue