mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
[yabridgectl] Warn for duplicate VST3 plugins
Since we can't have multiple plugins with the same name this way.
This commit is contained in:
@@ -18,13 +18,12 @@
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use colored::Colorize;
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::config::{yabridge_vst3_home, Config, InstallationMethod, YabridgeFiles};
|
||||
use crate::files;
|
||||
use crate::files::NativeFile;
|
||||
use crate::files::{self, LibArchitecture, NativeFile};
|
||||
use crate::utils;
|
||||
use crate::utils::{verify_path_setup, verify_wine_setup};
|
||||
|
||||
@@ -199,17 +198,11 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> {
|
||||
let mut orphan_files: Vec<NativeFile> = Vec::new();
|
||||
// All the VST3 modules we have set up yabridge for. We need this to detect leftover VST3
|
||||
// modules in `~/.vst3/yabridge`.
|
||||
let mut yabridge_vst3_bundles: BTreeSet<PathBuf> = BTreeSet::new();
|
||||
let mut yabridge_vst3_bundles: BTreeMap<PathBuf, BTreeSet<LibArchitecture>> = BTreeMap::new();
|
||||
for (path, search_results) in results {
|
||||
num_installed += search_results.vst2_files.len();
|
||||
num_installed += search_results.vst3_modules.len();
|
||||
orphan_files.extend(search_results.vst2_orphans().into_iter().cloned());
|
||||
yabridge_vst3_bundles.extend(
|
||||
search_results
|
||||
.vst3_modules
|
||||
.iter()
|
||||
.map(|module| module.yabridge_bundle_home()),
|
||||
);
|
||||
skipped_dll_files.extend(search_results.skipped_files);
|
||||
|
||||
if options.verbose {
|
||||
@@ -241,6 +234,28 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> {
|
||||
// https://steinbergmedia.github.io/vst3_doc/vstinterfaces/vst3loc.html#mergedbundles
|
||||
if let Some(libyabridge_vst3_hash) = libyabridge_vst3_hash {
|
||||
for module in search_results.vst3_modules {
|
||||
// Check if we already set up the same architecture version of the plugin (since
|
||||
// 32-bit and 64-bit versions of the plugin cna live inside of the same bundle), and
|
||||
// show a warning if we come across any duplicates.
|
||||
let already_installed_architectures = yabridge_vst3_bundles
|
||||
.entry(module.yabridge_bundle_home())
|
||||
.or_insert_with(|| BTreeSet::new());
|
||||
if !already_installed_architectures.insert(module.architecture()) {
|
||||
eprintln!(
|
||||
"{}",
|
||||
utils::wrap(&format!(
|
||||
"{}: The {} version of '{}' has already been provided by another Wine \
|
||||
prefix, skipping '{}'\n",
|
||||
"WARNING".red(),
|
||||
module.architecture(),
|
||||
module.yabridge_bundle_home().display(),
|
||||
module.original_module_path().display(),
|
||||
))
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
let native_module_path = module.yabridge_native_module_path();
|
||||
|
||||
// For VST3 plugins we'll first have to create the bundle structure
|
||||
@@ -298,7 +313,7 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> {
|
||||
.filter_map(|path| {
|
||||
// Add all files and directories in `~/.vst3/yabridge` to `orphan_files` if they
|
||||
// are not a VST3 module we just created
|
||||
if !yabridge_vst3_bundles.contains(&path) {
|
||||
if !yabridge_vst3_bundles.contains_key(&path) {
|
||||
utils::get_file_type(path)
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -21,6 +21,7 @@ use anyhow::{Context, Result};
|
||||
use lazy_static::lazy_static;
|
||||
use rayon::prelude::*;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::fmt::Display;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use walkdir::WalkDir;
|
||||
@@ -177,12 +178,21 @@ impl Vst3Module {
|
||||
}
|
||||
|
||||
/// The architecture of a `.dll` file. Needed so we can create a merged bundle for VST3 plugins.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Copy)]
|
||||
pub enum LibArchitecture {
|
||||
Dll32,
|
||||
Dll64,
|
||||
}
|
||||
|
||||
impl Display for LibArchitecture {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match &self {
|
||||
LibArchitecture::Dll32 => write!(f, "32-bit"),
|
||||
LibArchitecture::Dll64 => write!(f, "64-bit"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LibArchitecture {
|
||||
/// Get the corresponding VST3 architecture directory name. See
|
||||
/// https://steinbergmedia.github.io/vst3_doc/vstinterfaces/vst3loc.html.
|
||||
|
||||
Reference in New Issue
Block a user