mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
VST3 Client: Update moduleinfotool to write compatibility info from plugin
Reintegrates changes from 06a2089872
This commit is contained in:
parent
ebae624d52
commit
632bdafab7
1 changed files with 35 additions and 0 deletions
|
|
@ -35,6 +35,9 @@
|
|||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "pluginterfaces/base/iplugincompatibility.h"
|
||||
#include "public.sdk/source/common/memorystream.h"
|
||||
|
||||
#include "public.sdk/source/common/readfile.h"
|
||||
#include "public.sdk/source/vst/hosting/module.h"
|
||||
#include "public.sdk/source/vst/moduleinfo/moduleinfocreator.h"
|
||||
|
|
@ -96,6 +99,35 @@ std::optional<ModuleInfo::CompatibilityList> openAndParseCompatJSON (const std::
|
|||
return result;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
std::optional<ModuleInfo::CompatibilityList> loadCompatibilityFromModule (const VST3::Hosting::Module& module)
|
||||
{
|
||||
const auto& factory = module.getFactory();
|
||||
const auto& infos = factory.classInfos();
|
||||
|
||||
const auto iter = std::find_if (infos.begin(), infos.end(), [&] (const auto& info)
|
||||
{
|
||||
return info.category() == kPluginCompatibilityClass;
|
||||
});
|
||||
|
||||
if (iter == infos.end())
|
||||
return {};
|
||||
|
||||
const auto compatibility = factory.createInstance<Steinberg::IPluginCompatibility> (iter->ID());
|
||||
|
||||
if (compatibility == nullptr)
|
||||
return {};
|
||||
|
||||
Steinberg::MemoryStream stream;
|
||||
|
||||
if (compatibility->getCompatibilityJSON (&stream) != kResultOk)
|
||||
return {};
|
||||
|
||||
const std::string_view streamView (stream.getData(), stream.getSize());
|
||||
|
||||
return ModuleInfoLib::parseCompatibilityJson (streamView, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
int createJSON (const std::optional<ModuleInfo::CompatibilityList>& compat,
|
||||
const std::string& modulePath, const std::string& moduleVersion,
|
||||
|
|
@ -111,6 +143,9 @@ int createJSON (const std::optional<ModuleInfo::CompatibilityList>& compat,
|
|||
auto moduleInfo = ModuleInfoLib::createModuleInfo (*module, false);
|
||||
if (compat)
|
||||
moduleInfo.compatibility = *compat;
|
||||
else if (auto loaded = loadCompatibilityFromModule (*module))
|
||||
moduleInfo.compatibility = *loaded;
|
||||
|
||||
moduleInfo.version = moduleVersion;
|
||||
|
||||
std::stringstream output;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue