mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
[yabridgectl] Add option for VST2 install location
This commit is contained in:
@@ -23,7 +23,7 @@ use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
use crate::config::{yabridge_vst3_home, Config, YabridgeFiles};
|
||||
use crate::config::{yabridge_vst3_home, Config, Vst2InstallationLocation, YabridgeFiles};
|
||||
use crate::files::{self, NativeFile, Plugin, Vst2Plugin};
|
||||
use crate::utils::{self, get_file_type};
|
||||
use crate::utils::{verify_path_setup, verify_wine_setup};
|
||||
@@ -182,9 +182,10 @@ pub fn show_status(config: &Config) -> Result<()> {
|
||||
}
|
||||
|
||||
/// Options passed to `yabridgectl set`, see `main()` for the definitions of these options.
|
||||
pub struct SetOptions {
|
||||
pub struct SetOptions<'a> {
|
||||
pub path: Option<PathBuf>,
|
||||
pub path_auto: bool,
|
||||
pub vst2_location: Option<&'a str>,
|
||||
pub no_verify: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -198,6 +199,13 @@ pub fn set_settings(config: &mut Config, options: &SetOptions) -> Result<()> {
|
||||
config.yabridge_home = None;
|
||||
}
|
||||
|
||||
match options.vst2_location {
|
||||
Some("centralized") => config.vst2_location = Vst2InstallationLocation::Centralized,
|
||||
Some("inline") => config.vst2_location = Vst2InstallationLocation::Inline,
|
||||
Some(s) => unimplemented!("Unexpected installation method '{}'", s),
|
||||
None => (),
|
||||
}
|
||||
|
||||
if let Some(no_verify) = options.no_verify {
|
||||
config.no_verify = no_verify;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,9 @@ pub struct Config {
|
||||
/// Files/Common/VST3`). We're using an ordered set here out of convenience so we can't get
|
||||
/// duplicates and the config file is always sorted.
|
||||
pub plugin_dirs: BTreeSet<PathBuf>,
|
||||
/// Where VST2 plugins are setup. This can be either in `~/.vst/yabridge` or inline with the
|
||||
/// plugin's .dll` files.`
|
||||
pub vst2_location: Vst2InstallationLocation,
|
||||
/// Always skip post-installation setup checks. This can be set temporarily by passing the
|
||||
/// `--no-verify` option to `yabridgectl sync`.
|
||||
pub no_verify: bool,
|
||||
@@ -82,6 +85,21 @@ pub struct Config {
|
||||
pub last_known_config: Option<KnownConfig>,
|
||||
}
|
||||
|
||||
/// Determines where VST2 plugins are set up. They can either be set up in `~/.vst/yabridge` by
|
||||
/// creating `libyabridge-chainloader-vst2.so` copies there and symlinking the Windows VST2 plugin
|
||||
/// `.dll` files right next to it, or those copies can be made right next to the orignal plugin
|
||||
/// files.
|
||||
#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone, Copy)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum Vst2InstallationLocation {
|
||||
/// Set up the plugins in `~/.vst/yabridge`. The downside of this approach is that you cannot
|
||||
/// have multiple plugins with the same name being provided by multiple directories or prefixes.
|
||||
/// That might be useful for debugging purposes.
|
||||
Centralized,
|
||||
/// Create the `.so` files right next to the original VST2 plugins.
|
||||
Inline,
|
||||
}
|
||||
|
||||
/// Stores information about a combination of Wine and yabridge that works together properly.
|
||||
/// Whenever we encounter a new version of Wine or yabridge, we'll check whether `yabridge-host.exe`
|
||||
/// can run without issues. This is needed because older versions of Wine won't be able to run newer
|
||||
@@ -129,6 +147,12 @@ pub struct YabridgeFiles {
|
||||
pub yabridge_host_32_exe_so: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl Default for Vst2InstallationLocation {
|
||||
fn default() -> Self {
|
||||
Vst2InstallationLocation::Centralized
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
/// Try to read the config file, creating a new default file if necessary. This will fail if the
|
||||
/// file could not be created or if it could not be parsed.
|
||||
|
||||
@@ -143,6 +143,21 @@ fn main() -> Result<()> {
|
||||
setting a path with the '--path' option to revert back to the default \
|
||||
auto detection behaviour.",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("vst2_location")
|
||||
.long("vst2-location")
|
||||
.help("Where to set up VST2 plugins")
|
||||
.long_help(format!(
|
||||
"Where to set up VST2 plugins. \
|
||||
'{}' (the default) causes bridged VST2 plugins to be set up in `~/.vst/yabridge.` \
|
||||
'{}' causes bridged VST2 plugins to be set up next to the original '.dll' file.",
|
||||
"centralized".bright_white(),
|
||||
"inline".bright_white()
|
||||
).as_ref())
|
||||
.setting(clap::ArgSettings::NextLineHelp)
|
||||
.possible_values(["centralized", "inline"])
|
||||
.takes_value(true),
|
||||
).arg(
|
||||
Arg::new("no_verify")
|
||||
.long("no-verify")
|
||||
@@ -249,6 +264,7 @@ fn main() -> Result<()> {
|
||||
.ok()
|
||||
.and_then(|path| path.canonicalize().ok()),
|
||||
path_auto: options.is_present("path_auto"),
|
||||
vst2_location: options.value_of("vst2_location"),
|
||||
no_verify: options.value_of("no_verify").map(|value| value == "true"),
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user