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.

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