The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

689 lines
23KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. #include "../../Application/jucer_Headers.h"
  14. #include "../../ProjectSaving/jucer_ProjectSaver.h"
  15. #include "../../ProjectSaving/jucer_ProjectExport_Xcode.h"
  16. #include "../../Application/jucer_Application.h"
  17. //==============================================================================
  18. LibraryModule::LibraryModule (const ModuleDescription& d)
  19. : moduleInfo (d)
  20. {
  21. }
  22. void LibraryModule::writeIncludes (ProjectSaver& projectSaver, OutputStream& out)
  23. {
  24. auto& project = projectSaver.getProject();
  25. auto& modules = project.getEnabledModules();
  26. auto moduleID = getID();
  27. if (modules.shouldCopyModuleFilesLocally (moduleID))
  28. {
  29. auto juceModuleFolder = moduleInfo.getFolder();
  30. auto localModuleFolder = project.getLocalModuleFolder (moduleID);
  31. localModuleFolder.createDirectory();
  32. projectSaver.copyFolder (juceModuleFolder, localModuleFolder);
  33. }
  34. out << "#include <" << moduleInfo.getModuleFolder().getFileName() << "/"
  35. << moduleInfo.getHeader().getFileName()
  36. << ">" << newLine;
  37. }
  38. void LibraryModule::addSearchPathsToExporter (ProjectExporter& exporter) const
  39. {
  40. auto moduleRelativePath = exporter.getModuleFolderRelativeToProject (getID());
  41. exporter.addToExtraSearchPaths (moduleRelativePath.getParentDirectory());
  42. String libDirPlatform;
  43. if (exporter.isLinux())
  44. libDirPlatform = "Linux";
  45. else if (exporter.isCodeBlocks() && exporter.isWindows())
  46. libDirPlatform = "MinGW";
  47. else
  48. libDirPlatform = exporter.getTargetFolder().getFileName();
  49. auto libSubdirPath = moduleRelativePath.toUnixStyle() + "/libs/" + libDirPlatform;
  50. auto moduleLibDir = File (exporter.getProject().getProjectFolder().getFullPathName() + "/" + libSubdirPath);
  51. if (moduleLibDir.exists())
  52. exporter.addToModuleLibPaths ({ libSubdirPath, moduleRelativePath.getRoot() });
  53. auto extraInternalSearchPaths = moduleInfo.getExtraSearchPaths().trim();
  54. if (extraInternalSearchPaths.isNotEmpty())
  55. {
  56. auto paths = StringArray::fromTokens (extraInternalSearchPaths, true);
  57. for (auto& path : paths)
  58. exporter.addToExtraSearchPaths (moduleRelativePath.getChildFile (path.unquoted()));
  59. }
  60. }
  61. void LibraryModule::addDefinesToExporter (ProjectExporter& exporter) const
  62. {
  63. auto extraDefs = moduleInfo.getPreprocessorDefs().trim();
  64. if (extraDefs.isNotEmpty())
  65. exporter.getExporterPreprocessorDefsValue() = exporter.getExporterPreprocessorDefsString() + "\n" + extraDefs;
  66. }
  67. void LibraryModule::addCompileUnitsToExporter (ProjectExporter& exporter, ProjectSaver& projectSaver) const
  68. {
  69. auto& project = exporter.getProject();
  70. auto& modules = project.getEnabledModules();
  71. auto moduleID = getID();
  72. auto localModuleFolder = modules.shouldCopyModuleFilesLocally (moduleID) ? project.getLocalModuleFolder (moduleID)
  73. : moduleInfo.getFolder();
  74. Array<File> compiled;
  75. findAndAddCompiledUnits (exporter, &projectSaver, compiled);
  76. if (modules.shouldShowAllModuleFilesInProject (moduleID))
  77. addBrowseableCode (exporter, compiled, localModuleFolder);
  78. }
  79. void LibraryModule::addLibsToExporter (ProjectExporter& exporter) const
  80. {
  81. auto parseAndAddLibsToList = [] (StringArray& libList, const String& libs)
  82. {
  83. libList.addTokens (libs, ", ", {});
  84. libList.trim();
  85. libList.removeDuplicates (false);
  86. };
  87. auto& project = exporter.getProject();
  88. if (exporter.isXcode())
  89. {
  90. auto& xcodeExporter = dynamic_cast<XcodeProjectExporter&> (exporter);
  91. if (project.isAUPluginHost())
  92. {
  93. xcodeExporter.xcodeFrameworks.add ("CoreAudioKit");
  94. if (xcodeExporter.isOSX())
  95. xcodeExporter.xcodeFrameworks.add ("AudioUnit");
  96. }
  97. auto frameworks = moduleInfo.getModuleInfo() [xcodeExporter.isOSX() ? "OSXFrameworks" : "iOSFrameworks"].toString();
  98. xcodeExporter.xcodeFrameworks.addTokens (frameworks, ", ", {});
  99. parseAndAddLibsToList (xcodeExporter.xcodeLibs, moduleInfo.getModuleInfo() [exporter.isOSX() ? "OSXLibs" : "iOSLibs"].toString());
  100. }
  101. else if (exporter.isLinux())
  102. {
  103. parseAndAddLibsToList (exporter.linuxLibs, moduleInfo.getModuleInfo() ["linuxLibs"].toString());
  104. parseAndAddLibsToList (exporter.linuxPackages, moduleInfo.getModuleInfo() ["linuxPackages"].toString());
  105. }
  106. else if (exporter.isWindows())
  107. {
  108. if (exporter.isCodeBlocks())
  109. parseAndAddLibsToList (exporter.mingwLibs, moduleInfo.getModuleInfo() ["mingwLibs"].toString());
  110. else
  111. parseAndAddLibsToList (exporter.windowsLibs, moduleInfo.getModuleInfo() ["windowsLibs"].toString());
  112. }
  113. else if (exporter.isAndroid())
  114. {
  115. parseAndAddLibsToList (exporter.androidLibs, moduleInfo.getModuleInfo() ["androidLibs"].toString());
  116. }
  117. }
  118. void LibraryModule::addSettingsForModuleToExporter (ProjectExporter& exporter, ProjectSaver& projectSaver) const
  119. {
  120. addSearchPathsToExporter (exporter);
  121. addDefinesToExporter (exporter);
  122. addCompileUnitsToExporter (exporter, projectSaver);
  123. addLibsToExporter (exporter);
  124. }
  125. void LibraryModule::getConfigFlags (Project& project, OwnedArray<Project::ConfigFlag>& flags) const
  126. {
  127. auto header = moduleInfo.getHeader();
  128. jassert (header.exists());
  129. StringArray lines;
  130. header.readLines (lines);
  131. for (int i = 0; i < lines.size(); ++i)
  132. {
  133. auto line = lines[i].trim();
  134. if (line.startsWith ("/**") && line.containsIgnoreCase ("Config:"))
  135. {
  136. auto config = std::make_unique<Project::ConfigFlag>();
  137. config->sourceModuleID = getID();
  138. config->symbol = line.fromFirstOccurrenceOf (":", false, false).trim();
  139. if (config->symbol.length() > 2)
  140. {
  141. ++i;
  142. while (! (lines[i].contains ("*/") || lines[i].contains ("@see")))
  143. {
  144. if (lines[i].trim().isNotEmpty())
  145. config->description = config->description.trim() + " " + lines[i].trim();
  146. ++i;
  147. }
  148. config->description = config->description.upToFirstOccurrenceOf ("*/", false, false);
  149. config->value = project.getConfigFlag (config->symbol);
  150. i += 2;
  151. if (lines[i].contains ("#define " + config->symbol))
  152. {
  153. auto value = lines[i].fromFirstOccurrenceOf ("#define " + config->symbol, false, true).trim();
  154. config->value.setDefault (value == "0" ? false : true);
  155. }
  156. auto currentValue = config->value.get().toString();
  157. if (currentValue == "enabled") config->value = true;
  158. else if (currentValue == "disabled") config->value = false;
  159. flags.add (std::move (config));
  160. }
  161. }
  162. }
  163. }
  164. static void addFileWithGroups (Project::Item& group, const build_tools::RelativePath& file, const String& path)
  165. {
  166. auto slash = path.indexOfChar (File::getSeparatorChar());
  167. if (slash >= 0)
  168. {
  169. auto topLevelGroup = path.substring (0, slash);
  170. auto remainingPath = path.substring (slash + 1);
  171. auto newGroup = group.getOrCreateSubGroup (topLevelGroup);
  172. addFileWithGroups (newGroup, file, remainingPath);
  173. }
  174. else
  175. {
  176. if (! group.containsChildForFile (file))
  177. group.addRelativeFile (file, -1, false);
  178. }
  179. }
  180. struct FileSorter
  181. {
  182. static int compareElements (const File& f1, const File& f2)
  183. {
  184. return f1.getFileName().compareNatural (f2.getFileName());
  185. }
  186. };
  187. void LibraryModule::findBrowseableFiles (const File& folder, Array<File>& filesFound) const
  188. {
  189. Array<File> tempList;
  190. FileSorter sorter;
  191. for (const auto& iter : RangedDirectoryIterator (folder, true, "*", File::findFiles))
  192. if (! iter.isHidden() && iter.getFile().hasFileExtension (browseableFileExtensions))
  193. tempList.addSorted (sorter, iter.getFile());
  194. filesFound.addArray (tempList);
  195. }
  196. bool LibraryModule::CompileUnit::isNeededForExporter (ProjectExporter& exporter) const
  197. {
  198. if ((hasSuffix (file, "_OSX") && ! exporter.isOSX())
  199. || (hasSuffix (file, "_iOS") && ! exporter.isiOS())
  200. || (hasSuffix (file, "_Windows") && ! exporter.isWindows())
  201. || (hasSuffix (file, "_Linux") && ! exporter.isLinux())
  202. || (hasSuffix (file, "_Android") && ! exporter.isAndroid()))
  203. return false;
  204. auto targetType = Project::getTargetTypeFromFilePath (file, false);
  205. if (targetType != build_tools::ProjectType::Target::unspecified && ! exporter.shouldBuildTargetType (targetType))
  206. return false;
  207. return exporter.usesMMFiles() ? isCompiledForObjC
  208. : isCompiledForNonObjC;
  209. }
  210. String LibraryModule::CompileUnit::getFilenameForProxyFile() const
  211. {
  212. return "include_" + file.getFileName();
  213. }
  214. bool LibraryModule::CompileUnit::hasSuffix (const File& f, const char* suffix)
  215. {
  216. auto fileWithoutSuffix = f.getFileNameWithoutExtension() + ".";
  217. return fileWithoutSuffix.containsIgnoreCase (suffix + String ("."))
  218. || fileWithoutSuffix.containsIgnoreCase (suffix + String ("_"));
  219. }
  220. Array<LibraryModule::CompileUnit> LibraryModule::getAllCompileUnits (build_tools::ProjectType::Target::Type forTarget) const
  221. {
  222. auto files = getFolder().findChildFiles (File::findFiles, false);
  223. FileSorter sorter;
  224. files.sort (sorter);
  225. Array<LibraryModule::CompileUnit> units;
  226. for (auto& file : files)
  227. {
  228. if (file.getFileName().startsWithIgnoreCase (getID())
  229. && file.hasFileExtension (sourceFileExtensions))
  230. {
  231. if (forTarget == build_tools::ProjectType::Target::unspecified
  232. || forTarget == Project::getTargetTypeFromFilePath (file, true))
  233. {
  234. CompileUnit cu;
  235. cu.file = file;
  236. units.add (std::move (cu));
  237. }
  238. }
  239. }
  240. for (auto& cu : units)
  241. {
  242. cu.isCompiledForObjC = true;
  243. cu.isCompiledForNonObjC = ! cu.file.hasFileExtension ("mm;m");
  244. if (cu.isCompiledForNonObjC)
  245. if (cu.file.withFileExtension ("mm").existsAsFile())
  246. cu.isCompiledForObjC = false;
  247. jassert (cu.isCompiledForObjC || cu.isCompiledForNonObjC);
  248. }
  249. return units;
  250. }
  251. void LibraryModule::findAndAddCompiledUnits (ProjectExporter& exporter,
  252. ProjectSaver* projectSaver,
  253. Array<File>& result,
  254. build_tools::ProjectType::Target::Type forTarget) const
  255. {
  256. for (auto& cu : getAllCompileUnits (forTarget))
  257. {
  258. if (cu.isNeededForExporter (exporter))
  259. {
  260. auto localFile = exporter.getProject().getGeneratedCodeFolder()
  261. .getChildFile (cu.getFilenameForProxyFile());
  262. result.add (localFile);
  263. if (projectSaver != nullptr)
  264. projectSaver->addFileToGeneratedGroup (localFile);
  265. }
  266. }
  267. }
  268. void LibraryModule::addBrowseableCode (ProjectExporter& exporter, const Array<File>& compiled, const File& localModuleFolder) const
  269. {
  270. if (sourceFiles.isEmpty())
  271. findBrowseableFiles (localModuleFolder, sourceFiles);
  272. auto sourceGroup = Project::Item::createGroup (exporter.getProject(), getID(), "__mainsourcegroup" + getID(), false);
  273. auto moduleFromProject = exporter.getModuleFolderRelativeToProject (getID());
  274. auto moduleHeader = moduleInfo.getHeader();
  275. auto& project = exporter.getProject();
  276. if (project.getEnabledModules().shouldCopyModuleFilesLocally (getID()))
  277. moduleHeader = project.getLocalModuleFolder (getID()).getChildFile (moduleHeader.getFileName());
  278. auto isModuleHeader = [&] (const File& f) { return f.getFileName() == moduleHeader.getFileName(); };
  279. for (auto& sourceFile : sourceFiles)
  280. {
  281. auto pathWithinModule = build_tools::getRelativePathFrom (sourceFile, localModuleFolder);
  282. // (Note: in exporters like MSVC we have to avoid adding the same file twice, even if one of those instances
  283. // is flagged as being excluded from the build, because this overrides the other and it fails to compile)
  284. if ((exporter.canCopeWithDuplicateFiles() || ! compiled.contains (sourceFile)) && ! isModuleHeader (sourceFile))
  285. addFileWithGroups (sourceGroup, moduleFromProject.getChildFile (pathWithinModule), pathWithinModule);
  286. }
  287. sourceGroup.sortAlphabetically (true, true);
  288. sourceGroup.addFileAtIndex (moduleHeader, -1, false);
  289. exporter.getModulesGroup().state.appendChild (sourceGroup.state.createCopy(), nullptr);
  290. }
  291. //==============================================================================
  292. EnabledModulesList::EnabledModulesList (Project& p, const ValueTree& s)
  293. : project (p), state (s)
  294. {
  295. }
  296. StringArray EnabledModulesList::getAllModules() const
  297. {
  298. StringArray moduleIDs;
  299. for (int i = 0; i < getNumModules(); ++i)
  300. moduleIDs.add (getModuleID (i));
  301. return moduleIDs;
  302. }
  303. void EnabledModulesList::createRequiredModules (OwnedArray<LibraryModule>& modules)
  304. {
  305. for (int i = 0; i < getNumModules(); ++i)
  306. modules.add (new LibraryModule (getModuleInfo (getModuleID (i))));
  307. }
  308. void EnabledModulesList::sortAlphabetically()
  309. {
  310. struct ModuleTreeSorter
  311. {
  312. static int compareElements (const ValueTree& m1, const ValueTree& m2)
  313. {
  314. return m1[Ids::ID].toString().compareIgnoreCase (m2[Ids::ID]);
  315. }
  316. };
  317. ModuleTreeSorter sorter;
  318. state.sort (sorter, getUndoManager(), false);
  319. }
  320. File EnabledModulesList::getDefaultModulesFolder() const
  321. {
  322. File globalPath (getAppSettings().getStoredPath (Ids::defaultJuceModulePath, TargetOS::getThisOS()).get().toString());
  323. if (globalPath.exists())
  324. return globalPath;
  325. for (auto& exporterPathModule : project.getExporterPathsModulesList().getAllModules())
  326. {
  327. auto f = exporterPathModule.second;
  328. if (f.isDirectory())
  329. return f.getParentDirectory();
  330. }
  331. return File::getCurrentWorkingDirectory();
  332. }
  333. ModuleDescription EnabledModulesList::getModuleInfo (const String& moduleID) const
  334. {
  335. return ModuleDescription (project.getModuleWithID (moduleID).second);
  336. }
  337. bool EnabledModulesList::isModuleEnabled (const String& moduleID) const
  338. {
  339. return state.getChildWithProperty (Ids::ID, moduleID).isValid();
  340. }
  341. static void getDependencies (Project& project, const String& moduleID, StringArray& dependencies)
  342. {
  343. auto info = project.getEnabledModules().getModuleInfo (moduleID);
  344. for (auto uid : info.getDependencies())
  345. {
  346. if (! dependencies.contains (uid, true))
  347. {
  348. dependencies.add (uid);
  349. getDependencies (project, uid, dependencies);
  350. }
  351. }
  352. }
  353. StringArray EnabledModulesList::getExtraDependenciesNeeded (const String& moduleID) const
  354. {
  355. StringArray dependencies, extraDepsNeeded;
  356. getDependencies (project, moduleID, dependencies);
  357. for (auto dep : dependencies)
  358. if (dep != moduleID && ! isModuleEnabled (dep))
  359. extraDepsNeeded.add (dep);
  360. return extraDepsNeeded;
  361. }
  362. bool EnabledModulesList::tryToFixMissingDependencies (const String& moduleID)
  363. {
  364. auto copyLocally = areMostModulesCopiedLocally();
  365. auto useGlobalPath = areMostModulesUsingGlobalPath();
  366. StringArray missing;
  367. for (auto missingModule : getExtraDependenciesNeeded (moduleID))
  368. {
  369. auto mod = project.getModuleWithID (missingModule);
  370. if (mod.second != File())
  371. addModule (mod.second, copyLocally, useGlobalPath);
  372. else
  373. missing.add (missingModule);
  374. }
  375. return (missing.size() == 0);
  376. }
  377. bool EnabledModulesList::doesModuleHaveHigherCppStandardThanProject (const String& moduleID) const
  378. {
  379. auto projectCppStandard = project.getCppStandardString();
  380. if (projectCppStandard == Project::getCppStandardVars().getLast().toString())
  381. return false;
  382. auto moduleCppStandard = getModuleInfo (moduleID).getMinimumCppStandard();
  383. return (moduleCppStandard.getIntValue() > projectCppStandard.getIntValue());
  384. }
  385. bool EnabledModulesList::shouldUseGlobalPath (const String& moduleID) const
  386. {
  387. return (bool) shouldUseGlobalPathValue (moduleID).getValue();
  388. }
  389. Value EnabledModulesList::shouldUseGlobalPathValue (const String& moduleID) const
  390. {
  391. return state.getChildWithProperty (Ids::ID, moduleID)
  392. .getPropertyAsValue (Ids::useGlobalPath, getUndoManager());
  393. }
  394. bool EnabledModulesList::shouldShowAllModuleFilesInProject (const String& moduleID) const
  395. {
  396. return (bool) shouldShowAllModuleFilesInProjectValue (moduleID).getValue();
  397. }
  398. Value EnabledModulesList::shouldShowAllModuleFilesInProjectValue (const String& moduleID) const
  399. {
  400. return state.getChildWithProperty (Ids::ID, moduleID)
  401. .getPropertyAsValue (Ids::showAllCode, getUndoManager());
  402. }
  403. bool EnabledModulesList::shouldCopyModuleFilesLocally (const String& moduleID) const
  404. {
  405. return (bool) shouldCopyModuleFilesLocallyValue (moduleID).getValue();
  406. }
  407. Value EnabledModulesList::shouldCopyModuleFilesLocallyValue (const String& moduleID) const
  408. {
  409. return state.getChildWithProperty (Ids::ID, moduleID)
  410. .getPropertyAsValue (Ids::useLocalCopy, getUndoManager());
  411. }
  412. bool EnabledModulesList::areMostModulesUsingGlobalPath() const
  413. {
  414. int numYes = 0, numNo = 0;
  415. for (auto i = getNumModules(); --i >= 0;)
  416. {
  417. if (shouldUseGlobalPath (getModuleID (i)))
  418. ++numYes;
  419. else
  420. ++numNo;
  421. }
  422. return numYes > numNo;
  423. }
  424. bool EnabledModulesList::areMostModulesCopiedLocally() const
  425. {
  426. int numYes = 0, numNo = 0;
  427. for (auto i = getNumModules(); --i >= 0;)
  428. {
  429. if (shouldCopyModuleFilesLocally (getModuleID (i)))
  430. ++numYes;
  431. else
  432. ++numNo;
  433. }
  434. return numYes > numNo;
  435. }
  436. StringArray EnabledModulesList::getModulesWithHigherCppStandardThanProject() const
  437. {
  438. StringArray list;
  439. for (auto& module : getAllModules())
  440. if (doesModuleHaveHigherCppStandardThanProject (module))
  441. list.add (module);
  442. return list;
  443. }
  444. StringArray EnabledModulesList::getModulesWithMissingDependencies() const
  445. {
  446. StringArray list;
  447. for (auto& module : getAllModules())
  448. if (getExtraDependenciesNeeded (module).size() > 0)
  449. list.add (module);
  450. return list;
  451. }
  452. String EnabledModulesList::getHighestModuleCppStandard() const
  453. {
  454. auto highestCppStandard = Project::getCppStandardVars()[0].toString();
  455. for (auto& mod : getAllModules())
  456. {
  457. auto moduleCppStandard = getModuleInfo (mod).getMinimumCppStandard();
  458. if (moduleCppStandard == "latest")
  459. return moduleCppStandard;
  460. if (moduleCppStandard.getIntValue() > highestCppStandard.getIntValue())
  461. highestCppStandard = moduleCppStandard;
  462. }
  463. return highestCppStandard;
  464. }
  465. void EnabledModulesList::addModule (const File& moduleFolder, bool copyLocally, bool useGlobalPath)
  466. {
  467. ModuleDescription info (moduleFolder);
  468. if (info.isValid())
  469. {
  470. auto moduleID = info.getID();
  471. if (! isModuleEnabled (moduleID))
  472. {
  473. ValueTree module (Ids::MODULE);
  474. module.setProperty (Ids::ID, moduleID, getUndoManager());
  475. state.appendChild (module, getUndoManager());
  476. sortAlphabetically();
  477. shouldShowAllModuleFilesInProjectValue (moduleID) = true;
  478. shouldCopyModuleFilesLocallyValue (moduleID) = copyLocally;
  479. shouldUseGlobalPathValue (moduleID) = useGlobalPath;
  480. build_tools::RelativePath path (moduleFolder.getParentDirectory(),
  481. project.getProjectFolder(),
  482. build_tools::RelativePath::projectFolder);
  483. for (Project::ExporterIterator exporter (project); exporter.next();)
  484. exporter->getPathForModuleValue (moduleID) = path.toUnixStyle();
  485. if (! useGlobalPath)
  486. project.rescanExporterPathModules (false);
  487. }
  488. }
  489. }
  490. void EnabledModulesList::addModuleInteractive (const String& moduleID)
  491. {
  492. auto f = project.getModuleWithID (moduleID).second;
  493. if (f != File())
  494. {
  495. addModule (f, areMostModulesCopiedLocally(), areMostModulesUsingGlobalPath());
  496. return;
  497. }
  498. addModuleFromUserSelectedFile();
  499. }
  500. void EnabledModulesList::addModuleFromUserSelectedFile()
  501. {
  502. auto lastLocation = getDefaultModulesFolder();
  503. FileChooser fc ("Select a module to add...", lastLocation, {});
  504. if (fc.browseForDirectory())
  505. {
  506. lastLocation = fc.getResult();
  507. addModuleOfferingToCopy (lastLocation, true);
  508. }
  509. }
  510. void EnabledModulesList::addModuleOfferingToCopy (const File& f, bool isFromUserSpecifiedFolder)
  511. {
  512. ModuleDescription m (f);
  513. if (! m.isValid())
  514. {
  515. AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
  516. "Add Module", "This wasn't a valid module folder!");
  517. return;
  518. }
  519. if (isModuleEnabled (m.getID()))
  520. {
  521. AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
  522. "Add Module", "The project already contains this module!");
  523. return;
  524. }
  525. addModule (m.getModuleFolder(), areMostModulesCopiedLocally(),
  526. isFromUserSpecifiedFolder ? false : areMostModulesUsingGlobalPath());
  527. }
  528. void EnabledModulesList::removeModule (String moduleID) // must be pass-by-value, and not a const ref!
  529. {
  530. for (auto i = state.getNumChildren(); --i >= 0;)
  531. if (state.getChild(i) [Ids::ID] == moduleID)
  532. state.removeChild (i, getUndoManager());
  533. for (Project::ExporterIterator exporter (project); exporter.next();)
  534. exporter->removePathForModule (moduleID);
  535. }