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.

172 lines
6.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. #include "jucer_Project.h"
  19. class ProjectExporter;
  20. class ProjectSaver;
  21. //==============================================================================
  22. File findDefaultModulesFolder (bool mustContainJuceCoreModule = true);
  23. bool isJuceModulesFolder (const File&);
  24. bool isJuceFolder (const File&);
  25. //==============================================================================
  26. struct ModuleDescription
  27. {
  28. ModuleDescription() {}
  29. ModuleDescription (const File& folder);
  30. ModuleDescription (const var& info) : moduleInfo (info) {}
  31. bool isValid() const { return getID().isNotEmpty(); }
  32. String getID() const { return moduleInfo [Ids::ID_uppercase].toString(); }
  33. String getVendor() const { return moduleInfo [Ids::vendor].toString(); }
  34. String getVersion() const { return moduleInfo [Ids::version].toString(); }
  35. String getName() const { return moduleInfo [Ids::name].toString(); }
  36. String getDescription() const { return moduleInfo [Ids::description].toString(); }
  37. String getLicense() const { return moduleInfo [Ids::license].toString(); }
  38. String getPreprocessorDefs() const { return moduleInfo [Ids::defines].toString(); }
  39. String getExtraSearchPaths() const { return moduleInfo [Ids::searchpaths].toString(); }
  40. StringArray getDependencies() const;
  41. File getFolder() const { jassert (moduleFolder != File()); return moduleFolder; }
  42. File getHeader() const;
  43. bool isPluginClient() const { return getID() == "juce_audio_plugin_client"; }
  44. File moduleFolder;
  45. var moduleInfo;
  46. URL url;
  47. };
  48. //==============================================================================
  49. struct ModuleList
  50. {
  51. ModuleList();
  52. ModuleList (const ModuleList&);
  53. ModuleList& operator= (const ModuleList&);
  54. const ModuleDescription* getModuleWithID (const String& moduleID) const;
  55. StringArray getIDs() const;
  56. void sort();
  57. Result tryToAddModuleFromFolder (const File&);
  58. Result addAllModulesInFolder (const File&);
  59. Result addAllModulesInSubfoldersRecursively (const File&, int depth);
  60. Result scanAllKnownFolders (Project&);
  61. OwnedArray<ModuleDescription> modules;
  62. };
  63. //==============================================================================
  64. class LibraryModule
  65. {
  66. public:
  67. LibraryModule (const ModuleDescription&);
  68. bool isValid() const { return moduleInfo.isValid(); }
  69. String getID() const { return moduleInfo.getID(); }
  70. String getVendor() const { return moduleInfo.getVendor(); }
  71. String getVersion() const { return moduleInfo.getVersion(); }
  72. String getName() const { return moduleInfo.getName(); }
  73. String getDescription() const { return moduleInfo.getDescription(); }
  74. String getLicense() const { return moduleInfo.getLicense(); }
  75. File getFolder() const { return moduleInfo.getFolder(); }
  76. void writeIncludes (ProjectSaver&, OutputStream&);
  77. void addSettingsForModuleToExporter (ProjectExporter&, ProjectSaver&) const;
  78. void getConfigFlags (Project&, OwnedArray<Project::ConfigFlag>& flags) const;
  79. void findBrowseableFiles (const File& localModuleFolder, Array<File>& files) const;
  80. struct CompileUnit
  81. {
  82. File file;
  83. bool isCompiledForObjC, isCompiledForNonObjC;
  84. void writeInclude (MemoryOutputStream&) const;
  85. bool isNeededForExporter (ProjectExporter&) const;
  86. static bool hasSuffix (const File&, const char*);
  87. };
  88. Array<CompileUnit> getAllCompileUnits() const;
  89. void findAndAddCompiledUnits (ProjectExporter&, ProjectSaver*, Array<File>& result) const;
  90. ModuleDescription moduleInfo;
  91. private:
  92. mutable Array<File> sourceFiles;
  93. OwnedArray<Project::ConfigFlag> configFlags;
  94. void addBrowseableCode (ProjectExporter&, const Array<File>& compiled, const File& localModuleFolder) const;
  95. };
  96. //==============================================================================
  97. class EnabledModuleList
  98. {
  99. public:
  100. EnabledModuleList (Project&, const ValueTree&);
  101. bool isModuleEnabled (const String& moduleID) const;
  102. Value shouldShowAllModuleFilesInProject (const String& moduleID);
  103. Value shouldCopyModuleFilesLocally (const String& moduleID) const;
  104. void removeModule (String moduleID);
  105. bool isAudioPluginModuleMissing() const;
  106. ModuleDescription getModuleInfo (const String& moduleID);
  107. File getModuleFolder (const String& moduleID);
  108. void addModule (const File& moduleManifestFile, bool copyLocally);
  109. void addModuleInteractive (const String& moduleID);
  110. void addModuleFromUserSelectedFile();
  111. void addModuleOfferingToCopy (const File&);
  112. StringArray getAllModules() const;
  113. StringArray getExtraDependenciesNeeded (const String& moduleID) const;
  114. void createRequiredModules (OwnedArray<LibraryModule>& modules);
  115. int getNumModules() const { return state.getNumChildren(); }
  116. String getModuleID (int index) const { return state.getChild (index) [Ids::ID].toString(); }
  117. bool areMostModulesCopiedLocally() const;
  118. void setLocalCopyModeForAllModules (bool copyLocally);
  119. void sortAlphabetically();
  120. static File findDefaultModulesFolder (Project&);
  121. Project& project;
  122. ValueTree state;
  123. private:
  124. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  125. File findLocalModuleFolder (const String& moduleID, bool useExportersForOtherOSes);
  126. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EnabledModuleList)
  127. };