mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
[yabridgectl] Split up Vst3Module
So we can add easily add additional fields later.
This commit is contained in:
@@ -250,14 +250,14 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> {
|
|||||||
let already_installed_architectures = yabridge_vst3_bundles
|
let already_installed_architectures = yabridge_vst3_bundles
|
||||||
.entry(module.target_bundle_home())
|
.entry(module.target_bundle_home())
|
||||||
.or_insert_with(BTreeSet::new);
|
.or_insert_with(BTreeSet::new);
|
||||||
if !already_installed_architectures.insert(module.architecture()) {
|
if !already_installed_architectures.insert(module.architecture) {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"{}",
|
"{}",
|
||||||
utils::wrap(&format!(
|
utils::wrap(&format!(
|
||||||
"{}: The {} version of '{}' has already been provided by another Wine \
|
"{}: The {} version of '{}' has already been provided by another Wine \
|
||||||
prefix, skipping '{}'\n",
|
prefix, skipping '{}'\n",
|
||||||
"WARNING".red(),
|
"WARNING".red(),
|
||||||
module.architecture(),
|
module.architecture,
|
||||||
module.target_bundle_home().display(),
|
module.target_bundle_home().display(),
|
||||||
module.original_module_path().display(),
|
module.original_module_path().display(),
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -84,39 +84,39 @@ impl NativeFile {
|
|||||||
|
|
||||||
/// VST3 modules we found during a serach.
|
/// VST3 modules we found during a serach.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum Vst3Module {
|
pub struct Vst3Module {
|
||||||
|
/// The actual VST3 module and its type.
|
||||||
|
pub module: Vst3ModuleType,
|
||||||
|
/// The architecture of the `.vst3` file in the module.
|
||||||
|
pub architecture: LibArchitecture,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The type of the VST3 module. VST 3.6.10 style bundles require slightly different handling
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub enum Vst3ModuleType {
|
||||||
/// Old, pre-VST 3.6.10 style `.vst3` modules. These are simply `.dll` files with a different p
|
/// Old, pre-VST 3.6.10 style `.vst3` modules. These are simply `.dll` files with a different p
|
||||||
/// refix. Even though this is a legacy format, almost all VST3 plugins in the wild still use
|
/// refix. Even though this is a legacy format, almost all VST3 plugins in the wild still use
|
||||||
/// this format.
|
/// this format.
|
||||||
Legacy(PathBuf, LibArchitecture),
|
Legacy(PathBuf),
|
||||||
/// A VST 3.6.10 bundle, with the same format as the VST3 bundles used on Linux and macOS. These
|
/// A VST 3.6.10 bundle, with the same format as the VST3 bundles used on Linux and macOS. These
|
||||||
/// kinds of bundles can come with resource files and presets, which should also be symlinked to
|
/// kinds of bundles can come with resource files and presets, which should also be symlinked to
|
||||||
/// `~/.vst3/`
|
/// `~/.vst3/`
|
||||||
Bundle(PathBuf, LibArchitecture),
|
Bundle(PathBuf),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Vst3Module {
|
impl Vst3Module {
|
||||||
/// The architecture of this VST3 module.
|
|
||||||
pub fn architecture(&self) -> LibArchitecture {
|
|
||||||
match &self {
|
|
||||||
Vst3Module::Legacy(_, architecture) | Vst3Module::Bundle(_, architecture) => {
|
|
||||||
*architecture
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the path to the Windows VST3 plugin. This can be either a file or a directory depending
|
/// Get the path to the Windows VST3 plugin. This can be either a file or a directory depending
|
||||||
/// on the type of moudle.
|
/// on the type of moudle.
|
||||||
pub fn original_path(&self) -> &Path {
|
pub fn original_path(&self) -> &Path {
|
||||||
match &self {
|
match &self.module {
|
||||||
Vst3Module::Legacy(path, _) | Vst3Module::Bundle(path, _) => path,
|
Vst3ModuleType::Legacy(path) | Vst3ModuleType::Bundle(path) => path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the name of the module as a string. Should be in the format `Plugin Name.vst3`.
|
/// Get the name of the module as a string. Should be in the format `Plugin Name.vst3`.
|
||||||
pub fn original_module_name(&self) -> &str {
|
pub fn original_module_name(&self) -> &str {
|
||||||
match &self {
|
match &self.module {
|
||||||
Vst3Module::Legacy(path, _) | Vst3Module::Bundle(path, _) => path
|
Vst3ModuleType::Legacy(path) | Vst3ModuleType::Bundle(path) => path
|
||||||
.file_name()
|
.file_name()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
@@ -126,11 +126,11 @@ impl Vst3Module {
|
|||||||
|
|
||||||
/// Get the path to the actual `.vst3` module file.
|
/// Get the path to the actual `.vst3` module file.
|
||||||
pub fn original_module_path(&self) -> PathBuf {
|
pub fn original_module_path(&self) -> PathBuf {
|
||||||
match &self {
|
match &self.module {
|
||||||
Vst3Module::Legacy(path, _) => path.to_owned(),
|
Vst3ModuleType::Legacy(path) => path.to_owned(),
|
||||||
Vst3Module::Bundle(bundle_home, architecture) => {
|
Vst3ModuleType::Bundle(bundle_home) => {
|
||||||
let mut path = bundle_home.join("Contents");
|
let mut path = bundle_home.join("Contents");
|
||||||
path.push(architecture.vst_arch());
|
path.push(self.architecture.vst_arch());
|
||||||
path.push(self.original_module_name());
|
path.push(self.original_module_name());
|
||||||
|
|
||||||
path
|
path
|
||||||
@@ -141,8 +141,8 @@ impl Vst3Module {
|
|||||||
/// If this was a VST 3.6.10 style bundle, then return the path to the `Resources` directory if
|
/// If this was a VST 3.6.10 style bundle, then return the path to the `Resources` directory if
|
||||||
/// it has one.
|
/// it has one.
|
||||||
pub fn original_resources_dir(&self) -> Option<PathBuf> {
|
pub fn original_resources_dir(&self) -> Option<PathBuf> {
|
||||||
match &self {
|
match &self.module {
|
||||||
Vst3Module::Bundle(bundle_home, _) => {
|
Vst3ModuleType::Bundle(bundle_home) => {
|
||||||
let mut path = bundle_home.join("Contents");
|
let mut path = bundle_home.join("Contents");
|
||||||
path.push("Resources");
|
path.push("Resources");
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
@@ -151,7 +151,7 @@ impl Vst3Module {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vst3Module::Legacy(_, _) => None,
|
Vst3ModuleType::Legacy(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,8 +166,8 @@ impl Vst3Module {
|
|||||||
/// Get the path to the `libyabridge.so` file in `~/.vst3` corresponding to the bridged version
|
/// Get the path to the `libyabridge.so` file in `~/.vst3` corresponding to the bridged version
|
||||||
/// of this module.
|
/// of this module.
|
||||||
pub fn target_native_module_path(&self) -> PathBuf {
|
pub fn target_native_module_path(&self) -> PathBuf {
|
||||||
let native_module_name = match &self {
|
let native_module_name = match &self.module {
|
||||||
Vst3Module::Legacy(path, _) | Vst3Module::Bundle(path, _) => path
|
Vst3ModuleType::Legacy(path) | Vst3ModuleType::Bundle(path) => path
|
||||||
.with_extension("so")
|
.with_extension("so")
|
||||||
.file_name()
|
.file_name()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -188,7 +188,7 @@ impl Vst3Module {
|
|||||||
pub fn target_windows_module_path(&self) -> PathBuf {
|
pub fn target_windows_module_path(&self) -> PathBuf {
|
||||||
let mut path = self.target_bundle_home();
|
let mut path = self.target_bundle_home();
|
||||||
path.push("Contents");
|
path.push("Contents");
|
||||||
path.push(self.architecture().vst_arch());
|
path.push(self.architecture.vst_arch());
|
||||||
path.push(self.original_module_name());
|
path.push(self.original_module_name());
|
||||||
path
|
path
|
||||||
}
|
}
|
||||||
@@ -415,12 +415,15 @@ impl SearchIndex {
|
|||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
|
|
||||||
if module_is_in_bundle {
|
if module_is_in_bundle {
|
||||||
Ok(Ok(Vst3Module::Bundle(
|
Ok(Ok(Vst3Module {
|
||||||
bundle_root.unwrap().to_owned(),
|
module: Vst3ModuleType::Bundle(bundle_root.unwrap().to_owned()),
|
||||||
architecture,
|
architecture,
|
||||||
)))
|
}))
|
||||||
} else {
|
} else {
|
||||||
Ok(Ok(Vst3Module::Legacy(module_path, architecture)))
|
Ok(Ok(Vst3Module {
|
||||||
|
module: Vst3ModuleType::Legacy(module_path),
|
||||||
|
architecture,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(Err(module_path))
|
Ok(Err(module_path))
|
||||||
|
|||||||
Reference in New Issue
Block a user