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.

189 lines
7.4KB

  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. 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 getMinimumCppStandard() const { return moduleInfo [Ids::minimumCppStandard].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. bool tryToAddModuleFromFolder (const File&);
  60. void addAllModulesInFolder (const File&);
  61. static Array<File>& getPreviousModuleDirectories();
  62. static File tryToFindModulePathFromPrevious (const String&);
  63. void scanProjectExporterModulePaths (Project&);
  64. void scanGlobalJuceModulePath();
  65. void scanGlobalUserModulePath();
  66. OwnedArray<ModuleDescription> modules;
  67. };
  68. //==============================================================================
  69. class LibraryModule
  70. {
  71. public:
  72. LibraryModule (const ModuleDescription&);
  73. bool isValid() const { return moduleInfo.isValid(); }
  74. String getID() const { return moduleInfo.getID(); }
  75. String getVendor() const { return moduleInfo.getVendor(); }
  76. String getVersion() const { return moduleInfo.getVersion(); }
  77. String getName() const { return moduleInfo.getName(); }
  78. String getDescription() const { return moduleInfo.getDescription(); }
  79. String getLicense() const { return moduleInfo.getLicense(); }
  80. String getMinimumCppStandard() const { return moduleInfo.getMinimumCppStandard(); }
  81. File getFolder() const { return moduleInfo.getFolder(); }
  82. void writeIncludes (ProjectSaver&, OutputStream&);
  83. void addSettingsForModuleToExporter (ProjectExporter&, ProjectSaver&) const;
  84. void getConfigFlags (Project&, OwnedArray<Project::ConfigFlag>& flags) const;
  85. void findBrowseableFiles (const File& localModuleFolder, Array<File>& files) const;
  86. struct CompileUnit
  87. {
  88. File file;
  89. bool isCompiledForObjC, isCompiledForNonObjC;
  90. void writeInclude (MemoryOutputStream&) const;
  91. bool isNeededForExporter (ProjectExporter&) const;
  92. String getFilenameForProxyFile() const;
  93. static bool hasSuffix (const File&, const char*);
  94. };
  95. Array<CompileUnit> getAllCompileUnits (ProjectType::Target::Type forTarget = ProjectType::Target::unspecified) const;
  96. void findAndAddCompiledUnits (ProjectExporter&, ProjectSaver*, Array<File>& result,
  97. ProjectType::Target::Type forTarget = ProjectType::Target::unspecified) const;
  98. ModuleDescription moduleInfo;
  99. private:
  100. mutable Array<File> sourceFiles;
  101. OwnedArray<Project::ConfigFlag> configFlags;
  102. void addBrowseableCode (ProjectExporter&, const Array<File>& compiled, const File& localModuleFolder) const;
  103. };
  104. //==============================================================================
  105. class EnabledModuleList
  106. {
  107. public:
  108. EnabledModuleList (Project&, const ValueTree&);
  109. static File findDefaultModulesFolder (Project&);
  110. bool isModuleEnabled (const String& moduleID) const;
  111. bool shouldUseGlobalPath (const String& moduleID) const;
  112. Value getShouldUseGlobalPathValue (const String& moduleID) const;
  113. Value shouldShowAllModuleFilesInProject (const String& moduleID);
  114. Value shouldCopyModuleFilesLocally (const String& moduleID) const;
  115. void removeModule (String moduleID);
  116. bool isAudioPluginModuleMissing() const;
  117. ModuleDescription getModuleInfo (const String& moduleID);
  118. void addModule (const File& moduleManifestFile, bool copyLocally, bool useGlobalPath, bool sendAnalyticsEvent);
  119. void addModuleInteractive (const String& moduleID);
  120. void addModuleFromUserSelectedFile();
  121. void addModuleOfferingToCopy (const File&, bool isFromUserSpecifiedFolder);
  122. StringArray getAllModules() const;
  123. StringArray getExtraDependenciesNeeded (const String& moduleID) const;
  124. bool doesModuleHaveHigherCppStandardThanProject (const String& moduleID);
  125. void createRequiredModules (OwnedArray<LibraryModule>& modules);
  126. int getNumModules() const { return state.getNumChildren(); }
  127. String getModuleID (int index) const { return state.getChild (index) [Ids::ID].toString(); }
  128. bool areMostModulesUsingGlobalPath() const;
  129. bool areMostModulesCopiedLocally() const;
  130. void setLocalCopyModeForAllModules (bool copyLocally);
  131. void sortAlphabetically();
  132. Project& project;
  133. ValueTree state;
  134. private:
  135. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  136. File findFolderForModule (const String& moduleID);
  137. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EnabledModuleList)
  138. };