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.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. #include "jucer_Project.h"
  21. class ProjectExporter;
  22. class ProjectSaver;
  23. //==============================================================================
  24. File findDefaultModulesFolder (bool mustContainJuceCoreModule = true);
  25. bool isJuceModulesFolder (const File&);
  26. bool isJuceFolder (const File&);
  27. //==============================================================================
  28. struct ModuleDescription
  29. {
  30. ModuleDescription() {}
  31. ModuleDescription (const File& folder);
  32. ModuleDescription (const var& info) : moduleInfo (info) {}
  33. bool isValid() const { return getID().isNotEmpty(); }
  34. String getID() const { return moduleInfo [Ids::ID_uppercase].toString(); }
  35. String getVendor() const { return moduleInfo [Ids::vendor].toString(); }
  36. String getVersion() const { return moduleInfo [Ids::version].toString(); }
  37. String getName() const { return moduleInfo [Ids::name].toString(); }
  38. String getDescription() const { return moduleInfo [Ids::description].toString(); }
  39. String getLicense() const { return moduleInfo [Ids::license].toString(); }
  40. String getPreprocessorDefs() const { return moduleInfo [Ids::defines].toString(); }
  41. String getExtraSearchPaths() const { return moduleInfo [Ids::searchpaths].toString(); }
  42. StringArray getDependencies() const;
  43. File getFolder() const { jassert (moduleFolder != File()); return moduleFolder; }
  44. File getHeader() const;
  45. bool isPluginClient() const { return getID() == "juce_audio_plugin_client"; }
  46. File moduleFolder;
  47. var moduleInfo;
  48. URL url;
  49. };
  50. //==============================================================================
  51. struct ModuleList
  52. {
  53. ModuleList();
  54. ModuleList (const ModuleList&);
  55. ModuleList& operator= (const ModuleList&);
  56. const ModuleDescription* getModuleWithID (const String& moduleID) const;
  57. StringArray getIDs() const;
  58. void sort();
  59. Result tryToAddModuleFromFolder (const File&);
  60. Result addAllModulesInFolder (const File&);
  61. Result addAllModulesInSubfoldersRecursively (const File&, int depth);
  62. Result scanAllKnownFolders (Project&);
  63. OwnedArray<ModuleDescription> modules;
  64. };
  65. //==============================================================================
  66. class LibraryModule
  67. {
  68. public:
  69. LibraryModule (const ModuleDescription&);
  70. bool isValid() const { return moduleInfo.isValid(); }
  71. String getID() const { return moduleInfo.getID(); }
  72. String getVendor() const { return moduleInfo.getVendor(); }
  73. String getVersion() const { return moduleInfo.getVersion(); }
  74. String getName() const { return moduleInfo.getName(); }
  75. String getDescription() const { return moduleInfo.getDescription(); }
  76. String getLicense() const { return moduleInfo.getLicense(); }
  77. File getFolder() const { return moduleInfo.getFolder(); }
  78. void writeIncludes (ProjectSaver&, OutputStream&);
  79. void addSettingsForModuleToExporter (ProjectExporter&, ProjectSaver&) const;
  80. void getConfigFlags (Project&, OwnedArray<Project::ConfigFlag>& flags) const;
  81. void findBrowseableFiles (const File& localModuleFolder, Array<File>& files) const;
  82. struct CompileUnit
  83. {
  84. File file;
  85. bool isCompiledForObjC, isCompiledForNonObjC;
  86. void writeInclude (MemoryOutputStream&) const;
  87. bool isNeededForExporter (ProjectExporter&) const;
  88. String getFilenameForProxyFile() const;
  89. static bool hasSuffix (const File&, const char*);
  90. };
  91. Array<CompileUnit> getAllCompileUnits (ProjectType::Target::Type forTarget = ProjectType::Target::unspecified) const;
  92. void findAndAddCompiledUnits (ProjectExporter&, ProjectSaver*, Array<File>& result,
  93. ProjectType::Target::Type forTarget = ProjectType::Target::unspecified) const;
  94. ModuleDescription moduleInfo;
  95. private:
  96. mutable Array<File> sourceFiles;
  97. OwnedArray<Project::ConfigFlag> configFlags;
  98. void addBrowseableCode (ProjectExporter&, const Array<File>& compiled, const File& localModuleFolder) const;
  99. };
  100. //==============================================================================
  101. class EnabledModuleList
  102. {
  103. public:
  104. EnabledModuleList (Project&, const ValueTree&);
  105. bool isModuleEnabled (const String& moduleID) const;
  106. Value shouldShowAllModuleFilesInProject (const String& moduleID);
  107. Value shouldCopyModuleFilesLocally (const String& moduleID) const;
  108. void removeModule (String moduleID);
  109. bool isAudioPluginModuleMissing() const;
  110. ModuleDescription getModuleInfo (const String& moduleID);
  111. File getModuleFolder (const String& moduleID);
  112. void addModule (const File& moduleManifestFile, bool copyLocally);
  113. void addModuleInteractive (const String& moduleID);
  114. void addModuleFromUserSelectedFile();
  115. void addModuleOfferingToCopy (const File&);
  116. StringArray getAllModules() const;
  117. StringArray getExtraDependenciesNeeded (const String& moduleID) const;
  118. void createRequiredModules (OwnedArray<LibraryModule>& modules);
  119. int getNumModules() const { return state.getNumChildren(); }
  120. String getModuleID (int index) const { return state.getChild (index) [Ids::ID].toString(); }
  121. bool areMostModulesCopiedLocally() const;
  122. void setLocalCopyModeForAllModules (bool copyLocally);
  123. void sortAlphabetically();
  124. static File findDefaultModulesFolder (Project&);
  125. Project& project;
  126. ValueTree state;
  127. private:
  128. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  129. File findLocalModuleFolder (const String& moduleID, bool useExportersForOtherOSes);
  130. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EnabledModuleList)
  131. };