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.

149 lines
5.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - 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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-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 moduleDescription.isValid(); }
  28. String getID() const { return moduleDescription.getID(); }
  29. String getVendor() const { return moduleDescription.getVendor(); }
  30. String getVersion() const { return moduleDescription.getVersion(); }
  31. String getName() const { return moduleDescription.getName(); }
  32. String getDescription() const { return moduleDescription.getDescription(); }
  33. String getLicense() const { return moduleDescription.getLicense(); }
  34. String getMinimumCppStandard() const { return moduleDescription.getMinimumCppStandard(); }
  35. File getFolder() const { return moduleDescription.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. };
  47. Array<CompileUnit> getAllCompileUnits (build_tools::ProjectType::Target::Type forTarget =
  48. build_tools::ProjectType::Target::unspecified) const;
  49. void findAndAddCompiledUnits (ProjectExporter&, ProjectSaver*, Array<File>& result,
  50. build_tools::ProjectType::Target::Type forTarget =
  51. build_tools::ProjectType::Target::unspecified) const;
  52. ModuleDescription moduleDescription;
  53. private:
  54. void addSearchPathsToExporter (ProjectExporter&) const;
  55. void addDefinesToExporter (ProjectExporter&) const;
  56. void addCompileUnitsToExporter (ProjectExporter&, ProjectSaver&) const;
  57. void addLibsToExporter (ProjectExporter&) const;
  58. void addBrowseableCode (ProjectExporter&, const Array<File>& compiled, const File& localModuleFolder) const;
  59. mutable Array<File> sourceFiles;
  60. OwnedArray<Project::ConfigFlag> configFlags;
  61. };
  62. //==============================================================================
  63. class EnabledModulesList
  64. {
  65. public:
  66. EnabledModulesList (Project&, const ValueTree&);
  67. //==============================================================================
  68. ValueTree getState() const { return state; }
  69. StringArray getAllModules() const;
  70. void createRequiredModules (OwnedArray<LibraryModule>& modules);
  71. void sortAlphabetically();
  72. File getDefaultModulesFolder() const;
  73. int getNumModules() const { return state.getNumChildren(); }
  74. String getModuleID (int index) const { return state.getChild (index) [Ids::ID].toString(); }
  75. ModuleDescription getModuleInfo (const String& moduleID) const;
  76. bool isModuleEnabled (const String& moduleID) const;
  77. StringArray getExtraDependenciesNeeded (const String& moduleID) const;
  78. bool tryToFixMissingDependencies (const String& moduleID);
  79. bool doesModuleHaveHigherCppStandardThanProject (const String& moduleID) const;
  80. bool shouldUseGlobalPath (const String& moduleID) const;
  81. Value shouldUseGlobalPathValue (const String& moduleID) const;
  82. bool shouldShowAllModuleFilesInProject (const String& moduleID) const;
  83. Value shouldShowAllModuleFilesInProjectValue (const String& moduleID) const;
  84. bool shouldCopyModuleFilesLocally (const String& moduleID) const;
  85. Value shouldCopyModuleFilesLocallyValue (const String& moduleID) const;
  86. bool areMostModulesUsingGlobalPath() const;
  87. bool areMostModulesCopiedLocally() const;
  88. StringArray getModulesWithHigherCppStandardThanProject() const;
  89. StringArray getModulesWithMissingDependencies() const;
  90. String getHighestModuleCppStandard() const;
  91. //==============================================================================
  92. void addModule (const File& moduleManifestFile, bool copyLocally, bool useGlobalPath);
  93. void addModuleInteractive (const String& moduleID);
  94. void addModuleFromUserSelectedFile();
  95. void addModuleOfferingToCopy (const File&, bool isFromUserSpecifiedFolder);
  96. void removeModule (String moduleID);
  97. private:
  98. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  99. Project& project;
  100. CriticalSection stateLock;
  101. ValueTree state;
  102. std::unique_ptr<FileChooser> chooser;
  103. ScopedMessageBox messageBox;
  104. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EnabledModulesList)
  105. };