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.

185 lines
7.1KB

  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 getPreprocessorDefs() const { return moduleInfo [Ids::defines].toString(); }
  40. String getExtraSearchPaths() const { return moduleInfo [Ids::searchpaths].toString(); }
  41. StringArray getDependencies() const;
  42. File getFolder() const { jassert (moduleFolder != File()); return moduleFolder; }
  43. File getHeader() const;
  44. bool isPluginClient() const { return getID() == "juce_audio_plugin_client"; }
  45. File moduleFolder;
  46. var moduleInfo;
  47. URL url;
  48. };
  49. //==============================================================================
  50. struct ModuleList
  51. {
  52. ModuleList();
  53. ModuleList (const ModuleList&);
  54. ModuleList& operator= (const ModuleList&);
  55. const ModuleDescription* getModuleWithID (const String& moduleID) const;
  56. StringArray getIDs() const;
  57. void sort();
  58. Result tryToAddModuleFromFolder (const File&);
  59. Result addAllModulesInFolder (const File&);
  60. Result addAllModulesInSubfoldersRecursively (const File&, int depth);
  61. Result scanProjectExporterModulePaths (Project&);
  62. void scanGlobalJuceModulePath();
  63. void scanGlobalUserModulePath();
  64. OwnedArray<ModuleDescription> modules;
  65. };
  66. //==============================================================================
  67. class LibraryModule
  68. {
  69. public:
  70. LibraryModule (const ModuleDescription&);
  71. bool isValid() const { return moduleInfo.isValid(); }
  72. String getID() const { return moduleInfo.getID(); }
  73. String getVendor() const { return moduleInfo.getVendor(); }
  74. String getVersion() const { return moduleInfo.getVersion(); }
  75. String getName() const { return moduleInfo.getName(); }
  76. String getDescription() const { return moduleInfo.getDescription(); }
  77. String getLicense() const { return moduleInfo.getLicense(); }
  78. File getFolder() const { return moduleInfo.getFolder(); }
  79. void writeIncludes (ProjectSaver&, OutputStream&);
  80. void addSettingsForModuleToExporter (ProjectExporter&, ProjectSaver&) const;
  81. void getConfigFlags (Project&, OwnedArray<Project::ConfigFlag>& flags) const;
  82. void findBrowseableFiles (const File& localModuleFolder, Array<File>& files) const;
  83. struct CompileUnit
  84. {
  85. File file;
  86. bool isCompiledForObjC, isCompiledForNonObjC;
  87. void writeInclude (MemoryOutputStream&) const;
  88. bool isNeededForExporter (ProjectExporter&) const;
  89. String getFilenameForProxyFile() const;
  90. static bool hasSuffix (const File&, const char*);
  91. };
  92. Array<CompileUnit> getAllCompileUnits (ProjectType::Target::Type forTarget = ProjectType::Target::unspecified) const;
  93. void findAndAddCompiledUnits (ProjectExporter&, ProjectSaver*, Array<File>& result,
  94. ProjectType::Target::Type forTarget = ProjectType::Target::unspecified) const;
  95. ModuleDescription moduleInfo;
  96. private:
  97. mutable Array<File> sourceFiles;
  98. OwnedArray<Project::ConfigFlag> configFlags;
  99. void addBrowseableCode (ProjectExporter&, const Array<File>& compiled, const File& localModuleFolder) const;
  100. };
  101. //==============================================================================
  102. class EnabledModuleList
  103. {
  104. public:
  105. EnabledModuleList (Project&, const ValueTree&);
  106. static File findGlobalModulesFolder();
  107. static File findDefaultModulesFolder (Project&);
  108. static bool isJuceModule (const String& moduleID);
  109. bool isModuleEnabled (const String& moduleID) const;
  110. Value shouldUseGlobalPath (const String& moduleID) const;
  111. Value shouldShowAllModuleFilesInProject (const String& moduleID);
  112. Value shouldCopyModuleFilesLocally (const String& moduleID) const;
  113. void removeModule (String moduleID);
  114. bool isAudioPluginModuleMissing() const;
  115. ModuleDescription getModuleInfo (const String& moduleID);
  116. File getModuleFolder (const String& moduleID);
  117. void addModule (const File& moduleManifestFile, bool copyLocally, bool useGlobalPath);
  118. void addModuleInteractive (const String& moduleID);
  119. void addModuleFromUserSelectedFile();
  120. void addModuleOfferingToCopy (const File&);
  121. StringArray getAllModules() const;
  122. StringArray getExtraDependenciesNeeded (const String& moduleID) const;
  123. void createRequiredModules (OwnedArray<LibraryModule>& modules);
  124. int getNumModules() const { return state.getNumChildren(); }
  125. String getModuleID (int index) const { return state.getChild (index) [Ids::ID].toString(); }
  126. bool areMostModulesUsingGlobalPath() const;
  127. bool areMostModulesCopiedLocally() const;
  128. void setLocalCopyModeForAllModules (bool copyLocally);
  129. void sortAlphabetically();
  130. Project& project;
  131. ValueTree state;
  132. private:
  133. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  134. static File getModuleFolderFromPathIfItExists (const String& path, const String& moduleID, const Project&);
  135. File findUserModuleFolder (const String& possiblePaths, const String& moduleID);
  136. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EnabledModuleList)
  137. };