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.

161 lines
6.3KB

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