From 0b8221b136459223103b033d22a98f85975b389e Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 24 Jun 2021 15:48:43 +0200 Subject: [PATCH] [yabridgectl] Add support for 32-bit yabridge VST3 Bundles containing a 32-bit version of `libyabridge-vst3.so` should use the `x86-linux` directory instead of the `x86_64-linux` directory. --- CHANGELOG.md | 2 ++ tools/yabridgectl/src/actions.rs | 17 +++++++++++++---- tools/yabridgectl/src/files.rs | 26 ++++++++++++++++++++------ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e87593e..0bf7c0f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### yabridgectl +- Added support for setting up merged VST3 bundles with a 32-bit version of + `libyabridge-vst3.so`. - Copies of `libyabridge-vst2.so` and `libyabridge-vst3.so` are now reflinked when supported by the file system. This speeds up the file coyping process while also reducing the amount of disk space used for yabridge when using diff --git a/tools/yabridgectl/src/actions.rs b/tools/yabridgectl/src/actions.rs index 8366324c..882217a3 100644 --- a/tools/yabridgectl/src/actions.rs +++ b/tools/yabridgectl/src/actions.rs @@ -98,7 +98,8 @@ pub fn show_status(config: &Config) -> Result<()> { .unwrap_or_else(|| String::from("")) ); - match config.files() { + let files = config.files(); + match &files { Ok(files) => { println!( "libyabridge-vst2.so: '{}'", @@ -108,6 +109,7 @@ pub fn show_status(config: &Config) -> Result<()> { "libyabridge-vst3.so: {}\n", files .libyabridge_vst3 + .as_ref() .map(|(path, arch)| format!("'{}' ({})", path.display(), arch)) .unwrap_or_else(|| "".red().to_string()) ); @@ -123,7 +125,9 @@ pub fn show_status(config: &Config) -> Result<()> { // be added both with and without a trailing slash println!("\n{}", path.join("").display()); - for (plugin_path, (plugin, status)) in search_results.installation_status() { + for (plugin_path, (plugin, status)) in + search_results.installation_status(files.as_ref().ok()) + { let plugin_type = match plugin { Plugin::Vst2(Vst2Plugin { architecture, .. }) => { format!("{}, {}", "VST2".cyan(), architecture) @@ -302,8 +306,13 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> { } // We're building a merged VST3 bundle containing both a copy or symlink to - // `libyabridge-vst3.so` and the Windows VST3 plugin - let native_module_path = module.target_native_module_path(); + // `libyabridge-vst3.so` and the Windows VST3 plugin. The path to this native + // module will depend on whether `libyabridge-vst3.so` is a 32-bit or a 64-bit + // library file. + // TODO: Make sure the bundle is cleared before setting this up for the first + // time, or else it won't be possible to cleanly switch between 32-bit and + // 64-bit yabridge. + let native_module_path = module.target_native_module_path(Some(&files)); utils::create_dir_all(native_module_path.parent().unwrap())?; if install_file( options.force, diff --git a/tools/yabridgectl/src/files.rs b/tools/yabridgectl/src/files.rs index b43404ef..5ba5d16e 100644 --- a/tools/yabridgectl/src/files.rs +++ b/tools/yabridgectl/src/files.rs @@ -26,7 +26,7 @@ use std::path::{Path, PathBuf}; use std::process::Command; use walkdir::WalkDir; -use crate::config::yabridge_vst3_home; +use crate::config::{yabridge_vst3_home, YabridgeFiles}; use crate::utils::get_file_type; /// Stores the results from searching through a directory. We'll search for Windows VST2 plugin @@ -189,8 +189,10 @@ impl Vst3Module { } /// Get the path to the `libyabridge.so` file in `~/.vst3` corresponding to the bridged version - /// of this module. - pub fn target_native_module_path(&self) -> PathBuf { + /// of this module. The path here depends on whether we're using a 32-bit or 64-bit version of + /// yabridge. If the configuration is not given (for instance, becuase yabridge is not set up + /// properly) we'll assume the module should be 64-bit. + pub fn target_native_module_path(&self, config: Option<&YabridgeFiles>) -> PathBuf { let native_module_name = match &self.module { Vst3ModuleType::Legacy(path) | Vst3ModuleType::Bundle(path) => path .with_extension("so") @@ -203,7 +205,16 @@ impl Vst3Module { let mut path = self.target_bundle_home(); path.push("Contents"); - path.push("x86_64-linux"); + + #[allow(clippy::wildcard_in_or_patterns)] + match config.and_then(|c| c.libyabridge_vst3.as_ref()) { + Some((_, LibArchitecture::Lib32)) => path.push("x86-linux"), + // NOTE: We'll always fall back to this if `libyabridge-vst3.so` is not found, just so + // we cannot get any errors during `yabridgectl status` even if yabridge is not + // set up correctly. + Some((_, LibArchitecture::Lib64)) | _ => path.push("x86_64-linux"), + } + path.push(native_module_name); path } @@ -269,7 +280,10 @@ impl SearchResults { /// Create a map out of all found plugins based on their file path that contains both a /// reference to the plugin (so we can print information about it) and the current installation /// status. The installation status will be `None` if the plugin has not yet been set up. - pub fn installation_status(&self) -> BTreeMap)> { + pub fn installation_status( + &self, + config: Option<&YabridgeFiles>, + ) -> BTreeMap)> { let so_files: HashMap<&Path, &NativeFile> = self .so_files .iter() @@ -293,7 +307,7 @@ impl SearchResults { vst3_module.original_path().to_owned(), ( plugin, - get_file_type(vst3_module.target_native_module_path()), + get_file_type(vst3_module.target_native_module_path(config)), ), ), })