Update yabridgectl for libyabridge-vst2.so

This commit is contained in:
Robbert van der Helm
2020-11-28 13:17:33 +01:00
parent c6eb55dc6d
commit a428d08eff
6 changed files with 43 additions and 38 deletions
+13 -13
View File
@@ -96,9 +96,9 @@ pub fn show_status(config: &Config) -> Result<()> {
.unwrap_or_else(|| String::from("<auto>"))
);
println!(
"libyabridge.so: {}",
"libyabridge-vst2.so: {}",
config
.libyabridge()
.libyabridge_vst2()
.map(|path| format!("'{}'", path.display()))
.unwrap_or_else(|_| format!("{}", "<not found>".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)?;
}
}
+14 -14
View File
@@ -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<PathBuf> {
pub fn libyabridge_vst2(&self) -> Result<PathBuf> {
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=<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<PathBuf> {
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> {
BaseDirectories::with_prefix(YABRIDGE_PREFIX).context("Error while parsing base directories")
}
+2 -2
View File
@@ -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.
+3 -3
View File
@@ -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)
+1 -1
View File
@@ -179,7 +179,7 @@ pub fn verify_path_setup(config: &Config) -> Result<bool> {
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()
))