From a428d08eff37a0adf4714ffa978af283e6751116 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 28 Nov 2020 13:17:33 +0100 Subject: [PATCH] Update yabridgectl for libyabridge-vst2.so --- tools/yabridgectl/README.md | 15 ++++++++++----- tools/yabridgectl/src/actions.rs | 26 +++++++++++++------------- tools/yabridgectl/src/config.rs | 28 ++++++++++++++-------------- tools/yabridgectl/src/files.rs | 4 ++-- tools/yabridgectl/src/main.rs | 6 +++--- tools/yabridgectl/src/utils.rs | 2 +- 6 files changed, 43 insertions(+), 38 deletions(-) diff --git a/tools/yabridgectl/README.md b/tools/yabridgectl/README.md index c41ace1f..0366b119 100644 --- a/tools/yabridgectl/README.md +++ b/tools/yabridgectl/README.md @@ -13,11 +13,11 @@ from anywhere. All of the information below can also be found through ### Yabridge path -Yabridgectl will need to know where it can find `libyabridge.so`. By default it -will search for it in both `~/.local/share/yabridge` (the recommended -installation directory when using the prebuilt binaries) and in `/usr/lib`. You -can use the command below to override this behaviour and to use a custom -installation directory instead. +Yabridgectl will need to know where it can find the `libyabridge-vst*.so` files. +By default it will search for it in both `~/.local/share/yabridge` (the +recommended installation directory when using the prebuilt binaries) and in +`/usr/lib`. You can use the command below to override this behaviour and to use +a custom installation directory instead. ```shell yabridgectl set --path= @@ -77,6 +77,11 @@ yabridgectl sync --force ## Alternatives +TODO: This now only mentions how to do this for VST2 plugins. We should probably +just drop this section altogether since using yabridgectl is so much easier, and +if someone really wants to do this by hand then they'll be able to whip up their +own script based on the instructions in the main readme. + If you want to script your own installation behaviour and don't feel like using yabridgectl, then you could use one of the below bash snippets instead. This approach is slightly less robust and does not perform any problem detection or diff --git a/tools/yabridgectl/src/actions.rs b/tools/yabridgectl/src/actions.rs index 2de63b7d..b2741cd9 100644 --- a/tools/yabridgectl/src/actions.rs +++ b/tools/yabridgectl/src/actions.rs @@ -96,9 +96,9 @@ pub fn show_status(config: &Config) -> Result<()> { .unwrap_or_else(|| String::from("")) ); println!( - "libyabridge.so: {}", + "libyabridge-vst2.so: {}", config - .libyabridge() + .libyabridge_vst2() .map(|path| format!("'{}'", path.display())) .unwrap_or_else(|_| format!("{}", "".red())) ); @@ -154,9 +154,9 @@ pub struct SyncOptions { /// Set up yabridge for all Windows VST2 plugins in the plugin directories. Will also remove orphan /// `.so` files if the prune option is set. pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> { - let libyabridge_path = config.libyabridge()?; - let libyabridge_hash = utils::hash_file(&libyabridge_path)?; - println!("Using '{}'\n", libyabridge_path.display()); + let libyabridge_vst2_path = config.libyabridge_vst2()?; + let libyabridge_vst2_hash = utils::hash_file(&libyabridge_vst2_path)?; + println!("Using '{}'\n", libyabridge_vst2_path.display()); let results = config .index_directories() @@ -188,19 +188,19 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> { match (options.force, &config.method) { (false, InstallationMethod::Copy) => { // If the target file is already a real file (not a symlink) and its hash is - // the same as the `libyabridge.so` file we're trying to copy there, then we - // don't have to do anything + // the same as the `libyabridge-vst2.so` file we're trying to copy there, + // then we don't have to do anything if metadata.file_type().is_file() - && utils::hash_file(&target_path)? == libyabridge_hash + && utils::hash_file(&target_path)? == libyabridge_vst2_hash { continue; } } (false, InstallationMethod::Symlink) => { - // If the target file is already a symlink to `libyabridge.so`, then we can - // skip this file + // If the target file is already a symlink to `libyabridge-vst2.so`, then we + // can skip this file if metadata.file_type().is_symlink() - && target_path.read_link()? == libyabridge_path + && target_path.read_link()? == libyabridge_vst2_path { continue; } @@ -217,10 +217,10 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> { num_new += 1; match config.method { InstallationMethod::Copy => { - utils::copy(&libyabridge_path, &target_path)?; + utils::copy(&libyabridge_vst2_path, &target_path)?; } InstallationMethod::Symlink => { - utils::symlink(&libyabridge_path, &target_path)?; + utils::symlink(&libyabridge_vst2_path, &target_path)?; } } diff --git a/tools/yabridgectl/src/config.rs b/tools/yabridgectl/src/config.rs index fbb6b979..b4db96a6 100644 --- a/tools/yabridgectl/src/config.rs +++ b/tools/yabridgectl/src/config.rs @@ -35,7 +35,7 @@ pub const CONFIG_FILE_NAME: &str = "config.toml"; const YABRIDGECTL_PREFIX: &str = "yabridgectl"; /// The name of the library file we're searching for. -pub const LIBYABRIDGE_NAME: &str = "libyabridge.so"; +pub const LIBYABRIDGE_VST2_NAME: &str = "libyabridge-vst2.so"; /// The name of the script we're going to run to verify that everything's working correctly. pub const YABRIDGE_HOST_EXE_NAME: &str = "yabridge-host.exe"; /// The name of the XDG base directory prefix for yabridge's own files, relative to @@ -66,11 +66,11 @@ pub struct Config { #[derive(Deserialize, Serialize, Debug, PartialEq, Eq)] #[serde(rename_all = "snake_case")] pub enum InstallationMethod { - /// Create a copy of `libyabridge.so` for every Windows VST2 plugin .dll file found. After + /// Create a copy of `libyabridge-vst2.so` for every Windows VST2 plugin .dll file found. After /// updating yabridge, the user will have to rerun `yabridgectl sync` to copy over the new /// version. Copy, - /// This will create a symlink to `libyabridge.so` for every VST2 .dll file in the plugin + /// This will create a symlink to `libyabridge-vst2.so` for every VST2 .dll file in the plugin /// directories. As explained in the readme, this makes updating easier and remvoes the need to /// modify the `PATH` environment variable. Symlink, @@ -158,19 +158,19 @@ impl Config { .with_context(|| format!("Failed to write config file to '{}'", config_path.display())) } - /// Return the path to `libyabridge.so`, or a descriptive error if it can't be found. If + /// Return the path to `libyabridge-vst2.so`, or a descriptive error if it can't be found. If /// `yabridge_home` is `None`, then we'll search in both `/usr/lib` and /// `$XDG_DATA_HOME/yabridge`. - pub fn libyabridge(&self) -> Result { + pub fn libyabridge_vst2(&self) -> Result { match &self.yabridge_home { Some(directory) => { - let candidate = directory.join(LIBYABRIDGE_NAME); + let candidate = directory.join(LIBYABRIDGE_VST2_NAME); if candidate.exists() { Ok(candidate) } else { Err(anyhow!( "Could not find '{}' in '{}'", - LIBYABRIDGE_NAME, + LIBYABRIDGE_VST2_NAME, directory.display() )) } @@ -179,12 +179,12 @@ impl Config { // Search in the two common installation locations if no path was set explicitely. // We'll also search through `/usr/local/lib` just in case but since we advocate // against isntalling yabridge there we won't list this path in the error message - // when `libyabridge.so` can't be found. + // when `libyabridge-vst2.so` can't be found. let system_path = Path::new("/usr/lib"); let system_path_alt = Path::new("/usr/local/lib"); let user_path = yabridge_directories()?.get_data_home(); for directory in &[system_path, system_path_alt, &user_path] { - let candidate = directory.join(LIBYABRIDGE_NAME); + let candidate = directory.join(LIBYABRIDGE_VST2_NAME); if candidate.exists() { return Ok(candidate); } @@ -193,7 +193,7 @@ impl Config { Err(anyhow!( "Could not find '{}' in either '{}' or '{}'. You can override the default \ search path using 'yabridgectl set --path='.", - LIBYABRIDGE_NAME, + LIBYABRIDGE_VST2_NAME, system_path.display(), user_path.display() )) @@ -202,11 +202,11 @@ impl Config { } /// Return the path to `yabridge-host.exe`, or a descriptive error if it can't be found. This - /// will first search alongside `libyabridge.so` and then search through the search path. + /// will first search alongside `libyabridge-vst2.so` and then search through the search path. pub fn yabridge_host_exe(&self) -> Result { - let libyabridge_path = self.libyabridge()?; + let yabridge_path = self.libyabridge_vst2()?; - let yabridge_host_exe_candidate = libyabridge_path.with_file_name(YABRIDGE_HOST_EXE_NAME); + let yabridge_host_exe_candidate = yabridge_path.with_file_name(YABRIDGE_HOST_EXE_NAME); if yabridge_host_exe_candidate.exists() { return Ok(yabridge_host_exe_candidate); } @@ -228,7 +228,7 @@ impl Config { /// Fetch the XDG base directories for yabridge's own files, converting any error messages if this /// somehow fails into a printable string to reduce boiler plate. This is only used when searching -/// for `libyabridge.so` when no explicit search path has been set. +/// for `libyabridge-{vst2,vst3}.so` when no explicit search path has been set. pub fn yabridge_directories() -> Result { BaseDirectories::with_prefix(YABRIDGE_PREFIX).context("Error while parsing base directories") } diff --git a/tools/yabridgectl/src/files.rs b/tools/yabridgectl/src/files.rs index e3aac87e..3544ff34 100644 --- a/tools/yabridgectl/src/files.rs +++ b/tools/yabridgectl/src/files.rs @@ -47,8 +47,8 @@ pub enum FoundFile { } impl SearchResults { - /// For every found VST2 plugin, find the associated copy or symlink of `libyabridge.so`. The - /// returned hashmap will contain a `None` value for plugins that have not yet been set up. + /// For every found VST2 plugin, find the associated copy or symlink of `libyabridge-vst2.so`. + /// The returned hashmap will contain a `None` value for plugins that have not yet been set up. /// /// These two functions could be combined into a single function, but speed isn't really an /// issue here and it's a bit more organized this way. diff --git a/tools/yabridgectl/src/main.rs b/tools/yabridgectl/src/main.rs index 649ce4e6..b21fc8cd 100644 --- a/tools/yabridgectl/src/main.rs +++ b/tools/yabridgectl/src/main.rs @@ -99,10 +99,10 @@ fn main() -> Result<()> { .arg( Arg::with_name("path") .long("path") - .about("Path to the directory containing 'libyabridge.so'") + .about("Path to the directory containing 'libyabridge-{vst2,vst3}.so'") .long_about( - "Path to the directory containing 'libyabridge.so'. If this is \ - not set, then yabridgectl will look in both '/usr/lib' and \ + "Path to the directory containing 'libyabridge-{vst2,vst3}.so'. If this \ + is not set, then yabridgectl will look in both '/usr/lib' and \ '~/.local/share/yabridge' by default.", ) .validator(validate_path) diff --git a/tools/yabridgectl/src/utils.rs b/tools/yabridgectl/src/utils.rs index 736015a6..3e241a2a 100644 --- a/tools/yabridgectl/src/utils.rs +++ b/tools/yabridgectl/src/utils.rs @@ -179,7 +179,7 @@ pub fn verify_path_setup(config: &Config) -> Result { reboot your system to complete the setup.\n\ \n\ https://github.com/robbert-vdh/yabridge#troubleshooting-common-issues", - config.libyabridge()?.parent().unwrap().display(), + config.libyabridge_vst2()?.parent().unwrap().display(), shell.bright_white(), "PATH".bright_white() ))