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.

739 lines
25KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #include "jucer_Module.h"
  19. #include "jucer_ProjectType.h"
  20. #include "../Project Saving/jucer_ProjectExporter.h"
  21. #include "../Project Saving/jucer_ProjectSaver.h"
  22. #include "jucer_AudioPluginModule.h"
  23. //==============================================================================
  24. ModuleList::ModuleList()
  25. {
  26. }
  27. ModuleList::ModuleList (const ModuleList& other)
  28. : moduleFolder (other.moduleFolder)
  29. {
  30. modules.addCopiesOf (other.modules);
  31. }
  32. ModuleList& ModuleList::operator= (const ModuleList& other)
  33. {
  34. moduleFolder = other.moduleFolder;
  35. modules.clear();
  36. modules.addCopiesOf (other.modules);
  37. return *this;
  38. }
  39. bool ModuleList::operator== (const ModuleList& other) const
  40. {
  41. if (modules.size() != other.modules.size())
  42. return false;
  43. for (int i = modules.size(); --i >= 0;)
  44. {
  45. const Module* m1 = modules.getUnchecked(i);
  46. const Module* m2 = other.findModuleInfo (m1->uid);
  47. if (m2 == nullptr || *m1 != *m2)
  48. return false;
  49. }
  50. return true;
  51. }
  52. bool ModuleList::isLocalModulesFolderValid()
  53. {
  54. return isModulesFolder (getModulesFolderForJuceOrModulesFolder (getLocalModulesFolder (nullptr)));
  55. }
  56. bool ModuleList::isJuceFolder (const File& folder)
  57. {
  58. return folder.getFileName().containsIgnoreCase ("juce")
  59. && isModulesFolder (folder.getChildFile ("modules"));
  60. }
  61. bool ModuleList::isModulesFolder (const File& folder)
  62. {
  63. return folder.getFileName().equalsIgnoreCase ("modules")
  64. && folder.isDirectory();
  65. }
  66. bool ModuleList::isJuceOrModulesFolder (const File& folder)
  67. {
  68. return isJuceFolder (folder) || isModulesFolder (folder);
  69. }
  70. File ModuleList::getModulesFolderForJuceOrModulesFolder (const File& f)
  71. {
  72. if (f.getFileName() != "modules" && f.isDirectory() && f.getChildFile ("modules").isDirectory())
  73. return f.getChildFile ("modules");
  74. return f;
  75. }
  76. File ModuleList::getModulesFolderForExporter (const ProjectExporter& exporter)
  77. {
  78. File f (exporter.getProject().resolveFilename (exporter.getJuceFolderString()));
  79. f = getModulesFolderForJuceOrModulesFolder (f);
  80. return f;
  81. }
  82. File ModuleList::getDefaultModulesFolder (Project* project)
  83. {
  84. if (project != nullptr)
  85. {
  86. for (Project::ExporterIterator exporter (*project); exporter.next();)
  87. {
  88. const File f (getModulesFolderForExporter (*exporter));
  89. if (ModuleList::isModulesFolder (f))
  90. return f;
  91. }
  92. }
  93. // Fall back to a default..
  94. #if JUCE_WINDOWS
  95. return File::getSpecialLocation (File::userDocumentsDirectory)
  96. #else
  97. return File::getSpecialLocation (File::userHomeDirectory)
  98. #endif
  99. .getChildFile ("juce")
  100. .getChildFile ("modules");
  101. }
  102. File ModuleList::getLocalModulesFolder (Project* project)
  103. {
  104. File defaultJuceFolder (getDefaultModulesFolder (project));
  105. File f (getGlobalProperties().getValue ("lastJuceFolder", defaultJuceFolder.getFullPathName()));
  106. f = getModulesFolderForJuceOrModulesFolder (f);
  107. if ((! ModuleList::isModulesFolder (f)) && ModuleList::isModulesFolder (defaultJuceFolder))
  108. f = defaultJuceFolder;
  109. return f;
  110. }
  111. void ModuleList::setLocalModulesFolder (const File& file)
  112. {
  113. //jassert (FileHelpers::isJuceFolder (file));
  114. getGlobalProperties().setValue ("lastJuceFolder", file.getFullPathName());
  115. }
  116. struct ModuleSorter
  117. {
  118. static int compareElements (const ModuleList::Module* m1, const ModuleList::Module* m2)
  119. {
  120. return m1->uid.compareIgnoreCase (m2->uid);
  121. }
  122. };
  123. void ModuleList::sort()
  124. {
  125. ModuleSorter sorter;
  126. modules.sort (sorter);
  127. }
  128. void ModuleList::rescan()
  129. {
  130. rescan (moduleFolder);
  131. }
  132. void ModuleList::rescan (const File& newModulesFolder)
  133. {
  134. modules.clear();
  135. moduleFolder = getModulesFolderForJuceOrModulesFolder (newModulesFolder);
  136. if (moduleFolder.isDirectory())
  137. {
  138. DirectoryIterator iter (moduleFolder, false, "*", File::findDirectories);
  139. while (iter.next())
  140. {
  141. const File moduleDef (iter.getFile().getLinkedTarget()
  142. .getChildFile (LibraryModule::getInfoFileName()));
  143. if (moduleDef.exists())
  144. {
  145. LibraryModule m (moduleDef);
  146. jassert (m.isValid());
  147. if (m.isValid())
  148. {
  149. Module* info = new Module();
  150. modules.add (info);
  151. info->uid = m.getID();
  152. info->version = m.getVersion();
  153. info->name = m.moduleInfo ["name"];
  154. info->description = m.moduleInfo ["description"];
  155. info->file = moduleDef;
  156. }
  157. }
  158. }
  159. }
  160. sort();
  161. }
  162. bool ModuleList::loadFromWebsite()
  163. {
  164. modules.clear();
  165. URL baseURL ("http://www.rawmaterialsoftware.com/juce/modules");
  166. URL url (baseURL.getChildURL ("modulelist.php"));
  167. var infoList (JSON::parse (url.readEntireTextStream (false)));
  168. if (infoList.isArray())
  169. {
  170. const Array<var>* moduleList = infoList.getArray();
  171. for (int i = 0; i < moduleList->size(); ++i)
  172. {
  173. const var& m = moduleList->getReference(i);
  174. const String file (m ["file"].toString());
  175. if (file.isNotEmpty())
  176. {
  177. var moduleInfo (m ["info"]);
  178. LibraryModule lm (moduleInfo);
  179. if (lm.isValid())
  180. {
  181. Module* info = new Module();
  182. modules.add (info);
  183. info->uid = lm.getID();
  184. info->version = lm.getVersion();
  185. info->name = lm.getName();
  186. info->description = lm.getDescription();
  187. info->url = baseURL.getChildURL (file);
  188. }
  189. }
  190. }
  191. }
  192. sort();
  193. return infoList.isArray();
  194. }
  195. LibraryModule* ModuleList::Module::create() const
  196. {
  197. return new LibraryModule (file);
  198. }
  199. bool ModuleList::Module::operator== (const Module& other) const
  200. {
  201. return uid == other.uid
  202. && version == other.version
  203. && name == other.name
  204. && description == other.description
  205. && file == other.file
  206. && url == other.url;
  207. }
  208. bool ModuleList::Module::operator!= (const Module& other) const
  209. {
  210. return ! operator== (other);
  211. }
  212. LibraryModule* ModuleList::loadModule (const String& uid) const
  213. {
  214. const Module* const m = findModuleInfo (uid);
  215. return m != nullptr ? m->create() : nullptr;
  216. }
  217. const ModuleList::Module* ModuleList::findModuleInfo (const String& uid) const
  218. {
  219. for (int i = modules.size(); --i >= 0;)
  220. if (modules.getUnchecked(i)->uid == uid)
  221. return modules.getUnchecked(i);
  222. return nullptr;
  223. }
  224. void ModuleList::getDependencies (const String& moduleID, StringArray& dependencies) const
  225. {
  226. ScopedPointer<LibraryModule> m (loadModule (moduleID));
  227. if (m != nullptr)
  228. {
  229. const var depsArray (m->moduleInfo ["dependencies"]);
  230. const Array<var>* const deps = depsArray.getArray();
  231. if (deps != nullptr)
  232. {
  233. for (int i = 0; i < deps->size(); ++i)
  234. {
  235. const var& d = deps->getReference(i);
  236. String uid (d ["id"].toString());
  237. String version (d ["version"].toString());
  238. if (! dependencies.contains (uid, true))
  239. {
  240. dependencies.add (uid);
  241. getDependencies (uid, dependencies);
  242. }
  243. }
  244. }
  245. }
  246. }
  247. void ModuleList::createDependencies (const String& moduleID, OwnedArray<LibraryModule>& modules) const
  248. {
  249. ScopedPointer<LibraryModule> m (loadModule (moduleID));
  250. if (m != nullptr)
  251. {
  252. var depsArray (m->moduleInfo ["dependencies"]);
  253. const Array<var>* const deps = depsArray.getArray();
  254. for (int i = 0; i < deps->size(); ++i)
  255. {
  256. const var& d = deps->getReference(i);
  257. String uid (d ["id"].toString());
  258. String version (d ["version"].toString());
  259. //xxx to do - also need to find version conflicts
  260. jassertfalse
  261. }
  262. }
  263. }
  264. StringArray ModuleList::getExtraDependenciesNeeded (Project& project, const ModuleList::Module& m)
  265. {
  266. StringArray dependencies, extraDepsNeeded;
  267. getDependencies (m.uid, dependencies);
  268. for (int i = 0; i < dependencies.size(); ++i)
  269. if ((! project.isModuleEnabled (dependencies[i])) && dependencies[i] != m.uid)
  270. extraDepsNeeded.add (dependencies[i]);
  271. return extraDepsNeeded;
  272. }
  273. //==============================================================================
  274. LibraryModule::LibraryModule (const File& file)
  275. : moduleInfo (JSON::parse (file)),
  276. moduleFile (file),
  277. moduleFolder (file.getParentDirectory())
  278. {
  279. jassert (isValid());
  280. }
  281. LibraryModule::LibraryModule (const var& moduleInfo_)
  282. : moduleInfo (moduleInfo_)
  283. {
  284. }
  285. bool LibraryModule::isValid() const { return getID().isNotEmpty(); }
  286. bool LibraryModule::isPluginClient() const { return getID() == "juce_audio_plugin_client"; }
  287. bool LibraryModule::isAUPluginHost (const Project& project) const { return getID() == "juce_audio_processors" && project.isConfigFlagEnabled ("JUCE_PLUGINHOST_AU"); }
  288. bool LibraryModule::isVSTPluginHost (const Project& project) const { return getID() == "juce_audio_processors" && project.isConfigFlagEnabled ("JUCE_PLUGINHOST_VST"); }
  289. File LibraryModule::getInclude (const File& folder) const
  290. {
  291. return folder.getChildFile (moduleInfo ["include"]);
  292. }
  293. RelativePath LibraryModule::getModuleRelativeToProject (ProjectExporter& exporter) const
  294. {
  295. RelativePath p (exporter.getJuceFolderString(), RelativePath::projectFolder);
  296. if (p.getFileName() != "modules")
  297. p = p.getChildFile ("modules");
  298. return p.getChildFile (getID());
  299. }
  300. RelativePath LibraryModule::getModuleOrLocalCopyRelativeToProject (ProjectExporter& exporter, const File& localModuleFolder) const
  301. {
  302. if (exporter.getProject().shouldCopyModuleFilesLocally (getID()).getValue())
  303. return RelativePath (exporter.getProject().getRelativePathForFile (localModuleFolder), RelativePath::projectFolder);
  304. return getModuleRelativeToProject (exporter);
  305. }
  306. //==============================================================================
  307. void LibraryModule::writeIncludes (ProjectSaver& projectSaver, OutputStream& out)
  308. {
  309. const File localModuleFolder (projectSaver.getLocalModuleFolder (*this));
  310. const File localHeader (getInclude (localModuleFolder));
  311. if (projectSaver.getProject().shouldCopyModuleFilesLocally (getID()).getValue())
  312. {
  313. projectSaver.copyFolder (moduleFolder, localModuleFolder);
  314. }
  315. else
  316. {
  317. localModuleFolder.createDirectory();
  318. createLocalHeaderWrapper (projectSaver, getInclude (moduleFolder), localHeader);
  319. }
  320. out << CodeHelpers::createIncludeStatement (localHeader, projectSaver.getGeneratedCodeFolder().getChildFile ("AppConfig.h")) << newLine;
  321. }
  322. static void writeGuardedInclude (OutputStream& out, StringArray paths, StringArray guards)
  323. {
  324. StringArray uniquePaths (paths);
  325. uniquePaths.removeDuplicates (false);
  326. if (uniquePaths.size() == 1)
  327. {
  328. out << "#include " << paths[0] << newLine;
  329. }
  330. else
  331. {
  332. int i = paths.size();
  333. for (; --i >= 0;)
  334. {
  335. for (int j = i; --j >= 0;)
  336. {
  337. if (paths[i] == paths[j] && guards[i] == guards[j])
  338. {
  339. paths.remove (i);
  340. guards.remove (i);
  341. }
  342. }
  343. }
  344. for (i = 0; i < paths.size(); ++i)
  345. {
  346. out << (i == 0 ? "#if " : "#elif ") << guards[i] << newLine
  347. << " #include " << paths[i] << newLine;
  348. }
  349. out << "#else" << newLine
  350. << " #error \"This file is designed to be used in an Introjucer-generated project!\"" << newLine
  351. << "#endif" << newLine;
  352. }
  353. }
  354. void LibraryModule::createLocalHeaderWrapper (ProjectSaver& projectSaver, const File& originalHeader, const File& localHeader) const
  355. {
  356. Project& project = projectSaver.getProject();
  357. MemoryOutputStream out;
  358. out << "// This is an auto-generated file to redirect any included" << newLine
  359. << "// module headers to the correct external folder." << newLine
  360. << newLine;
  361. StringArray paths, guards;
  362. for (Project::ExporterIterator exporter (project); exporter.next();)
  363. {
  364. const RelativePath headerFromProject (getModuleRelativeToProject (*exporter)
  365. .getChildFile (originalHeader.getFileName()));
  366. const RelativePath fileFromHere (headerFromProject.rebased (project.getFile().getParentDirectory(),
  367. localHeader.getParentDirectory(), RelativePath::unknown));
  368. paths.add (fileFromHere.toUnixStyle().quoted());
  369. guards.add ("defined (" + exporter->getExporterIdentifierMacro() + ")");
  370. }
  371. writeGuardedInclude (out, paths, guards);
  372. out << newLine;
  373. projectSaver.replaceFileIfDifferent (localHeader, out);
  374. }
  375. //==============================================================================
  376. File LibraryModule::getLocalFolderFor (Project& project) const
  377. {
  378. if (project.shouldCopyModuleFilesLocally (getID()).getValue())
  379. return project.getGeneratedCodeFolder().getChildFile ("modules").getChildFile (getID());
  380. else
  381. return moduleFolder;
  382. }
  383. void LibraryModule::prepareExporter (ProjectExporter& exporter, ProjectSaver& projectSaver) const
  384. {
  385. Project& project = exporter.getProject();
  386. File localFolder (moduleFolder);
  387. if (project.shouldCopyModuleFilesLocally (getID()).getValue())
  388. localFolder = projectSaver.getLocalModuleFolder (*this);
  389. {
  390. Array<File> compiled;
  391. findAndAddCompiledCode (exporter, projectSaver, localFolder, compiled);
  392. if (project.shouldShowAllModuleFilesInProject (getID()).getValue())
  393. addBrowsableCode (exporter, compiled, localFolder);
  394. }
  395. if (isVSTPluginHost (project))
  396. VSTHelpers::addVSTFolderToPath (exporter, exporter.extraSearchPaths);
  397. if (exporter.isXcode())
  398. {
  399. if (isAUPluginHost (project))
  400. exporter.xcodeFrameworks.addTokens ("AudioUnit CoreAudioKit", false);
  401. const String frameworks (moduleInfo [exporter.isOSX() ? "OSXFrameworks" : "iOSFrameworks"].toString());
  402. exporter.xcodeFrameworks.addTokens (frameworks, ", ", String::empty);
  403. }
  404. else if (exporter.isLinux())
  405. {
  406. const String libs (moduleInfo ["LinuxLibs"].toString());
  407. exporter.linuxLibs.addTokens (libs, ", ", String::empty);
  408. exporter.linuxLibs.trim();
  409. exporter.linuxLibs.sort (false);
  410. exporter.linuxLibs.removeDuplicates (false);
  411. }
  412. if (isPluginClient())
  413. {
  414. if (shouldBuildVST (project).getValue()) VSTHelpers::prepareExporter (exporter, projectSaver);
  415. if (shouldBuildAU (project).getValue()) AUHelpers::prepareExporter (exporter, projectSaver);
  416. if (shouldBuildAAX (project).getValue()) AAXHelpers::prepareExporter (exporter, projectSaver, localFolder);
  417. if (shouldBuildRTAS (project).getValue()) RTASHelpers::prepareExporter (exporter, projectSaver, localFolder);
  418. }
  419. }
  420. void LibraryModule::createPropertyEditors (ProjectExporter& exporter, PropertyListBuilder& props) const
  421. {
  422. if (isVSTPluginHost (exporter.getProject()))
  423. VSTHelpers::createVSTPathEditor (exporter, props);
  424. if (isPluginClient())
  425. {
  426. if (shouldBuildVST (exporter.getProject()).getValue()) VSTHelpers::createPropertyEditors (exporter, props);
  427. if (shouldBuildRTAS (exporter.getProject()).getValue()) RTASHelpers::createPropertyEditors (exporter, props);
  428. if (shouldBuildAAX (exporter.getProject()).getValue()) AAXHelpers::createPropertyEditors (exporter, props);
  429. }
  430. }
  431. void LibraryModule::getConfigFlags (Project& project, OwnedArray<Project::ConfigFlag>& flags) const
  432. {
  433. const File header (getInclude (moduleFolder));
  434. jassert (header.exists());
  435. StringArray lines;
  436. header.readLines (lines);
  437. for (int i = 0; i < lines.size(); ++i)
  438. {
  439. String line (lines[i].trim());
  440. if (line.startsWith ("/**") && line.containsIgnoreCase ("Config:"))
  441. {
  442. ScopedPointer <Project::ConfigFlag> config (new Project::ConfigFlag());
  443. config->sourceModuleID = getID();
  444. config->symbol = line.fromFirstOccurrenceOf (":", false, false).trim();
  445. if (config->symbol.length() > 2)
  446. {
  447. ++i;
  448. while (! (lines[i].contains ("*/") || lines[i].contains ("@see")))
  449. {
  450. if (lines[i].trim().isNotEmpty())
  451. config->description = config->description.trim() + " " + lines[i].trim();
  452. ++i;
  453. }
  454. config->description = config->description.upToFirstOccurrenceOf ("*/", false, false);
  455. config->value.referTo (project.getConfigFlag (config->symbol));
  456. flags.add (config.release());
  457. }
  458. }
  459. }
  460. }
  461. //==============================================================================
  462. static bool exporterTargetMatches (const String& test, String target)
  463. {
  464. StringArray validTargets;
  465. validTargets.addTokens (target, ",;", "");
  466. validTargets.trim();
  467. validTargets.removeEmptyStrings();
  468. if (validTargets.size() == 0)
  469. return true;
  470. for (int i = validTargets.size(); --i >= 0;)
  471. {
  472. const String& target = validTargets[i];
  473. if (target == test
  474. || (target.startsWithChar ('!') && test != target.substring (1).trimStart()))
  475. return true;
  476. }
  477. return false;
  478. }
  479. bool LibraryModule::fileTargetMatches (ProjectExporter& exporter, const String& target)
  480. {
  481. if (exporter.isXcode()) return exporterTargetMatches ("xcode", target);
  482. if (exporter.isVisualStudio()) return exporterTargetMatches ("msvc", target);
  483. if (exporter.isLinux()) return exporterTargetMatches ("linux", target);
  484. if (exporter.isAndroid()) return exporterTargetMatches ("android", target);
  485. return target.isEmpty();
  486. }
  487. void LibraryModule::findWildcardMatches (const File& localModuleFolder, const String& wildcardPath, Array<File>& result) const
  488. {
  489. String path (wildcardPath.upToLastOccurrenceOf ("/", false, false));
  490. String wildCard (wildcardPath.fromLastOccurrenceOf ("/", false, false));
  491. Array<File> tempList;
  492. FileSorter sorter;
  493. DirectoryIterator iter (localModuleFolder.getChildFile (path), false, wildCard);
  494. bool isHiddenFile;
  495. while (iter.next (nullptr, &isHiddenFile, nullptr, nullptr, nullptr, nullptr))
  496. if (! isHiddenFile)
  497. tempList.addSorted (sorter, iter.getFile());
  498. result.addArray (tempList);
  499. }
  500. void LibraryModule::findAndAddCompiledCode (ProjectExporter& exporter, ProjectSaver& projectSaver,
  501. const File& localModuleFolder, Array<File>& result) const
  502. {
  503. const var compileArray (moduleInfo ["compile"]); // careful to keep this alive while the array is in use!
  504. const Array<var>* const files = compileArray.getArray();
  505. if (files != nullptr)
  506. {
  507. for (int i = 0; i < files->size(); ++i)
  508. {
  509. const var& file = files->getReference(i);
  510. const String filename (file ["file"].toString());
  511. if (filename.isNotEmpty()
  512. && fileTargetMatches (exporter, file ["target"].toString()))
  513. {
  514. const File compiledFile (localModuleFolder.getChildFile (filename));
  515. result.add (compiledFile);
  516. Project::Item item (projectSaver.addFileToGeneratedGroup (compiledFile));
  517. if (file ["warnings"].toString().equalsIgnoreCase ("disabled"))
  518. item.getShouldInhibitWarningsValue() = true;
  519. if (file ["stdcall"])
  520. item.getShouldUseStdCallValue() = true;
  521. }
  522. }
  523. }
  524. }
  525. void LibraryModule::getLocalCompiledFiles (const File& localModuleFolder, Array<File>& result) const
  526. {
  527. const var compileArray (moduleInfo ["compile"]); // careful to keep this alive while the array is in use!
  528. const Array<var>* const files = compileArray.getArray();
  529. if (files != nullptr)
  530. {
  531. for (int i = 0; i < files->size(); ++i)
  532. {
  533. const var& file = files->getReference(i);
  534. const String filename (file ["file"].toString());
  535. if (filename.isNotEmpty()
  536. #if JUCE_MAC
  537. && exporterTargetMatches ("xcode", file ["target"].toString())
  538. #elif JUCE_WINDOWS
  539. && exporterTargetMatches ("msvc", file ["target"].toString())
  540. #elif JUCE_LINUX
  541. && exporterTargetMatches ("linux", file ["target"].toString())
  542. #endif
  543. )
  544. {
  545. result.add (localModuleFolder.getChildFile (filename));
  546. }
  547. }
  548. }
  549. }
  550. static void addFileWithGroups (Project::Item& group, const RelativePath& file, const String& path)
  551. {
  552. const int slash = path.indexOfChar (File::separator);
  553. if (slash >= 0)
  554. {
  555. const String topLevelGroup (path.substring (0, slash));
  556. const String remainingPath (path.substring (slash + 1));
  557. Project::Item newGroup (group.getOrCreateSubGroup (topLevelGroup));
  558. addFileWithGroups (newGroup, file, remainingPath);
  559. }
  560. else
  561. {
  562. if (! group.containsChildForFile (file))
  563. group.addRelativeFile (file, -1, false);
  564. }
  565. }
  566. void LibraryModule::addBrowsableCode (ProjectExporter& exporter, const Array<File>& compiled, const File& localModuleFolder) const
  567. {
  568. if (sourceFiles.size() == 0)
  569. {
  570. const var filesArray (moduleInfo ["browse"]);
  571. const Array<var>* const files = filesArray.getArray();
  572. for (int i = 0; i < files->size(); ++i)
  573. findWildcardMatches (localModuleFolder, files->getReference(i), sourceFiles);
  574. }
  575. Project::Item sourceGroup (Project::Item::createGroup (exporter.getProject(), getID(), "__mainsourcegroup" + getID()));
  576. const RelativePath moduleFromProject (getModuleOrLocalCopyRelativeToProject (exporter, localModuleFolder));
  577. for (int i = 0; i < sourceFiles.size(); ++i)
  578. {
  579. const String pathWithinModule (FileHelpers::getRelativePathFrom (sourceFiles.getReference(i), localModuleFolder));
  580. // (Note: in exporters like MSVC we have to avoid adding the same file twice, even if one of those instances
  581. // is flagged as being excluded from the build, because this overrides the other and it fails to compile)
  582. if (exporter.canCopeWithDuplicateFiles() || ! compiled.contains (sourceFiles.getReference(i)))
  583. addFileWithGroups (sourceGroup,
  584. moduleFromProject.getChildFile (pathWithinModule),
  585. pathWithinModule);
  586. }
  587. sourceGroup.addFile (localModuleFolder.getChildFile (FileHelpers::getRelativePathFrom (moduleFile, moduleFolder)), -1, false);
  588. sourceGroup.addFile (getInclude (localModuleFolder), -1, false);
  589. exporter.getModulesGroup().state.addChild (sourceGroup.state.createCopy(), -1, nullptr);
  590. }