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.

147 lines
5.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #pragma once
  19. #include "../jucer_Project.h"
  20. class ProjectExporter;
  21. class ProjectSaver;
  22. //==============================================================================
  23. class LibraryModule
  24. {
  25. public:
  26. LibraryModule (const ModuleDescription&);
  27. bool isValid() const { return moduleInfo.isValid(); }
  28. String getID() const { return moduleInfo.getID(); }
  29. String getVendor() const { return moduleInfo.getVendor(); }
  30. String getVersion() const { return moduleInfo.getVersion(); }
  31. String getName() const { return moduleInfo.getName(); }
  32. String getDescription() const { return moduleInfo.getDescription(); }
  33. String getLicense() const { return moduleInfo.getLicense(); }
  34. String getMinimumCppStandard() const { return moduleInfo.getMinimumCppStandard(); }
  35. File getFolder() const { return moduleInfo.getFolder(); }
  36. void writeIncludes (ProjectSaver&, OutputStream&);
  37. void addSettingsForModuleToExporter (ProjectExporter&, ProjectSaver&) const;
  38. void getConfigFlags (Project&, OwnedArray<Project::ConfigFlag>& flags) const;
  39. void findBrowseableFiles (const File& localModuleFolder, Array<File>& files) const;
  40. struct CompileUnit
  41. {
  42. File file;
  43. bool isCompiledForObjC = false, isCompiledForNonObjC = false;
  44. bool isNeededForExporter (ProjectExporter&) const;
  45. String getFilenameForProxyFile() const;
  46. static bool hasSuffix (const File&, const char*);
  47. };
  48. Array<CompileUnit> getAllCompileUnits (build_tools::ProjectType::Target::Type forTarget =
  49. build_tools::ProjectType::Target::unspecified) const;
  50. void findAndAddCompiledUnits (ProjectExporter&, ProjectSaver*, Array<File>& result,
  51. build_tools::ProjectType::Target::Type forTarget =
  52. build_tools::ProjectType::Target::unspecified) const;
  53. ModuleDescription moduleInfo;
  54. private:
  55. void addSearchPathsToExporter (ProjectExporter&) const;
  56. void addDefinesToExporter (ProjectExporter&) const;
  57. void addCompileUnitsToExporter (ProjectExporter&, ProjectSaver&) const;
  58. void addLibsToExporter (ProjectExporter&) const;
  59. void addBrowseableCode (ProjectExporter&, const Array<File>& compiled, const File& localModuleFolder) const;
  60. mutable Array<File> sourceFiles;
  61. OwnedArray<Project::ConfigFlag> configFlags;
  62. };
  63. //==============================================================================
  64. class EnabledModulesList
  65. {
  66. public:
  67. EnabledModulesList (Project&, const ValueTree&);
  68. //==============================================================================
  69. ValueTree getState() const { return state; }
  70. StringArray getAllModules() const;
  71. void createRequiredModules (OwnedArray<LibraryModule>& modules);
  72. void sortAlphabetically();
  73. File getDefaultModulesFolder() const;
  74. int getNumModules() const { return state.getNumChildren(); }
  75. String getModuleID (int index) const { return state.getChild (index) [Ids::ID].toString(); }
  76. ModuleDescription getModuleInfo (const String& moduleID) const;
  77. bool isModuleEnabled (const String& moduleID) const;
  78. StringArray getExtraDependenciesNeeded (const String& moduleID) const;
  79. bool tryToFixMissingDependencies (const String& moduleID);
  80. bool doesModuleHaveHigherCppStandardThanProject (const String& moduleID) const;
  81. bool shouldUseGlobalPath (const String& moduleID) const;
  82. Value shouldUseGlobalPathValue (const String& moduleID) const;
  83. bool shouldShowAllModuleFilesInProject (const String& moduleID) const;
  84. Value shouldShowAllModuleFilesInProjectValue (const String& moduleID) const;
  85. bool shouldCopyModuleFilesLocally (const String& moduleID) const;
  86. Value shouldCopyModuleFilesLocallyValue (const String& moduleID) const;
  87. bool areMostModulesUsingGlobalPath() const;
  88. bool areMostModulesCopiedLocally() const;
  89. StringArray getModulesWithHigherCppStandardThanProject() const;
  90. StringArray getModulesWithMissingDependencies() const;
  91. String getHighestModuleCppStandard() const;
  92. //==============================================================================
  93. void addModule (const File& moduleManifestFile, bool copyLocally, bool useGlobalPath);
  94. void addModuleInteractive (const String& moduleID);
  95. void addModuleFromUserSelectedFile();
  96. void addModuleOfferingToCopy (const File&, bool isFromUserSpecifiedFolder);
  97. void removeModule (String moduleID);
  98. private:
  99. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  100. Project& project;
  101. CriticalSection stateLock;
  102. ValueTree state;
  103. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EnabledModulesList)
  104. };