1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-16 00:34:19 +00:00

Projucer: Try to get path from compatible exporters first when getting module folder

This commit is contained in:
ed 2017-12-28 15:50:31 +00:00
parent 617a8e77af
commit 07ddc94d51
2 changed files with 49 additions and 22 deletions

View file

@ -201,6 +201,48 @@ Result ModuleList::addAllModulesInSubfoldersRecursively (const File& path, int d
return Result::ok();
}
static File getModuleFolderFromPathIfItExists (const String& path, const String& moduleID, const Project& project)
{
if (path.isNotEmpty())
{
auto moduleFolder = project.resolveFilename (path);
if (moduleFolder.exists())
{
if (ModuleDescription (moduleFolder).getID() == moduleID)
return moduleFolder;
auto f = moduleFolder.getChildFile (moduleID);
if (ModuleDescription (f).getID() == moduleID)
return f;
}
}
return {};
}
static File getPathToSpecifiedModule (Project& project, StringRef moduleID)
{
auto& modules = project.getModules();
if (! modules.shouldUseGlobalPath (moduleID))
{
for (Project::ExporterIterator exporter (project); exporter.next();)
{
if (! exporter->mayCompileOnCurrentOS())
continue;
auto path = getModuleFolderFromPathIfItExists (exporter->getPathForModuleString (moduleID), moduleID, project);
if (path != File())
return path;
}
}
return {};
}
static Array<File> getAllPossibleModulePathsFromExporters (Project& project)
{
StringArray paths;
@ -661,27 +703,6 @@ Value EnabledModuleList::shouldShowAllModuleFilesInProject (const String& module
.getPropertyAsValue (Ids::showAllCode, getUndoManager());
}
File EnabledModuleList::getModuleFolderFromPathIfItExists (const String& path, const String& moduleID, const Project& project)
{
if (path.isNotEmpty())
{
auto moduleFolder = project.resolveFilename (path);
if (moduleFolder.exists())
{
if (ModuleDescription (moduleFolder).getID() == moduleID)
return moduleFolder;
auto f = moduleFolder.getChildFile (moduleID);
if (ModuleDescription (f).getID() == moduleID)
return f;
}
}
return {};
}
File EnabledModuleList::findUserModuleFolder (const String& possiblePaths, const String& moduleID)
{
auto paths = StringArray::fromTokens (possiblePaths, ";", {});
@ -710,6 +731,13 @@ File EnabledModuleList::getModuleFolder (const String& moduleID)
return findUserModuleFolder (getAppSettings().getStoredPath (Ids::defaultUserModulePath).toString(), moduleID);
}
{
auto path = getPathToSpecifiedModule (project, moduleID);
if (path != File())
return path;
}
auto paths = getAllPossibleModulePathsFromExporters (project);
for (auto p : paths)
{