From fa3051fb24019e3805cc9dd22752abcd14c0eda3 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 8 Oct 2020 00:08:52 +0200 Subject: [PATCH] Better version of previous commit (fa3ae33a1fecc) Since the file-modification timestamp of the module-path is used if the cache is up-to-date, the file must exist. For macOS/X bundles the mandatory file as per VST3 spec is Info.plist --- libs/ardour/vst3_module.cc | 3 +-- libs/ardour/vst3_scan.cc | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/libs/ardour/vst3_module.cc b/libs/ardour/vst3_module.cc index e188966d8b..7fe7ca2aba 100644 --- a/libs/ardour/vst3_module.cc +++ b/libs/ardour/vst3_module.cc @@ -49,8 +49,7 @@ class VST3MacModule : public VST3PluginModule public: VST3MacModule (std::string const& module_path) { - std::string path = Glib::path_get_dirname (module_path); // MacOS - path = Glib::path_get_dirname (path); // Contents + std::string path = Glib::path_get_dirname (module_path); // Contents path = Glib::path_get_dirname (path); // theVST.vst3 CFURLRef url = CFURLCreateFromFileSystemRepresentation (0, (const UInt8*)path.c_str (), (CFIndex)path.length (), true); if (url) { diff --git a/libs/ardour/vst3_scan.cc b/libs/ardour/vst3_scan.cc index 9d7b7b0bf1..202c53764a 100644 --- a/libs/ardour/vst3_scan.cc +++ b/libs/ardour/vst3_scan.cc @@ -244,18 +244,23 @@ ARDOUR::module_path_vst3 (string const& path) module_path = Glib::build_filename (path, "Contents", vst3_bindir (), PBD::basename_nosuffix (path) + vst3_suffix ()); } - if (!Glib::file_test (module_path, Glib::FILE_TEST_IS_REGULAR)) { + #ifdef __APPLE__ - if (Glib::file_test (Glib::path_get_dirname (module_path), Glib::FILE_TEST_IS_DIR) && - Glib::file_test (Glib::build_filename (path, "Contents", "Info.plist"), Glib::FILE_TEST_IS_REGULAR)) { - /* Alternatively check for "Contents/MacOS" and an Info.plist file. - * VST3MacModule calls CFBundleCreate() which handles Info.plist files. - * (this is for plugins that use PACE, the MacOS folder usually - * contains a file + "Protect"). - */ - return module_path; - } + /* Check for "Contents/MacOS/" and "Context/Info.plist". + * VST3MacModule calls CFBundleCreate() which handles Info.plist files. + * (on macOS/X the binrary name may differ from the bundle name) + */ + string plist = Glib::build_filename (path, "Contents", "Info.plist"); + if (Glib::file_test (Glib::path_get_dirname (module_path), Glib::FILE_TEST_IS_DIR) && + Glib::file_test (Glib::build_filename (path, "Contents", "Info.plist"), Glib::FILE_TEST_IS_REGULAR)) { + return plist; + } else { + cerr << "VST3 not a valid bundle: '" << path << "'\n"; + return ""; + } #endif + + if (!Glib::file_test (module_path, Glib::FILE_TEST_IS_REGULAR)) { cerr << "VST3 not a valid bundle: '" << module_path << "'\n"; return ""; }