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.

669 lines
33KB

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