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.

176 lines
6.7KB

  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. #ifndef JUCER_MODULE_H_INCLUDED
  18. #define JUCER_MODULE_H_INCLUDED
  19. #include "jucer_Project.h"
  20. class ProjectExporter;
  21. class ProjectSaver;
  22. //==============================================================================
  23. File findDefaultModulesFolder (bool mustContainJuceCoreModule = true);
  24. bool isJuceModulesFolder (const File&);
  25. bool isJuceFolder (const File&);
  26. //==============================================================================
  27. struct ModuleDescription
  28. {
  29. ModuleDescription() {}
  30. ModuleDescription (const File& folder);
  31. ModuleDescription (const var& info) : moduleInfo (info) {}
  32. bool isValid() const { return getID().isNotEmpty(); }
  33. String getID() const { return moduleInfo [Ids::ID_uppercase].toString(); }
  34. String getVendor() const { return moduleInfo [Ids::vendor].toString(); }
  35. String getVersion() const { return moduleInfo [Ids::version].toString(); }
  36. String getName() const { return moduleInfo [Ids::name].toString(); }
  37. String getDescription() const { return moduleInfo [Ids::description].toString(); }
  38. String getLicense() const { return moduleInfo [Ids::license].toString(); }
  39. String getPreprocessorDefs() const { return moduleInfo [Ids::defines].toString(); }
  40. String getExtraSearchPaths() const { return moduleInfo [Ids::searchpaths].toString(); }
  41. StringArray getDependencies() const;
  42. File getFolder() const { jassert (moduleFolder != File()); return moduleFolder; }
  43. File getHeader() const;
  44. bool isPluginClient() const { return getID() == "juce_audio_plugin_client"; }
  45. File moduleFolder;
  46. var moduleInfo;
  47. URL url;
  48. };
  49. //==============================================================================
  50. struct ModuleList
  51. {
  52. ModuleList();
  53. ModuleList (const ModuleList&);
  54. ModuleList& operator= (const ModuleList&);
  55. const ModuleDescription* getModuleWithID (const String& moduleID) const;
  56. StringArray getIDs() const;
  57. void sort();
  58. Result tryToAddModuleFromFolder (const File&);
  59. Result addAllModulesInFolder (const File&);
  60. Result addAllModulesInSubfoldersRecursively (const File&, int depth);
  61. Result scanAllKnownFolders (Project&);
  62. OwnedArray<ModuleDescription> modules;
  63. };
  64. //==============================================================================
  65. class LibraryModule
  66. {
  67. public:
  68. LibraryModule (const ModuleDescription&);
  69. bool isValid() const { return moduleInfo.isValid(); }
  70. String getID() const { return moduleInfo.getID(); }
  71. String getVendor() const { return moduleInfo.getVendor(); }
  72. String getVersion() const { return moduleInfo.getVersion(); }
  73. String getName() const { return moduleInfo.getName(); }
  74. String getDescription() const { return moduleInfo.getDescription(); }
  75. String getLicense() const { return moduleInfo.getLicense(); }
  76. File getFolder() const { return moduleInfo.getFolder(); }
  77. void writeIncludes (ProjectSaver&, OutputStream&);
  78. void addSettingsForModuleToExporter (ProjectExporter&, ProjectSaver&) const;
  79. void getConfigFlags (Project&, OwnedArray<Project::ConfigFlag>& flags) const;
  80. void findBrowseableFiles (const File& localModuleFolder, Array<File>& files) const;
  81. struct CompileUnit
  82. {
  83. File file;
  84. bool isCompiledForObjC, isCompiledForNonObjC;
  85. void writeInclude (MemoryOutputStream&) const;
  86. bool isNeededForExporter (ProjectExporter&) const;
  87. static bool hasSuffix (const File&, const char*);
  88. };
  89. Array<CompileUnit> getAllCompileUnits() const;
  90. void findAndAddCompiledUnits (ProjectExporter&, ProjectSaver*, Array<File>& result) const;
  91. ModuleDescription moduleInfo;
  92. private:
  93. mutable Array<File> sourceFiles;
  94. OwnedArray<Project::ConfigFlag> configFlags;
  95. void addBrowseableCode (ProjectExporter&, const Array<File>& compiled, const File& localModuleFolder) const;
  96. };
  97. //==============================================================================
  98. class EnabledModuleList
  99. {
  100. public:
  101. EnabledModuleList (Project&, const ValueTree&);
  102. bool isModuleEnabled (const String& moduleID) const;
  103. Value shouldShowAllModuleFilesInProject (const String& moduleID);
  104. Value shouldCopyModuleFilesLocally (const String& moduleID) const;
  105. void removeModule (String moduleID);
  106. bool isAudioPluginModuleMissing() const;
  107. ModuleDescription getModuleInfo (const String& moduleID);
  108. File getModuleFolder (const String& moduleID);
  109. void addModule (const File& moduleManifestFile, bool copyLocally);
  110. void addModuleInteractive (const String& moduleID);
  111. void addModuleFromUserSelectedFile();
  112. void addModuleOfferingToCopy (const File&);
  113. StringArray getAllModules() const;
  114. StringArray getExtraDependenciesNeeded (const String& moduleID) const;
  115. void createRequiredModules (OwnedArray<LibraryModule>& modules);
  116. int getNumModules() const { return state.getNumChildren(); }
  117. String getModuleID (int index) const { return state.getChild (index) [Ids::ID].toString(); }
  118. bool areMostModulesCopiedLocally() const;
  119. void setLocalCopyModeForAllModules (bool copyLocally);
  120. void sortAlphabetically();
  121. static File findDefaultModulesFolder (Project&);
  122. Project& project;
  123. ValueTree state;
  124. private:
  125. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  126. File findLocalModuleFolder (const String& moduleID, bool useExportersForOtherOSes);
  127. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EnabledModuleList)
  128. };
  129. #endif // JUCER_MODULE_H_INCLUDED