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.

676 lines
34KB

  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 "../Application/UserAccount/jucer_LicenseController.h"
  20. #include "Modules/jucer_AvailableModulesList.h"
  21. class ProjectExporter;
  22. class LibraryModule;
  23. class EnabledModulesList;
  24. class ProjectSaver;
  25. namespace ProjectMessages
  26. {
  27. namespace Ids
  28. {
  29. #define DECLARE_ID(name) static const Identifier name (#name)
  30. DECLARE_ID (projectMessages);
  31. DECLARE_ID (incompatibleLicense);
  32. DECLARE_ID (cppStandard);
  33. DECLARE_ID (moduleNotFound);
  34. DECLARE_ID (jucePath);
  35. DECLARE_ID (jucerFileModified);
  36. DECLARE_ID (missingModuleDependencies);
  37. DECLARE_ID (oldProjucer);
  38. DECLARE_ID (newVersionAvailable);
  39. DECLARE_ID (pluginCodeInvalid);
  40. DECLARE_ID (manufacturerCodeInvalid);
  41. DECLARE_ID (deprecatedExporter);
  42. DECLARE_ID (notification);
  43. DECLARE_ID (warning);
  44. DECLARE_ID (isVisible);
  45. #undef DECLARE_ID
  46. }
  47. inline Identifier getTypeForMessage (const Identifier& message)
  48. {
  49. static Identifier warnings[] = { Ids::incompatibleLicense, Ids::cppStandard, Ids::moduleNotFound,
  50. Ids::jucePath, Ids::jucerFileModified, Ids::missingModuleDependencies,
  51. Ids::oldProjucer, Ids::pluginCodeInvalid, Ids::manufacturerCodeInvalid,
  52. Ids::deprecatedExporter };
  53. if (std::find (std::begin (warnings), std::end (warnings), message) != std::end (warnings))
  54. return Ids::warning;
  55. if (message == Ids::newVersionAvailable)
  56. return Ids::notification;
  57. jassertfalse;
  58. return {};
  59. }
  60. inline String getTitleForMessage (const Identifier& message)
  61. {
  62. if (message == Ids::incompatibleLicense) return "Incompatible License and Splash Screen Setting";
  63. if (message == Ids::cppStandard) return "C++ Standard";
  64. if (message == Ids::moduleNotFound) return "Module Not Found";
  65. if (message == Ids::jucePath) return "JUCE Path";
  66. if (message == Ids::jucerFileModified) return "Project File Modified";
  67. if (message == Ids::missingModuleDependencies) return "Missing Module Dependencies";
  68. if (message == Ids::oldProjucer) return "Projucer Out of Date";
  69. if (message == Ids::newVersionAvailable) return "New Version Available";
  70. if (message == Ids::pluginCodeInvalid) return "Invalid Plugin Code";
  71. if (message == Ids::manufacturerCodeInvalid) return "Invalid Manufacturer Code";
  72. if (message == Ids::deprecatedExporter) return "Deprecated Exporter";
  73. jassertfalse;
  74. return {};
  75. }
  76. inline String getDescriptionForMessage (const Identifier& message)
  77. {
  78. if (message == Ids::incompatibleLicense) return "Save and export is disabled.";
  79. if (message == Ids::cppStandard) return "Module(s) have a higher C++ standard requirement than the project.";
  80. if (message == Ids::moduleNotFound) return "Module(s) could not be found at the specified paths.";
  81. if (message == Ids::jucePath) return "The path to your JUCE folder is incorrect.";
  82. if (message == Ids::jucerFileModified) return "The .jucer file has been modified since the last save.";
  83. if (message == Ids::missingModuleDependencies) return "Module(s) have missing dependencies.";
  84. if (message == Ids::oldProjucer) return "The version of the Projucer you are using is out of date.";
  85. if (message == Ids::newVersionAvailable) return "A new version of JUCE is available to download.";
  86. if (message == Ids::pluginCodeInvalid) return "The plugin code should be exactly four characters in length.";
  87. if (message == Ids::manufacturerCodeInvalid) return "The manufacturer code should be exactly four characters in length.";
  88. if (message == Ids::deprecatedExporter) return "The project includes a deprecated exporter.";
  89. jassertfalse;
  90. return {};
  91. }
  92. using MessageAction = std::pair<String, std::function<void()>>;
  93. }
  94. enum class Async { no, yes };
  95. //==============================================================================
  96. class Project final : public FileBasedDocument,
  97. private ValueTree::Listener,
  98. private LicenseController::LicenseStateListener,
  99. private ChangeListener,
  100. private AvailableModulesList::Listener
  101. {
  102. public:
  103. //==============================================================================
  104. Project (const File&);
  105. ~Project() override;
  106. //==============================================================================
  107. String getDocumentTitle() override;
  108. Result loadDocument (const File& file) override;
  109. Result saveDocument (const File& file) override;
  110. void saveDocumentAsync (const File& file, std::function<void (Result)> callback) override;
  111. void saveProject (Async, ProjectExporter* exporterToSave, std::function<void (Result)> onCompletion);
  112. void saveAndMoveTemporaryProject (bool openInIDE);
  113. Result saveResourcesOnly();
  114. void openProjectInIDE (ProjectExporter& exporterToOpen);
  115. File getLastDocumentOpened() override;
  116. void setLastDocumentOpened (const File& file) override;
  117. void setTitle (const String& newTitle);
  118. //==============================================================================
  119. File getProjectFolder() const { return getFile().getParentDirectory(); }
  120. File getGeneratedCodeFolder() const { return getFile().getSiblingFile ("JuceLibraryCode"); }
  121. File getSourceFilesFolder() const { return getProjectFolder().getChildFile ("Source"); }
  122. File getLocalModulesFolder() const { return getGeneratedCodeFolder().getChildFile ("modules"); }
  123. File getLocalModuleFolder (const String& moduleID) const { return getLocalModulesFolder().getChildFile (moduleID); }
  124. File getAppIncludeFile() const { return getGeneratedCodeFolder().getChildFile (getJuceSourceHFilename()); }
  125. File getBinaryDataCppFile (int index) const;
  126. File getBinaryDataHeaderFile() const { return getBinaryDataCppFile (0).withFileExtension (".h"); }
  127. static String getAppConfigFilename() { return "AppConfig.h"; }
  128. static String getPluginDefinesFilename() { return "JucePluginDefines.h"; }
  129. static String getJuceSourceHFilename() { return "JuceHeader.h"; }
  130. static String getJuceLV2DefinesFilename() { return "JuceLV2Defines.h"; }
  131. static String getLV2FileWriterName() { return "juce_lv2_helper"; }
  132. static String getVST3FileWriterName() { return "juce_vst3_helper"; }
  133. //==============================================================================
  134. template <class FileType>
  135. bool shouldBeAddedToBinaryResourcesByDefault (const FileType& file)
  136. {
  137. return ! file.hasFileExtension (sourceOrHeaderFileExtensions);
  138. }
  139. File resolveFilename (String filename) const;
  140. String getRelativePathForFile (const File& file) const;
  141. //==============================================================================
  142. // Creates editors for the project settings
  143. void createPropertyEditors (PropertyListBuilder&);
  144. //==============================================================================
  145. ValueTree getProjectRoot() const { return projectRoot; }
  146. Value getProjectValue (const Identifier& name) { return projectRoot.getPropertyAsValue (name, getUndoManagerFor (projectRoot)); }
  147. var getProjectVar (const Identifier& name) const { return projectRoot.getProperty (name); }
  148. const build_tools::ProjectType& getProjectType() const;
  149. String getProjectTypeString() const { return projectTypeValue.get(); }
  150. void setProjectType (const String& newProjectType) { projectTypeValue = newProjectType; }
  151. String getProjectNameString() const { return projectNameValue.get(); }
  152. String getProjectFilenameRootString() { return File::createLegalFileName (getDocumentTitle()); }
  153. String getProjectUIDString() const { return projectUIDValue.get(); }
  154. String getProjectLineFeed() const { return projectLineFeedValue.get(); }
  155. String getVersionString() const { return versionValue.get(); }
  156. String getVersionAsHex() const { return build_tools::getVersionAsHex (getVersionString()); }
  157. int getVersionAsHexInteger() const { return build_tools::getVersionAsHexInteger (getVersionString()); }
  158. void setProjectVersion (const String& newVersion) { versionValue = newVersion; }
  159. String getBundleIdentifierString() const { return bundleIdentifierValue.get(); }
  160. String getDefaultBundleIdentifierString() const;
  161. String getDefaultCompanyWebsiteString() const;
  162. String getDefaultAAXIdentifierString() const { return getDefaultBundleIdentifierString(); }
  163. String getDefaultPluginManufacturerString() const;
  164. String getDefaultLV2URI() const { return getCompanyWebsiteString() + "/plugins/" + build_tools::makeValidIdentifier (getProjectNameString(), false, true, false); }
  165. String getDefaultARAFactoryIDString() const;
  166. String getDefaultARADocumentArchiveID() const;
  167. String getDefaultARACompatibleArchiveIDs() const;
  168. String getCompanyNameString() const { return companyNameValue.get(); }
  169. String getCompanyCopyrightString() const { return companyCopyrightValue.get(); }
  170. String getCompanyWebsiteString() const { return companyWebsiteValue.get(); }
  171. String getCompanyEmailString() const { return companyEmailValue.get(); }
  172. String getHeaderSearchPathsString() const { return headerSearchPathsValue.get(); }
  173. StringPairArray getPreprocessorDefs() const { return parsedPreprocessorDefs; }
  174. int getMaxBinaryFileSize() const { return maxBinaryFileSizeValue.get(); }
  175. bool shouldIncludeBinaryInJuceHeader() const { return includeBinaryDataInJuceHeaderValue.get(); }
  176. String getBinaryDataNamespaceString() const { return binaryDataNamespaceValue.get(); }
  177. bool shouldDisplaySplashScreen() const { return displaySplashScreenValue.get(); }
  178. String getSplashScreenColourString() const { return splashScreenColourValue.get(); }
  179. static StringArray getCppStandardStrings() { return { "C++17", "C++20", "Use Latest" }; }
  180. static Array<var> getCppStandardVars() { return { "17", "20", "latest" }; }
  181. static String getLatestNumberedCppStandardString()
  182. {
  183. auto cppStandardVars = getCppStandardVars();
  184. return cppStandardVars[cppStandardVars.size() - 2];
  185. }
  186. String getCppStandardString() const { return cppStandardValue.get(); }
  187. StringArray getCompilerFlagSchemes() const;
  188. void addCompilerFlagScheme (const String&);
  189. void removeCompilerFlagScheme (const String&);
  190. String getPostExportShellCommandPosixString() const { return postExportShellCommandPosixValue.get(); }
  191. String getPostExportShellCommandWinString() const { return postExportShellCommandWinValue.get(); }
  192. bool shouldUseAppConfig() const { return useAppConfigValue.get(); }
  193. bool shouldAddUsingNamespaceToJuceHeader() const { return addUsingNamespaceToJuceHeader.get(); }
  194. //==============================================================================
  195. String getPluginNameString() const { return pluginNameValue.get(); }
  196. String getPluginDescriptionString() const { return pluginDescriptionValue.get();}
  197. String getPluginManufacturerString() const { return pluginManufacturerValue.get(); }
  198. String getPluginManufacturerCodeString() const { return pluginManufacturerCodeValue.get(); }
  199. String getPluginCodeString() const { return pluginCodeValue.get(); }
  200. String getPluginChannelConfigsString() const { return pluginChannelConfigsValue.get(); }
  201. String getAAXIdentifierString() const { return pluginAAXIdentifierValue.get(); }
  202. String getARAFactoryIDString() const { return pluginARAFactoryIDValue.get(); }
  203. String getARADocumentArchiveIDString() const { return pluginARAArchiveIDValue.get(); }
  204. String getARACompatibleArchiveIDStrings() const { return pluginARACompatibleArchiveIDsValue.get(); }
  205. String getPluginAUExportPrefixString() const { return pluginAUExportPrefixValue.get(); }
  206. String getPluginAUMainTypeString() const { return pluginAUMainTypeValue.get(); }
  207. String getVSTNumMIDIInputsString() const { return pluginVSTNumMidiInputsValue.get(); }
  208. String getVSTNumMIDIOutputsString() const { return pluginVSTNumMidiOutputsValue.get(); }
  209. static bool checkMultiChoiceVar (const ValueTreePropertyWithDefault& valueToCheck, Identifier idToCheck) noexcept
  210. {
  211. if (! valueToCheck.get().isArray())
  212. return false;
  213. auto v = valueToCheck.get();
  214. if (auto* varArray = v.getArray())
  215. return varArray->contains (idToCheck.toString());
  216. return false;
  217. }
  218. bool isAudioPluginProject() const { return getProjectType().isAudioPlugin(); }
  219. bool shouldBuildVST() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildVST); }
  220. bool shouldBuildVST3() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildVST3); }
  221. bool shouldBuildAU() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildAU); }
  222. bool shouldBuildAUv3() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildAUv3); }
  223. bool shouldBuildAAX() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildAAX); }
  224. bool shouldBuildStandalonePlugin() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildStandalone); }
  225. bool shouldBuildUnityPlugin() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildUnity); }
  226. bool shouldBuildLV2() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildLV2); }
  227. bool shouldEnableIAA() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::enableIAA); }
  228. bool shouldEnableARA() const { return (isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::enableARA)) || getProjectType().isARAAudioPlugin(); }
  229. bool isPluginSynth() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginIsSynth); }
  230. bool pluginWantsMidiInput() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginWantsMidiIn); }
  231. bool pluginProducesMidiOutput() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginProducesMidiOut); }
  232. bool isPluginMidiEffect() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginIsMidiEffectPlugin); }
  233. bool pluginEditorNeedsKeyFocus() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginEditorRequiresKeys); }
  234. bool isPluginAAXBypassDisabled() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginAAXDisableBypass); }
  235. bool isPluginAAXMultiMonoDisabled() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginAAXDisableMultiMono); }
  236. void disableStandaloneForARAPlugIn();
  237. static StringArray getAllAUMainTypeStrings() noexcept;
  238. static Array<var> getAllAUMainTypeVars() noexcept;
  239. Array<var> getDefaultAUMainTypes() const noexcept;
  240. static StringArray getAllVSTCategoryStrings() noexcept;
  241. Array<var> getDefaultVSTCategories() const noexcept;
  242. static StringArray getAllVST3CategoryStrings() noexcept;
  243. Array<var> getDefaultVST3Categories() const noexcept;
  244. static StringArray getAllAAXCategoryStrings() noexcept;
  245. static Array<var> getAllAAXCategoryVars() noexcept;
  246. Array<var> getDefaultAAXCategories() const noexcept;
  247. bool getDefaultEnableARA() const noexcept;
  248. static StringArray getAllARAContentTypeStrings() noexcept;
  249. static Array<var> getAllARAContentTypeVars() noexcept;
  250. Array<var> getDefaultARAContentTypes() const noexcept;
  251. static StringArray getAllARATransformationFlagStrings() noexcept;
  252. static Array<var> getAllARATransformationFlagVars() noexcept;
  253. Array<var> getDefaultARATransformationFlags() const noexcept;
  254. String getAUMainTypeString() const noexcept;
  255. bool isAUSandBoxSafe() const noexcept;
  256. String getVSTCategoryString() const noexcept;
  257. String getVST3CategoryString() const noexcept;
  258. int getAAXCategory() const noexcept;
  259. int getARAContentTypes() const noexcept;
  260. int getARATransformationFlags() const noexcept;
  261. String getIAATypeCode() const;
  262. String getIAAPluginName() const;
  263. String getUnityScriptName() const { return addUnityPluginPrefixIfNecessary (getProjectNameString()) + "_UnityScript.cs"; }
  264. static String addUnityPluginPrefixIfNecessary (const String& name)
  265. {
  266. if (! name.startsWithIgnoreCase ("audioplugin"))
  267. return "audioplugin_" + name;
  268. return name;
  269. }
  270. String getLV2URI() const { return pluginLV2URIValue.get(); }
  271. //==============================================================================
  272. bool isAUPluginHost() const;
  273. bool isVSTPluginHost() const;
  274. bool isVST3PluginHost() const;
  275. bool isLV2PluginHost() const;
  276. bool isARAPluginHost() const;
  277. //==============================================================================
  278. bool shouldBuildTargetType (build_tools::ProjectType::Target::Type targetType) const noexcept;
  279. static build_tools::ProjectType::Target::Type getTargetTypeFromFilePath (const File& file, bool returnSharedTargetIfNoValidSuffix);
  280. //==============================================================================
  281. void updateDeprecatedProjectSettingsInteractively();
  282. StringPairArray getAppConfigDefs();
  283. StringPairArray getAudioPluginFlags() const;
  284. //==============================================================================
  285. class Item
  286. {
  287. public:
  288. //==============================================================================
  289. Item (Project& project, const ValueTree& itemNode, bool isModuleCode);
  290. Item (const Item& other);
  291. static Item createGroup (Project& project, const String& name, const String& uid, bool isModuleCode);
  292. void initialiseMissingProperties();
  293. //==============================================================================
  294. bool isValid() const { return state.isValid(); }
  295. bool operator== (const Item& other) const { return state == other.state && &project == &other.project; }
  296. bool operator!= (const Item& other) const { return ! operator== (other); }
  297. //==============================================================================
  298. bool isFile() const;
  299. bool isGroup() const;
  300. bool isMainGroup() const;
  301. bool isImageFile() const;
  302. bool isSourceFile() const;
  303. String getID() const;
  304. void setID (const String& newID);
  305. Item findItemWithID (const String& targetId) const; // (recursive search)
  306. String getImageFileID() const;
  307. std::unique_ptr<Drawable> loadAsImageFile() const;
  308. //==============================================================================
  309. Value getNameValue();
  310. String getName() const;
  311. File getFile() const;
  312. String getFilePath() const;
  313. void setFile (const File& file);
  314. void setFile (const build_tools::RelativePath& file);
  315. File determineGroupFolder() const;
  316. bool renameFile (const File& newFile);
  317. bool shouldBeAddedToTargetProject() const;
  318. bool shouldBeAddedToTargetExporter (const ProjectExporter&) const;
  319. bool shouldBeCompiled() const;
  320. Value getShouldCompileValue();
  321. bool shouldBeAddedToBinaryResources() const;
  322. Value getShouldAddToBinaryResourcesValue();
  323. bool shouldBeAddedToXcodeResources() const;
  324. Value getShouldAddToXcodeResourcesValue();
  325. Value getShouldInhibitWarningsValue();
  326. bool shouldInhibitWarnings() const;
  327. bool isModuleCode() const;
  328. Value getShouldSkipPCHValue();
  329. bool shouldSkipPCH() const;
  330. Value getCompilerFlagSchemeValue();
  331. String getCompilerFlagSchemeString() const;
  332. void setCompilerFlagScheme (const String&);
  333. void clearCurrentCompilerFlagScheme();
  334. //==============================================================================
  335. bool canContain (const Item& child) const;
  336. int getNumChildren() const { return state.getNumChildren(); }
  337. Item getChild (int index) const { return Item (project, state.getChild (index), belongsToModule); }
  338. Item addNewSubGroup (const String& name, int insertIndex);
  339. Item getOrCreateSubGroup (const String& name);
  340. void addChild (const Item& newChild, int insertIndex);
  341. bool addFileAtIndex (const File& file, int insertIndex, bool shouldCompile);
  342. bool addFileRetainingSortOrder (const File& file, bool shouldCompile);
  343. void addFileUnchecked (const File& file, int insertIndex, bool shouldCompile);
  344. bool addRelativeFile (const build_tools::RelativePath& file, int insertIndex, bool shouldCompile);
  345. void removeItemFromProject();
  346. void sortAlphabetically (bool keepGroupsAtStart, bool recursive);
  347. Item findItemForFile (const File& file) const;
  348. bool containsChildForFile (const build_tools::RelativePath& file) const;
  349. Item getParent() const;
  350. Item createCopy();
  351. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  352. Icon getIcon (bool isOpen = false) const;
  353. bool isIconCrossedOut() const;
  354. bool needsSaving() const noexcept;
  355. Project& project;
  356. ValueTree state;
  357. private:
  358. Item& operator= (const Item&);
  359. bool belongsToModule;
  360. };
  361. Item getMainGroup();
  362. void findAllImageItems (OwnedArray<Item>& items);
  363. //==============================================================================
  364. ValueTree getExporters();
  365. int getNumExporters();
  366. std::unique_ptr<ProjectExporter> createExporter (int index);
  367. void addNewExporter (const Identifier& exporterIdentifier);
  368. void createExporterForCurrentPlatform();
  369. struct ExporterIterator
  370. {
  371. ExporterIterator (Project& project);
  372. bool next();
  373. ProjectExporter& operator*() const { return *exporter; }
  374. ProjectExporter* operator->() const { return exporter.get(); }
  375. std::unique_ptr<ProjectExporter> exporter;
  376. int index;
  377. private:
  378. Project& project;
  379. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ExporterIterator)
  380. };
  381. //==============================================================================
  382. struct ConfigFlag
  383. {
  384. String symbol, description, sourceModuleID;
  385. ValueTreePropertyWithDefault value;
  386. };
  387. ValueTreePropertyWithDefault getConfigFlag (const String& name);
  388. bool isConfigFlagEnabled (const String& name, bool defaultIsEnabled = false) const;
  389. //==============================================================================
  390. void createEnabledModulesList();
  391. EnabledModulesList& getEnabledModules();
  392. const EnabledModulesList& getEnabledModules() const;
  393. AvailableModulesList& getExporterPathsModulesList() { return exporterPathsModulesList; }
  394. void rescanExporterPathModules (bool async = false);
  395. std::pair<String, File> getModuleWithID (const String&);
  396. //==============================================================================
  397. PropertiesFile& getStoredProperties() const;
  398. //==============================================================================
  399. UndoManager* getUndoManagerFor (const ValueTree&) const { return nullptr; }
  400. UndoManager* getUndoManager() const { return nullptr; }
  401. //==============================================================================
  402. static const char* projectFileExtension;
  403. //==============================================================================
  404. bool updateCachedFileState();
  405. String getCachedFileStateContent() const noexcept { return cachedFileState.second; }
  406. String serialiseProjectXml (std::unique_ptr<XmlElement>) const;
  407. //==============================================================================
  408. String getUniqueTargetFolderSuffixForExporter (const Identifier& exporterIdentifier, const String& baseTargetFolder);
  409. //==============================================================================
  410. bool isCurrentlySaving() const noexcept { return saver != nullptr; }
  411. bool isTemporaryProject() const noexcept { return tempDirectory != File(); }
  412. File getTemporaryDirectory() const noexcept { return tempDirectory; }
  413. void setTemporaryDirectory (const File&) noexcept;
  414. //==============================================================================
  415. ValueTree getProjectMessages() const { return projectMessages; }
  416. void addProjectMessage (const Identifier& messageToAdd, std::vector<ProjectMessages::MessageAction>&& messageActions);
  417. void removeProjectMessage (const Identifier& messageToRemove);
  418. std::vector<ProjectMessages::MessageAction> getMessageActions (const Identifier& message);
  419. //==============================================================================
  420. bool hasIncompatibleLicenseTypeAndSplashScreenSetting() const;
  421. bool isFileModificationCheckPending() const;
  422. bool isSaveAndExportDisabled() const;
  423. private:
  424. //==============================================================================
  425. void valueTreePropertyChanged (ValueTree&, const Identifier&) override;
  426. void valueTreeChildAdded (ValueTree&, ValueTree&) override;
  427. void valueTreeChildRemoved (ValueTree&, ValueTree&, int) override;
  428. void valueTreeChildOrderChanged (ValueTree&, int, int) override;
  429. void valueTreeChildAddedOrRemoved (ValueTree&, ValueTree&);
  430. //==============================================================================
  431. template <typename This>
  432. static auto& getEnabledModulesImpl (This&);
  433. //==============================================================================
  434. struct ProjectFileModificationPoller final : private Timer
  435. {
  436. ProjectFileModificationPoller (Project& p);
  437. bool isCheckPending() const noexcept { return pending; }
  438. private:
  439. void timerCallback() override;
  440. void reset();
  441. void resaveProject();
  442. void reloadProjectFromDisk();
  443. Project& project;
  444. bool pending = false;
  445. };
  446. //==============================================================================
  447. ValueTree projectRoot { Ids::JUCERPROJECT };
  448. ValueTreePropertyWithDefault projectNameValue, projectUIDValue, projectLineFeedValue, projectTypeValue, versionValue, bundleIdentifierValue, companyNameValue,
  449. companyCopyrightValue, companyWebsiteValue, companyEmailValue, displaySplashScreenValue, splashScreenColourValue, cppStandardValue,
  450. headerSearchPathsValue, preprocessorDefsValue, userNotesValue, maxBinaryFileSizeValue, includeBinaryDataInJuceHeaderValue, binaryDataNamespaceValue,
  451. compilerFlagSchemesValue, postExportShellCommandPosixValue, postExportShellCommandWinValue, useAppConfigValue, addUsingNamespaceToJuceHeader;
  452. ValueTreePropertyWithDefault pluginFormatsValue, pluginNameValue, pluginDescriptionValue, pluginManufacturerValue, pluginManufacturerCodeValue,
  453. pluginCodeValue, pluginChannelConfigsValue, pluginCharacteristicsValue, pluginAUExportPrefixValue, pluginAAXIdentifierValue,
  454. pluginAUMainTypeValue, pluginAUSandboxSafeValue, pluginVSTCategoryValue, pluginVST3CategoryValue, pluginAAXCategoryValue,
  455. pluginEnableARA, pluginARAAnalyzableContentValue, pluginARAFactoryIDValue, pluginARAArchiveIDValue, pluginARACompatibleArchiveIDsValue, pluginARATransformFlagsValue,
  456. pluginVSTNumMidiInputsValue, pluginVSTNumMidiOutputsValue, pluginLV2URIValue;
  457. //==============================================================================
  458. std::unique_ptr<EnabledModulesList> enabledModulesList;
  459. AvailableModulesList exporterPathsModulesList;
  460. //==============================================================================
  461. void updateDeprecatedProjectSettings();
  462. //==============================================================================
  463. bool shouldWriteLegacyPluginFormatSettings = false;
  464. bool shouldWriteLegacyPluginCharacteristicsSettings = false;
  465. static Array<Identifier> getLegacyPluginFormatIdentifiers() noexcept;
  466. static Array<Identifier> getLegacyPluginCharacteristicsIdentifiers() noexcept;
  467. void writeLegacyPluginFormatSettings();
  468. void writeLegacyPluginCharacteristicsSettings();
  469. void coalescePluginFormatValues();
  470. void coalescePluginCharacteristicsValues();
  471. void updatePluginCategories();
  472. //==============================================================================
  473. File tempDirectory;
  474. std::pair<Time, String> cachedFileState;
  475. //==============================================================================
  476. StringPairArray parsedPreprocessorDefs;
  477. //==============================================================================
  478. void initialiseProjectValues();
  479. void initialiseMainGroup();
  480. void initialiseAudioPluginValues();
  481. bool setCppVersionFromOldExporterSettings();
  482. void createAudioPluginPropertyEditors (PropertyListBuilder& props);
  483. //==============================================================================
  484. void updateTitleDependencies();
  485. void updateCompanyNameDependencies();
  486. void updateProjectSettings();
  487. void updateWebsiteDependencies();
  488. ValueTree getConfigurations() const;
  489. ValueTree getConfigNode();
  490. void updateOldStyleConfigList();
  491. void moveOldPropertyFromProjectToAllExporters (Identifier name);
  492. void removeDefunctExporters();
  493. void updateOldModulePaths();
  494. //==============================================================================
  495. void licenseStateChanged() override;
  496. void changeListenerCallback (ChangeBroadcaster*) override;
  497. void availableModulesChanged (AvailableModulesList*) override;
  498. void updateLicenseWarning();
  499. void updateJUCEPathWarning();
  500. void updateModuleWarnings();
  501. void updateExporterWarnings();
  502. void updateCppStandardWarning (bool showWarning);
  503. void updateMissingModuleDependenciesWarning (bool showWarning);
  504. void updateOldProjucerWarning (bool showWarning);
  505. void updateModuleNotFoundWarning (bool showWarning);
  506. void updateCodeWarning (Identifier identifier, String value);
  507. ValueTree projectMessages { ProjectMessages::Ids::projectMessages, {},
  508. { { ProjectMessages::Ids::notification, {} }, { ProjectMessages::Ids::warning, {} } } };
  509. std::map<Identifier, std::vector<ProjectMessages::MessageAction>> messageActions;
  510. ProjectFileModificationPoller fileModificationPoller { *this };
  511. std::unique_ptr<FileChooser> chooser;
  512. std::unique_ptr<ProjectSaver> saver;
  513. ScopedMessageBox messageBox;
  514. //==============================================================================
  515. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Project)
  516. JUCE_DECLARE_WEAK_REFERENCEABLE (Project)
  517. };