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.

170 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& manifest);
  31. ModuleDescription (const var& info) : moduleInfo (info) {}
  32. bool isValid() const { return getID().isNotEmpty(); }
  33. String getID() const { return moduleInfo [Ids::ID].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 getHeaderName() const { return moduleInfo [Ids::include].toString(); }
  39. String getPreprocessorDefs() const { return moduleInfo [Ids::defines].toString(); }
  40. File getFolder() const { jassert (manifestFile != File::nonexistent); return manifestFile.getParentDirectory(); }
  41. bool isPluginClient() const { return getID() == "juce_audio_plugin_client"; }
  42. static const char* getManifestFileName() { return "juce_module_info"; }
  43. var moduleInfo;
  44. File manifestFile;
  45. URL url;
  46. };
  47. //==============================================================================
  48. struct ModuleList
  49. {
  50. ModuleList();
  51. ModuleList (const ModuleList&);
  52. ModuleList& operator= (const ModuleList&);
  53. const ModuleDescription* getModuleWithID (const String& moduleID) const;
  54. StringArray getIDs() const;
  55. void sort();
  56. Result addAllModulesInFolder (const File&);
  57. Result scanAllKnownFolders (Project&);
  58. bool loadFromWebsite();
  59. OwnedArray<ModuleDescription> modules;
  60. };
  61. //==============================================================================
  62. class LibraryModule
  63. {
  64. public:
  65. LibraryModule (const ModuleDescription&);
  66. bool isValid() const { return moduleInfo.isValid(); }
  67. String getID() const { return moduleInfo.getID(); }
  68. String getVersion() const { return moduleInfo.getVersion(); }
  69. String getName() const { return moduleInfo.getName(); }
  70. String getDescription() const { return moduleInfo.getDescription(); }
  71. String getLicense() const { return moduleInfo.getLicense(); }
  72. File getFolder() const { return moduleInfo.getFolder(); }
  73. void writeIncludes (ProjectSaver&, OutputStream&);
  74. void prepareExporter (ProjectExporter&, ProjectSaver&) const;
  75. void createPropertyEditors (ProjectExporter&, PropertyListBuilder&) const;
  76. void getConfigFlags (Project&, OwnedArray<Project::ConfigFlag>& flags) const;
  77. void findBrowseableFiles (const File& localModuleFolder, Array<File>& files) const;
  78. void findAndAddCompiledUnits (ProjectExporter&, ProjectSaver*, const File& localModuleFolder, Array<File>& result) const;
  79. ModuleDescription moduleInfo;
  80. private:
  81. mutable Array<File> sourceFiles;
  82. File getModuleHeaderFile (const File& folder) const;
  83. void findWildcardMatches (const File& localModuleFolder, const String& wildcardPath, Array<File>& result) const;
  84. void addBrowseableCode (ProjectExporter&, const Array<File>& compiled, const File& localModuleFolder) const;
  85. void createLocalHeaderWrapper (ProjectSaver&, const File& originalHeader, const File& localHeader) const;
  86. bool isAUPluginHost (const Project&) const;
  87. bool isVSTPluginHost (const Project&) const;
  88. bool isVST3PluginHost (const Project&) const;
  89. };
  90. //==============================================================================
  91. class EnabledModuleList
  92. {
  93. public:
  94. EnabledModuleList (Project&, const ValueTree&);
  95. bool isModuleEnabled (const String& moduleID) const;
  96. Value shouldShowAllModuleFilesInProject (const String& moduleID);
  97. Value shouldNotOverwriteModuleCodeOnSave (const String& moduleID);
  98. Value shouldCopyModuleFilesLocally (const String& moduleID) const;
  99. void removeModule (String moduleID);
  100. bool isAudioPluginModuleMissing() const;
  101. ModuleDescription getModuleInfo (const String& moduleID);
  102. File getModuleInfoFile (const String& moduleID);
  103. File getModuleFolder (const String& moduleID);
  104. void addModule (const File& moduleManifestFile, bool copyLocally);
  105. void addModuleInteractive (const String& moduleID);
  106. void addModuleFromUserSelectedFile();
  107. void addModuleOfferingToCopy (const File&);
  108. StringArray getAllModules() const;
  109. StringArray getExtraDependenciesNeeded (const String& moduleID) const;
  110. void createRequiredModules (OwnedArray<LibraryModule>& modules);
  111. int getNumModules() const { return state.getNumChildren(); }
  112. String getModuleID (int index) const { return state.getChild (index) [Ids::ID].toString(); }
  113. bool areMostModulesCopiedLocally() const;
  114. void setLocalCopyModeForAllModules (bool copyLocally);
  115. void sortAlphabetically();
  116. static File findDefaultModulesFolder (Project&);
  117. Project& project;
  118. ValueTree state;
  119. private:
  120. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  121. File findLocalModuleInfoFile (const String& moduleID, bool useExportersForOtherOSes);
  122. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EnabledModuleList)
  123. };
  124. #endif // JUCER_MODULE_H_INCLUDED