1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Projucer: Refactored module scanning code and added AvailableModuleList class for asynchronous scanning

This commit is contained in:
ed 2018-08-23 14:15:28 +01:00
parent 8632d853e9
commit f77c995b4d
19 changed files with 502 additions and 432 deletions

View file

@ -64,7 +64,7 @@ Project::Project (const File& f)
parsedPreprocessorDefs = parsePreprocessorDefs (preprocessorDefsValue.get());
getModules().sortAlphabetically();
getEnabledModules().sortAlphabetically();
projectRoot.addListener (this);
@ -488,45 +488,33 @@ static int getBuiltJuceVersion()
+ JUCE_BUILDNUMBER;
}
static bool isAnyModuleNewerThanProjucer (const OwnedArray<ModuleDescription>& modules)
static bool isModuleNewerThanProjucer (const ModuleDescription& module)
{
for (auto i = modules.size(); --i >= 0;)
{
auto* m = modules.getUnchecked(i);
if (m->getID().startsWith ("juce_")
&& getJuceVersion (m->getVersion()) > getBuiltJuceVersion())
return true;
}
if (module.getID().startsWith ("juce_")
&& getJuceVersion (module.getVersion()) > getBuiltJuceVersion())
return true;
return false;
}
void Project::warnAboutOldProjucerVersion()
{
ModuleList available;
available.scanGlobalJuceModulePath();
if (! isAnyModuleNewerThanProjucer (available.modules))
available.scanGlobalUserModulePath();
if (! isAnyModuleNewerThanProjucer (available.modules))
available.scanProjectExporterModulePaths (*this);
if (! isAnyModuleNewerThanProjucer (available.modules))
return;
// Projucer is out of date!
if (ProjucerApplication::getApp().isRunningCommandLine)
std::cout << "WARNING! This version of the Projucer is out-of-date!" << std::endl;
else
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
"Projucer",
"This version of the Projucer is out-of-date!"
"\n\n"
"Always make sure that you're running the very latest version, "
"preferably compiled directly from the JUCE repository that you're working with!");
for (auto& juceModule : ProjucerApplication::getApp().getJUCEPathModuleList().getAllModules())
{
if (isModuleNewerThanProjucer ({ juceModule.second }))
{
// Projucer is out of date!
if (ProjucerApplication::getApp().isRunningCommandLine)
std::cout << "WARNING! This version of the Projucer is out-of-date!" << std::endl;
else
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
"Projucer",
"This version of the Projucer is out-of-date!"
"\n\n"
"Always make sure that you're running the very latest version, "
"preferably compiled directly from the JUCE repository that you're working with!");
}
}
}
//==============================================================================
@ -564,7 +552,7 @@ Result Project::loadDocument (const File& file)
registerRecentFile (file);
enabledModulesList.reset();
enabledModuleList.reset();
projectRoot = newTree;
initialiseProjectValues();
@ -586,6 +574,9 @@ Result Project::loadDocument (const File& file)
compileEngineSettings.reset (new CompileEngineSettings (projectRoot));
exporterPathsModuleList.reset (new AvailableModuleList());
rescanExporterPathModules (! ProjucerApplication::getApp().isRunningCommandLine);
return Result::ok();
}
@ -1744,17 +1735,17 @@ String Project::getIAAPluginName()
//==============================================================================
bool Project::isAUPluginHost()
{
return getModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_AU");
return getEnabledModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_AU");
}
bool Project::isVSTPluginHost()
{
return getModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_VST");
return getEnabledModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_VST");
}
bool Project::isVST3PluginHost()
{
return getModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_VST3");
return getEnabledModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_VST3");
}
//==============================================================================
@ -1875,12 +1866,83 @@ Array<var> Project::getDefaultRTASCategories() const noexcept
}
//==============================================================================
EnabledModuleList& Project::getModules()
EnabledModuleList& Project::getEnabledModules()
{
if (enabledModulesList == nullptr)
enabledModulesList.reset (new EnabledModuleList (*this, projectRoot.getOrCreateChildWithName (Ids::MODULES, nullptr)));
if (enabledModuleList == nullptr)
enabledModuleList.reset (new EnabledModuleList (*this, projectRoot.getOrCreateChildWithName (Ids::MODULES, nullptr)));
return *enabledModulesList;
return *enabledModuleList;
}
static Array<File> getAllPossibleModulePathsFromExporters (Project& project)
{
StringArray paths;
for (Project::ExporterIterator exporter (project); exporter.next();)
{
auto& modules = project.getEnabledModules();
auto n = modules.getNumModules();
for (int i = 0; i < n; ++i)
{
auto id = modules.getModuleID (i);
if (modules.shouldUseGlobalPath (id))
continue;
auto path = exporter->getPathForModuleString (id);
if (path.isNotEmpty())
paths.addIfNotAlreadyThere (path);
}
auto oldPath = exporter->getLegacyModulePath();
if (oldPath.isNotEmpty())
paths.addIfNotAlreadyThere (oldPath);
}
Array<File> files;
for (auto& path : paths)
{
auto f = project.resolveFilename (path);
if (f.isDirectory())
{
files.addIfNotAlreadyThere (f);
if (f.getChildFile ("modules").isDirectory())
files.addIfNotAlreadyThere (f.getChildFile ("modules"));
}
}
return files;
}
AvailableModuleList& Project::getExporterPathsModuleList()
{
return *exporterPathsModuleList;
}
void Project::rescanExporterPathModules (bool async)
{
if (async)
exporterPathsModuleList->scanPathsAsync (getAllPossibleModulePathsFromExporters (*this));
else
exporterPathsModuleList->scanPaths (getAllPossibleModulePathsFromExporters (*this));
}
ModuleIDAndFolder Project::getModuleWithID (const String& id)
{
const auto& list = (isJUCEModule (id) ? ProjucerApplication::getApp().getJUCEPathModuleList().getAllModules()
: ProjucerApplication::getApp().getUserPathsModuleList().getAllModules());
for (auto& m : list)
if (m.first == id)
return m;
return exporterPathsModuleList->getModuleWithID (id);
}
//==============================================================================