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.

166 lines
6.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software 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_JUCEHEADER__
  18. #define __JUCER_MODULE_JUCEHEADER__
  19. #include "../jucer_Headers.h"
  20. #include "jucer_Project.h"
  21. class ProjectExporter;
  22. class ProjectSaver;
  23. //==============================================================================
  24. struct ModuleDescription
  25. {
  26. ModuleDescription() {}
  27. ModuleDescription (const File& manifest);
  28. ModuleDescription (const var& info) : moduleInfo (info) {}
  29. bool isValid() const { return getID().isNotEmpty(); }
  30. String getID() const { return moduleInfo [Ids::ID].toString(); }
  31. String getVersion() const { return moduleInfo [Ids::version].toString(); }
  32. String getName() const { return moduleInfo [Ids::name].toString(); }
  33. String getDescription() const { return moduleInfo [Ids::description].toString(); }
  34. String getLicense() const { return moduleInfo [Ids::license].toString(); }
  35. String getHeaderName() const { return moduleInfo [Ids::include].toString(); }
  36. String getPreprocessorDefs() const { return moduleInfo [Ids::defines].toString(); }
  37. File getFolder() const { jassert (manifestFile != File::nonexistent); return manifestFile.getParentDirectory(); }
  38. bool isPluginClient() const { return getID() == "juce_audio_plugin_client"; }
  39. static const char* getManifestFileName() { return "juce_module_info"; }
  40. var moduleInfo;
  41. File manifestFile;
  42. URL url;
  43. };
  44. //==============================================================================
  45. struct ModuleList
  46. {
  47. ModuleList();
  48. ModuleList (const ModuleList&);
  49. ModuleList& operator= (const ModuleList&);
  50. const ModuleDescription* getModuleWithID (const String& moduleID) const;
  51. StringArray getIDs() const;
  52. void sort();
  53. Result addAllModulesInFolder (const File&);
  54. Result scanAllKnownFolders (Project&);
  55. bool loadFromWebsite();
  56. OwnedArray<ModuleDescription> modules;
  57. };
  58. //==============================================================================
  59. class LibraryModule
  60. {
  61. public:
  62. LibraryModule (const ModuleDescription&);
  63. bool isValid() const { return moduleInfo.isValid(); }
  64. String getID() const { return moduleInfo.getID(); }
  65. String getVersion() const { return moduleInfo.getVersion(); }
  66. String getName() const { return moduleInfo.getName(); }
  67. String getDescription() const { return moduleInfo.getDescription(); }
  68. String getLicense() const { return moduleInfo.getLicense(); }
  69. File getFolder() const { return moduleInfo.getFolder(); }
  70. void writeIncludes (ProjectSaver&, OutputStream&);
  71. void prepareExporter (ProjectExporter&, ProjectSaver&) const;
  72. void createPropertyEditors (ProjectExporter&, PropertyListBuilder&) const;
  73. void getConfigFlags (Project&, OwnedArray<Project::ConfigFlag>& flags) const;
  74. void findBrowseableFiles (const File& localModuleFolder, Array<File>& files) const;
  75. ModuleDescription moduleInfo;
  76. private:
  77. mutable Array<File> sourceFiles;
  78. File getModuleHeaderFile (const File& folder) const;
  79. static bool fileTargetMatches (ProjectExporter& exporter, const String& target);
  80. void findWildcardMatches (const File& localModuleFolder, const String& wildcardPath, Array<File>& result) const;
  81. void findAndAddCompiledCode (ProjectExporter&, ProjectSaver&, const File& localModuleFolder, Array<File>& result) const;
  82. void addBrowsableCode (ProjectExporter&, ProjectSaver&, const Array<File>& compiled, const File& localModuleFolder) const;
  83. void createLocalHeaderWrapper (ProjectSaver&, const File& originalHeader, const File& localHeader) const;
  84. bool isAUPluginHost (const Project&) const;
  85. bool isVSTPluginHost (const Project&) const;
  86. bool isVST3PluginHost (const Project&) const;
  87. };
  88. //==============================================================================
  89. class EnabledModuleList
  90. {
  91. public:
  92. EnabledModuleList (Project&, const ValueTree&);
  93. bool isModuleEnabled (const String& moduleID) const;
  94. Value shouldShowAllModuleFilesInProject (const String& moduleID);
  95. Value shouldCopyModuleFilesLocally (const String& moduleID) const;
  96. void removeModule (String moduleID);
  97. bool isAudioPluginModuleMissing() const;
  98. ModuleDescription getModuleInfo (const String& moduleID);
  99. File getModuleInfoFile (const String& moduleID);
  100. File getModuleFolder (const String& moduleID);
  101. void addModule (const File& moduleManifestFile, bool copyLocally);
  102. void addModuleInteractive (const String& moduleID);
  103. void addModuleFromUserSelectedFile();
  104. void addModuleOfferingToCopy (const File&);
  105. StringArray getAllModules() const;
  106. StringArray getExtraDependenciesNeeded (const String& moduleID) const;
  107. void createRequiredModules (OwnedArray<LibraryModule>& modules);
  108. int getNumModules() const { return state.getNumChildren(); }
  109. String getModuleID (int index) const { return state.getChild (index) [Ids::ID].toString(); }
  110. bool areMostModulesCopiedLocally() const;
  111. void setLocalCopyModeForAllModules (bool copyLocally);
  112. void sortAlphabetically();
  113. static File findDefaultModulesFolder (Project&);
  114. Project& project;
  115. ValueTree state;
  116. private:
  117. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  118. File findLocalModuleInfoFile (const String& moduleID, bool useExportersForOtherOSes);
  119. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EnabledModuleList)
  120. };
  121. #endif // __JUCER_MODULE_JUCEHEADER__