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.

142 lines
5.6KB

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