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.

671 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. bool isVst3ManifestEnabled() const { return vst3ManifestEnabledValue.get(); }
  233. void disableStandaloneForARAPlugIn();
  234. static StringArray getAllAUMainTypeStrings() noexcept;
  235. static Array<var> getAllAUMainTypeVars() noexcept;
  236. Array<var> getDefaultAUMainTypes() const noexcept;
  237. static StringArray getAllVSTCategoryStrings() noexcept;
  238. Array<var> getDefaultVSTCategories() const noexcept;
  239. static StringArray getAllVST3CategoryStrings() noexcept;
  240. Array<var> getDefaultVST3Categories() const noexcept;
  241. static StringArray getAllAAXCategoryStrings() noexcept;
  242. static Array<var> getAllAAXCategoryVars() noexcept;
  243. Array<var> getDefaultAAXCategories() const noexcept;
  244. bool getDefaultEnableARA() const noexcept;
  245. static StringArray getAllARAContentTypeStrings() noexcept;
  246. static Array<var> getAllARAContentTypeVars() noexcept;
  247. Array<var> getDefaultARAContentTypes() const noexcept;
  248. static StringArray getAllARATransformationFlagStrings() noexcept;
  249. static Array<var> getAllARATransformationFlagVars() noexcept;
  250. Array<var> getDefaultARATransformationFlags() const noexcept;
  251. String getAUMainTypeString() const noexcept;
  252. bool isAUSandBoxSafe() const noexcept;
  253. String getVSTCategoryString() const noexcept;
  254. String getVST3CategoryString() const noexcept;
  255. int getAAXCategory() const noexcept;
  256. int getARAContentTypes() const noexcept;
  257. int getARATransformationFlags() const noexcept;
  258. String getIAATypeCode() const;
  259. String getIAAPluginName() const;
  260. String getUnityScriptName() const { return addUnityPluginPrefixIfNecessary (getProjectNameString()) + "_UnityScript.cs"; }
  261. static String addUnityPluginPrefixIfNecessary (const String& name)
  262. {
  263. if (! name.startsWithIgnoreCase ("audioplugin"))
  264. return "audioplugin_" + name;
  265. return name;
  266. }
  267. String getLV2URI() const { return pluginLV2URIValue.get(); }
  268. //==============================================================================
  269. bool isAUPluginHost() const;
  270. bool isVSTPluginHost() const;
  271. bool isVST3PluginHost() const;
  272. bool isLV2PluginHost() const;
  273. bool isARAPluginHost() const;
  274. //==============================================================================
  275. bool shouldBuildTargetType (build_tools::ProjectType::Target::Type targetType) const noexcept;
  276. static build_tools::ProjectType::Target::Type getTargetTypeFromFilePath (const File& file, bool returnSharedTargetIfNoValidSuffix);
  277. //==============================================================================
  278. void updateDeprecatedProjectSettingsInteractively();
  279. StringPairArray getAppConfigDefs();
  280. StringPairArray getAudioPluginFlags() const;
  281. //==============================================================================
  282. class Item
  283. {
  284. public:
  285. //==============================================================================
  286. Item (Project& project, const ValueTree& itemNode, bool isModuleCode);
  287. Item (const Item& other);
  288. static Item createGroup (Project& project, const String& name, const String& uid, bool isModuleCode);
  289. void initialiseMissingProperties();
  290. //==============================================================================
  291. bool isValid() const { return state.isValid(); }
  292. bool operator== (const Item& other) const { return state == other.state && &project == &other.project; }
  293. bool operator!= (const Item& other) const { return ! operator== (other); }
  294. //==============================================================================
  295. bool isFile() const;
  296. bool isGroup() const;
  297. bool isMainGroup() const;
  298. bool isImageFile() const;
  299. bool isSourceFile() const;
  300. String getID() const;
  301. void setID (const String& newID);
  302. Item findItemWithID (const String& targetId) const; // (recursive search)
  303. String getImageFileID() const;
  304. std::unique_ptr<Drawable> loadAsImageFile() const;
  305. //==============================================================================
  306. Value getNameValue();
  307. String getName() const;
  308. File getFile() const;
  309. String getFilePath() const;
  310. void setFile (const File& file);
  311. void setFile (const build_tools::RelativePath& file);
  312. File determineGroupFolder() const;
  313. bool renameFile (const File& newFile);
  314. bool shouldBeAddedToTargetProject() const;
  315. bool shouldBeAddedToTargetExporter (const ProjectExporter&) const;
  316. bool shouldBeCompiled() const;
  317. Value getShouldCompileValue();
  318. bool shouldBeAddedToBinaryResources() const;
  319. Value getShouldAddToBinaryResourcesValue();
  320. bool shouldBeAddedToXcodeResources() const;
  321. Value getShouldAddToXcodeResourcesValue();
  322. Value getShouldInhibitWarningsValue();
  323. bool shouldInhibitWarnings() const;
  324. bool isModuleCode() const;
  325. Value getShouldSkipPCHValue();
  326. bool shouldSkipPCH() const;
  327. Value getCompilerFlagSchemeValue();
  328. String getCompilerFlagSchemeString() const;
  329. void setCompilerFlagScheme (const String&);
  330. void clearCurrentCompilerFlagScheme();
  331. //==============================================================================
  332. bool canContain (const Item& child) const;
  333. int getNumChildren() const { return state.getNumChildren(); }
  334. Item getChild (int index) const { return Item (project, state.getChild (index), belongsToModule); }
  335. Item addNewSubGroup (const String& name, int insertIndex);
  336. Item getOrCreateSubGroup (const String& name);
  337. void addChild (const Item& newChild, int insertIndex);
  338. bool addFileAtIndex (const File& file, int insertIndex, bool shouldCompile);
  339. bool addFileRetainingSortOrder (const File& file, bool shouldCompile);
  340. void addFileUnchecked (const File& file, int insertIndex, bool shouldCompile);
  341. bool addRelativeFile (const build_tools::RelativePath& file, int insertIndex, bool shouldCompile);
  342. void removeItemFromProject();
  343. void sortAlphabetically (bool keepGroupsAtStart, bool recursive);
  344. Item findItemForFile (const File& file) const;
  345. bool containsChildForFile (const build_tools::RelativePath& file) const;
  346. Item getParent() const;
  347. Item createCopy();
  348. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  349. Icon getIcon (bool isOpen = false) const;
  350. bool isIconCrossedOut() const;
  351. bool needsSaving() const noexcept;
  352. Project& project;
  353. ValueTree state;
  354. private:
  355. Item& operator= (const Item&);
  356. bool belongsToModule;
  357. };
  358. Item getMainGroup();
  359. void findAllImageItems (OwnedArray<Item>& items);
  360. //==============================================================================
  361. ValueTree getExporters();
  362. int getNumExporters();
  363. std::unique_ptr<ProjectExporter> createExporter (int index);
  364. void addNewExporter (const Identifier& exporterIdentifier);
  365. void createExporterForCurrentPlatform();
  366. struct ExporterIterator
  367. {
  368. ExporterIterator (Project& project);
  369. bool next();
  370. ProjectExporter& operator*() const { return *exporter; }
  371. ProjectExporter* operator->() const { return exporter.get(); }
  372. std::unique_ptr<ProjectExporter> exporter;
  373. int index;
  374. private:
  375. Project& project;
  376. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ExporterIterator)
  377. };
  378. //==============================================================================
  379. struct ConfigFlag
  380. {
  381. String symbol, description, sourceModuleID;
  382. ValueTreePropertyWithDefault value;
  383. };
  384. ValueTreePropertyWithDefault getConfigFlag (const String& name);
  385. bool isConfigFlagEnabled (const String& name, bool defaultIsEnabled = false) const;
  386. //==============================================================================
  387. void createEnabledModulesList();
  388. EnabledModulesList& getEnabledModules();
  389. const EnabledModulesList& getEnabledModules() const;
  390. AvailableModulesList& getExporterPathsModulesList() { return exporterPathsModulesList; }
  391. void rescanExporterPathModules (bool async = false);
  392. std::pair<String, File> getModuleWithID (const String&);
  393. //==============================================================================
  394. PropertiesFile& getStoredProperties() const;
  395. //==============================================================================
  396. UndoManager* getUndoManagerFor (const ValueTree&) const { return nullptr; }
  397. UndoManager* getUndoManager() const { return nullptr; }
  398. //==============================================================================
  399. static const char* projectFileExtension;
  400. //==============================================================================
  401. bool updateCachedFileState();
  402. String getCachedFileStateContent() const noexcept { return cachedFileState.second; }
  403. String serialiseProjectXml (std::unique_ptr<XmlElement>) const;
  404. //==============================================================================
  405. String getUniqueTargetFolderSuffixForExporter (const Identifier& exporterIdentifier, const String& baseTargetFolder);
  406. //==============================================================================
  407. bool isCurrentlySaving() const noexcept { return saver != nullptr; }
  408. bool isTemporaryProject() const noexcept { return tempDirectory != File(); }
  409. File getTemporaryDirectory() const noexcept { return tempDirectory; }
  410. void setTemporaryDirectory (const File&) noexcept;
  411. //==============================================================================
  412. ValueTree getProjectMessages() const { return projectMessages; }
  413. void addProjectMessage (const Identifier& messageToAdd, std::vector<ProjectMessages::MessageAction>&& messageActions);
  414. void removeProjectMessage (const Identifier& messageToRemove);
  415. std::vector<ProjectMessages::MessageAction> getMessageActions (const Identifier& message);
  416. //==============================================================================
  417. bool hasIncompatibleLicenseTypeAndSplashScreenSetting() const;
  418. bool isFileModificationCheckPending() const;
  419. bool isSaveAndExportDisabled() const;
  420. private:
  421. //==============================================================================
  422. void valueTreePropertyChanged (ValueTree&, const Identifier&) override;
  423. void valueTreeChildAdded (ValueTree&, ValueTree&) override;
  424. void valueTreeChildRemoved (ValueTree&, ValueTree&, int) override;
  425. void valueTreeChildOrderChanged (ValueTree&, int, int) override;
  426. //==============================================================================
  427. template <typename This>
  428. static auto& getEnabledModulesImpl (This&);
  429. //==============================================================================
  430. struct ProjectFileModificationPoller : private Timer
  431. {
  432. ProjectFileModificationPoller (Project& p);
  433. bool isCheckPending() const noexcept { return pending; }
  434. private:
  435. void timerCallback() override;
  436. void reset();
  437. void resaveProject();
  438. void reloadProjectFromDisk();
  439. Project& project;
  440. bool pending = false;
  441. };
  442. //==============================================================================
  443. ValueTree projectRoot { Ids::JUCERPROJECT };
  444. ValueTreePropertyWithDefault projectNameValue, projectUIDValue, projectLineFeedValue, projectTypeValue, versionValue, bundleIdentifierValue, companyNameValue,
  445. companyCopyrightValue, companyWebsiteValue, companyEmailValue, displaySplashScreenValue, splashScreenColourValue, cppStandardValue,
  446. headerSearchPathsValue, preprocessorDefsValue, userNotesValue, maxBinaryFileSizeValue, includeBinaryDataInJuceHeaderValue, binaryDataNamespaceValue,
  447. compilerFlagSchemesValue, postExportShellCommandPosixValue, postExportShellCommandWinValue, useAppConfigValue, addUsingNamespaceToJuceHeader;
  448. ValueTreePropertyWithDefault pluginFormatsValue, pluginNameValue, pluginDescriptionValue, pluginManufacturerValue, pluginManufacturerCodeValue,
  449. pluginCodeValue, pluginChannelConfigsValue, pluginCharacteristicsValue, pluginAUExportPrefixValue, pluginAAXIdentifierValue,
  450. pluginAUMainTypeValue, pluginAUSandboxSafeValue, pluginVSTCategoryValue, pluginVST3CategoryValue, pluginAAXCategoryValue,
  451. pluginEnableARA, pluginARAAnalyzableContentValue, pluginARAFactoryIDValue, pluginARAArchiveIDValue, pluginARACompatibleArchiveIDsValue, pluginARATransformFlagsValue,
  452. pluginVSTNumMidiInputsValue, pluginVSTNumMidiOutputsValue, pluginLV2URIValue, vst3ManifestEnabledValue;
  453. //==============================================================================
  454. std::unique_ptr<EnabledModulesList> enabledModulesList;
  455. AvailableModulesList exporterPathsModulesList;
  456. //==============================================================================
  457. void updateDeprecatedProjectSettings();
  458. //==============================================================================
  459. bool shouldWriteLegacyPluginFormatSettings = false;
  460. bool shouldWriteLegacyPluginCharacteristicsSettings = false;
  461. static Array<Identifier> getLegacyPluginFormatIdentifiers() noexcept;
  462. static Array<Identifier> getLegacyPluginCharacteristicsIdentifiers() noexcept;
  463. void writeLegacyPluginFormatSettings();
  464. void writeLegacyPluginCharacteristicsSettings();
  465. void coalescePluginFormatValues();
  466. void coalescePluginCharacteristicsValues();
  467. void updatePluginCategories();
  468. //==============================================================================
  469. File tempDirectory;
  470. std::pair<Time, String> cachedFileState;
  471. //==============================================================================
  472. StringPairArray parsedPreprocessorDefs;
  473. //==============================================================================
  474. void initialiseProjectValues();
  475. void initialiseMainGroup();
  476. void initialiseAudioPluginValues();
  477. bool setCppVersionFromOldExporterSettings();
  478. void createAudioPluginPropertyEditors (PropertyListBuilder& props);
  479. //==============================================================================
  480. void updateTitleDependencies();
  481. void updateCompanyNameDependencies();
  482. void updateProjectSettings();
  483. void updateWebsiteDependencies();
  484. ValueTree getConfigurations() const;
  485. ValueTree getConfigNode();
  486. void updateOldStyleConfigList();
  487. void moveOldPropertyFromProjectToAllExporters (Identifier name);
  488. void removeDefunctExporters();
  489. void updateOldModulePaths();
  490. //==============================================================================
  491. void licenseStateChanged() override;
  492. void changeListenerCallback (ChangeBroadcaster*) override;
  493. void availableModulesChanged (AvailableModulesList*) override;
  494. void updateLicenseWarning();
  495. void updateJUCEPathWarning();
  496. void updateModuleWarnings();
  497. void updateCppStandardWarning (bool showWarning);
  498. void updateMissingModuleDependenciesWarning (bool showWarning);
  499. void updateOldProjucerWarning (bool showWarning);
  500. void updateModuleNotFoundWarning (bool showWarning);
  501. void updateCodeWarning (Identifier identifier, String value);
  502. ValueTree projectMessages { ProjectMessages::Ids::projectMessages, {},
  503. { { ProjectMessages::Ids::notification, {} }, { ProjectMessages::Ids::warning, {} } } };
  504. std::map<Identifier, std::vector<ProjectMessages::MessageAction>> messageActions;
  505. ProjectFileModificationPoller fileModificationPoller { *this };
  506. std::unique_ptr<FileChooser> chooser;
  507. std::unique_ptr<ProjectSaver> saver;
  508. ScopedMessageBox messageBox;
  509. //==============================================================================
  510. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Project)
  511. JUCE_DECLARE_WEAK_REFERENCEABLE (Project)
  512. };