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.

660 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. //==============================================================================
  129. template <class FileType>
  130. bool shouldBeAddedToBinaryResourcesByDefault (const FileType& file)
  131. {
  132. return ! file.hasFileExtension (sourceOrHeaderFileExtensions);
  133. }
  134. File resolveFilename (String filename) const;
  135. String getRelativePathForFile (const File& file) const;
  136. //==============================================================================
  137. // Creates editors for the project settings
  138. void createPropertyEditors (PropertyListBuilder&);
  139. //==============================================================================
  140. ValueTree getProjectRoot() const { return projectRoot; }
  141. Value getProjectValue (const Identifier& name) { return projectRoot.getPropertyAsValue (name, getUndoManagerFor (projectRoot)); }
  142. var getProjectVar (const Identifier& name) const { return projectRoot.getProperty (name); }
  143. const build_tools::ProjectType& getProjectType() const;
  144. String getProjectTypeString() const { return projectTypeValue.get(); }
  145. void setProjectType (const String& newProjectType) { projectTypeValue = newProjectType; }
  146. String getProjectNameString() const { return projectNameValue.get(); }
  147. String getProjectFilenameRootString() { return File::createLegalFileName (getDocumentTitle()); }
  148. String getProjectUIDString() const { return projectUIDValue.get(); }
  149. String getProjectLineFeed() const { return projectLineFeedValue.get(); }
  150. String getVersionString() const { return versionValue.get(); }
  151. String getVersionAsHex() const { return build_tools::getVersionAsHex (getVersionString()); }
  152. int getVersionAsHexInteger() const { return build_tools::getVersionAsHexInteger (getVersionString()); }
  153. void setProjectVersion (const String& newVersion) { versionValue = newVersion; }
  154. String getBundleIdentifierString() const { return bundleIdentifierValue.get(); }
  155. String getDefaultBundleIdentifierString() const;
  156. String getDefaultCompanyWebsiteString() const;
  157. String getDefaultAAXIdentifierString() const { return getDefaultBundleIdentifierString(); }
  158. String getDefaultPluginManufacturerString() const;
  159. String getDefaultLV2URI() const { return getCompanyWebsiteString() + "/plugins/" + build_tools::makeValidIdentifier (getProjectNameString(), false, true, false); }
  160. String getDefaultARAFactoryIDString() const;
  161. String getDefaultARADocumentArchiveID() const;
  162. String getDefaultARACompatibleArchiveIDs() const;
  163. String getCompanyNameString() const { return companyNameValue.get(); }
  164. String getCompanyCopyrightString() const { return companyCopyrightValue.get(); }
  165. String getCompanyWebsiteString() const { return companyWebsiteValue.get(); }
  166. String getCompanyEmailString() const { return companyEmailValue.get(); }
  167. String getHeaderSearchPathsString() const { return headerSearchPathsValue.get(); }
  168. StringPairArray getPreprocessorDefs() const { return parsedPreprocessorDefs; }
  169. int getMaxBinaryFileSize() const { return maxBinaryFileSizeValue.get(); }
  170. bool shouldIncludeBinaryInJuceHeader() const { return includeBinaryDataInJuceHeaderValue.get(); }
  171. String getBinaryDataNamespaceString() const { return binaryDataNamespaceValue.get(); }
  172. bool shouldDisplaySplashScreen() const { return displaySplashScreenValue.get(); }
  173. String getSplashScreenColourString() const { return splashScreenColourValue.get(); }
  174. static StringArray getCppStandardStrings() { return { "C++14", "C++17", "C++20", "Use Latest" }; }
  175. static Array<var> getCppStandardVars() { return { "14", "17", "20", "latest" }; }
  176. static String getLatestNumberedCppStandardString()
  177. {
  178. auto cppStandardVars = getCppStandardVars();
  179. return cppStandardVars[cppStandardVars.size() - 2];
  180. }
  181. String getCppStandardString() const { return cppStandardValue.get(); }
  182. StringArray getCompilerFlagSchemes() const;
  183. void addCompilerFlagScheme (const String&);
  184. void removeCompilerFlagScheme (const String&);
  185. String getPostExportShellCommandPosixString() const { return postExportShellCommandPosixValue.get(); }
  186. String getPostExportShellCommandWinString() const { return postExportShellCommandWinValue.get(); }
  187. bool shouldUseAppConfig() const { return useAppConfigValue.get(); }
  188. bool shouldAddUsingNamespaceToJuceHeader() const { return addUsingNamespaceToJuceHeader.get(); }
  189. //==============================================================================
  190. String getPluginNameString() const { return pluginNameValue.get(); }
  191. String getPluginDescriptionString() const { return pluginDescriptionValue.get();}
  192. String getPluginManufacturerString() const { return pluginManufacturerValue.get(); }
  193. String getPluginManufacturerCodeString() const { return pluginManufacturerCodeValue.get(); }
  194. String getPluginCodeString() const { return pluginCodeValue.get(); }
  195. String getPluginChannelConfigsString() const { return pluginChannelConfigsValue.get(); }
  196. String getAAXIdentifierString() const { return pluginAAXIdentifierValue.get(); }
  197. String getARAFactoryIDString() const { return pluginARAFactoryIDValue.get(); }
  198. String getARADocumentArchiveIDString() const { return pluginARAArchiveIDValue.get(); }
  199. String getARACompatibleArchiveIDStrings() const { return pluginARACompatibleArchiveIDsValue.get(); }
  200. String getPluginAUExportPrefixString() const { return pluginAUExportPrefixValue.get(); }
  201. String getPluginAUMainTypeString() const { return pluginAUMainTypeValue.get(); }
  202. String getVSTNumMIDIInputsString() const { return pluginVSTNumMidiInputsValue.get(); }
  203. String getVSTNumMIDIOutputsString() const { return pluginVSTNumMidiOutputsValue.get(); }
  204. static bool checkMultiChoiceVar (const ValueTreePropertyWithDefault& valueToCheck, Identifier idToCheck) noexcept
  205. {
  206. if (! valueToCheck.get().isArray())
  207. return false;
  208. auto v = valueToCheck.get();
  209. if (auto* varArray = v.getArray())
  210. return varArray->contains (idToCheck.toString());
  211. return false;
  212. }
  213. bool isAudioPluginProject() const { return getProjectType().isAudioPlugin(); }
  214. bool shouldBuildVST() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildVST); }
  215. bool shouldBuildVST3() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildVST3); }
  216. bool shouldBuildAU() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildAU); }
  217. bool shouldBuildAUv3() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildAUv3); }
  218. bool shouldBuildAAX() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildAAX); }
  219. bool shouldBuildStandalonePlugin() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildStandalone); }
  220. bool shouldBuildUnityPlugin() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildUnity); }
  221. bool shouldBuildLV2() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildLV2); }
  222. bool shouldEnableIAA() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::enableIAA); }
  223. bool shouldEnableARA() const { return (isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::enableARA)) || getProjectType().isARAAudioPlugin(); }
  224. bool isPluginSynth() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginIsSynth); }
  225. bool pluginWantsMidiInput() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginWantsMidiIn); }
  226. bool pluginProducesMidiOutput() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginProducesMidiOut); }
  227. bool isPluginMidiEffect() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginIsMidiEffectPlugin); }
  228. bool pluginEditorNeedsKeyFocus() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginEditorRequiresKeys); }
  229. bool isPluginAAXBypassDisabled() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginAAXDisableBypass); }
  230. bool isPluginAAXMultiMonoDisabled() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginAAXDisableMultiMono); }
  231. void disableStandaloneForARAPlugIn();
  232. static StringArray getAllAUMainTypeStrings() noexcept;
  233. static Array<var> getAllAUMainTypeVars() noexcept;
  234. Array<var> getDefaultAUMainTypes() const noexcept;
  235. static StringArray getAllVSTCategoryStrings() noexcept;
  236. Array<var> getDefaultVSTCategories() const noexcept;
  237. static StringArray getAllVST3CategoryStrings() noexcept;
  238. Array<var> getDefaultVST3Categories() const noexcept;
  239. static StringArray getAllAAXCategoryStrings() noexcept;
  240. static Array<var> getAllAAXCategoryVars() noexcept;
  241. Array<var> getDefaultAAXCategories() const noexcept;
  242. bool getDefaultEnableARA() const noexcept;
  243. static StringArray getAllARAContentTypeStrings() noexcept;
  244. static Array<var> getAllARAContentTypeVars() noexcept;
  245. Array<var> getDefaultARAContentTypes() const noexcept;
  246. static StringArray getAllARATransformationFlagStrings() noexcept;
  247. static Array<var> getAllARATransformationFlagVars() noexcept;
  248. Array<var> getDefaultARATransformationFlags() const noexcept;
  249. String getAUMainTypeString() const noexcept;
  250. bool isAUSandBoxSafe() const noexcept;
  251. String getVSTCategoryString() const noexcept;
  252. String getVST3CategoryString() const noexcept;
  253. int getAAXCategory() const noexcept;
  254. int getARAContentTypes() const noexcept;
  255. int getARATransformationFlags() const noexcept;
  256. String getIAATypeCode() const;
  257. String getIAAPluginName() const;
  258. String getUnityScriptName() const { return addUnityPluginPrefixIfNecessary (getProjectNameString()) + "_UnityScript.cs"; }
  259. static String addUnityPluginPrefixIfNecessary (const String& name)
  260. {
  261. if (! name.startsWithIgnoreCase ("audioplugin"))
  262. return "audioplugin_" + name;
  263. return name;
  264. }
  265. String getLV2URI() const { return pluginLV2URIValue.get(); }
  266. //==============================================================================
  267. bool isAUPluginHost();
  268. bool isVSTPluginHost();
  269. bool isVST3PluginHost();
  270. bool isLV2PluginHost();
  271. bool isARAPluginHost();
  272. //==============================================================================
  273. bool shouldBuildTargetType (build_tools::ProjectType::Target::Type targetType) const noexcept;
  274. static build_tools::ProjectType::Target::Type getTargetTypeFromFilePath (const File& file, bool returnSharedTargetIfNoValidSuffix);
  275. //==============================================================================
  276. void updateDeprecatedProjectSettingsInteractively();
  277. StringPairArray getAppConfigDefs();
  278. StringPairArray getAudioPluginFlags() const;
  279. //==============================================================================
  280. class Item
  281. {
  282. public:
  283. //==============================================================================
  284. Item (Project& project, const ValueTree& itemNode, bool isModuleCode);
  285. Item (const Item& other);
  286. static Item createGroup (Project& project, const String& name, const String& uid, bool isModuleCode);
  287. void initialiseMissingProperties();
  288. //==============================================================================
  289. bool isValid() const { return state.isValid(); }
  290. bool operator== (const Item& other) const { return state == other.state && &project == &other.project; }
  291. bool operator!= (const Item& other) const { return ! operator== (other); }
  292. //==============================================================================
  293. bool isFile() const;
  294. bool isGroup() const;
  295. bool isMainGroup() const;
  296. bool isImageFile() const;
  297. bool isSourceFile() const;
  298. String getID() const;
  299. void setID (const String& newID);
  300. Item findItemWithID (const String& targetId) const; // (recursive search)
  301. String getImageFileID() const;
  302. std::unique_ptr<Drawable> loadAsImageFile() const;
  303. //==============================================================================
  304. Value getNameValue();
  305. String getName() const;
  306. File getFile() const;
  307. String getFilePath() const;
  308. void setFile (const File& file);
  309. void setFile (const build_tools::RelativePath& file);
  310. File determineGroupFolder() const;
  311. bool renameFile (const File& newFile);
  312. bool shouldBeAddedToTargetProject() const;
  313. bool shouldBeAddedToTargetExporter (const ProjectExporter&) const;
  314. bool shouldBeCompiled() const;
  315. Value getShouldCompileValue();
  316. bool shouldBeAddedToBinaryResources() const;
  317. Value getShouldAddToBinaryResourcesValue();
  318. bool shouldBeAddedToXcodeResources() const;
  319. Value getShouldAddToXcodeResourcesValue();
  320. Value getShouldInhibitWarningsValue();
  321. bool shouldInhibitWarnings() const;
  322. bool isModuleCode() const;
  323. Value getShouldSkipPCHValue();
  324. bool shouldSkipPCH() const;
  325. Value getCompilerFlagSchemeValue();
  326. String getCompilerFlagSchemeString() const;
  327. void setCompilerFlagScheme (const String&);
  328. void clearCurrentCompilerFlagScheme();
  329. //==============================================================================
  330. bool canContain (const Item& child) const;
  331. int getNumChildren() const { return state.getNumChildren(); }
  332. Item getChild (int index) const { return Item (project, state.getChild (index), belongsToModule); }
  333. Item addNewSubGroup (const String& name, int insertIndex);
  334. Item getOrCreateSubGroup (const String& name);
  335. void addChild (const Item& newChild, int insertIndex);
  336. bool addFileAtIndex (const File& file, int insertIndex, bool shouldCompile);
  337. bool addFileRetainingSortOrder (const File& file, bool shouldCompile);
  338. void addFileUnchecked (const File& file, int insertIndex, bool shouldCompile);
  339. bool addRelativeFile (const build_tools::RelativePath& file, int insertIndex, bool shouldCompile);
  340. void removeItemFromProject();
  341. void sortAlphabetically (bool keepGroupsAtStart, bool recursive);
  342. Item findItemForFile (const File& file) const;
  343. bool containsChildForFile (const build_tools::RelativePath& file) const;
  344. Item getParent() const;
  345. Item createCopy();
  346. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  347. Icon getIcon (bool isOpen = false) const;
  348. bool isIconCrossedOut() const;
  349. bool needsSaving() const noexcept;
  350. Project& project;
  351. ValueTree state;
  352. private:
  353. Item& operator= (const Item&);
  354. bool belongsToModule;
  355. };
  356. Item getMainGroup();
  357. void findAllImageItems (OwnedArray<Item>& items);
  358. //==============================================================================
  359. ValueTree getExporters();
  360. int getNumExporters();
  361. std::unique_ptr<ProjectExporter> createExporter (int index);
  362. void addNewExporter (const Identifier& exporterIdentifier);
  363. void createExporterForCurrentPlatform();
  364. struct ExporterIterator
  365. {
  366. ExporterIterator (Project& project);
  367. bool next();
  368. ProjectExporter& operator*() const { return *exporter; }
  369. ProjectExporter* operator->() const { return exporter.get(); }
  370. std::unique_ptr<ProjectExporter> exporter;
  371. int index;
  372. private:
  373. Project& project;
  374. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ExporterIterator)
  375. };
  376. //==============================================================================
  377. struct ConfigFlag
  378. {
  379. String symbol, description, sourceModuleID;
  380. ValueTreePropertyWithDefault value;
  381. };
  382. ValueTreePropertyWithDefault getConfigFlag (const String& name);
  383. bool isConfigFlagEnabled (const String& name, bool defaultIsEnabled = false) const;
  384. //==============================================================================
  385. EnabledModulesList& getEnabledModules();
  386. AvailableModulesList& getExporterPathsModulesList() { return exporterPathsModulesList; }
  387. void rescanExporterPathModules (bool async = false);
  388. std::pair<String, File> getModuleWithID (const String&);
  389. //==============================================================================
  390. PropertiesFile& getStoredProperties() const;
  391. //==============================================================================
  392. UndoManager* getUndoManagerFor (const ValueTree&) const { return nullptr; }
  393. UndoManager* getUndoManager() const { return nullptr; }
  394. //==============================================================================
  395. static const char* projectFileExtension;
  396. //==============================================================================
  397. bool updateCachedFileState();
  398. String getCachedFileStateContent() const noexcept { return cachedFileState.second; }
  399. String serialiseProjectXml (std::unique_ptr<XmlElement>) const;
  400. //==============================================================================
  401. String getUniqueTargetFolderSuffixForExporter (const Identifier& exporterIdentifier, const String& baseTargetFolder);
  402. //==============================================================================
  403. bool isCurrentlySaving() const noexcept { return saver != nullptr; }
  404. bool isTemporaryProject() const noexcept { return tempDirectory != File(); }
  405. File getTemporaryDirectory() const noexcept { return tempDirectory; }
  406. void setTemporaryDirectory (const File&) noexcept;
  407. //==============================================================================
  408. ValueTree getProjectMessages() const { return projectMessages; }
  409. void addProjectMessage (const Identifier& messageToAdd, std::vector<ProjectMessages::MessageAction>&& messageActions);
  410. void removeProjectMessage (const Identifier& messageToRemove);
  411. std::vector<ProjectMessages::MessageAction> getMessageActions (const Identifier& message);
  412. //==============================================================================
  413. bool hasIncompatibleLicenseTypeAndSplashScreenSetting() const;
  414. bool isFileModificationCheckPending() const;
  415. bool isSaveAndExportDisabled() const;
  416. private:
  417. //==============================================================================
  418. void valueTreePropertyChanged (ValueTree&, const Identifier&) override;
  419. void valueTreeChildAdded (ValueTree&, ValueTree&) override;
  420. void valueTreeChildRemoved (ValueTree&, ValueTree&, int) override;
  421. void valueTreeChildOrderChanged (ValueTree&, int, int) override;
  422. //==============================================================================
  423. struct ProjectFileModificationPoller : private Timer
  424. {
  425. ProjectFileModificationPoller (Project& p);
  426. bool isCheckPending() const noexcept { return pending; }
  427. private:
  428. void timerCallback() override;
  429. void reset();
  430. void resaveProject();
  431. void reloadProjectFromDisk();
  432. Project& project;
  433. bool pending = false;
  434. };
  435. //==============================================================================
  436. ValueTree projectRoot { Ids::JUCERPROJECT };
  437. ValueTreePropertyWithDefault projectNameValue, projectUIDValue, projectLineFeedValue, projectTypeValue, versionValue, bundleIdentifierValue, companyNameValue,
  438. companyCopyrightValue, companyWebsiteValue, companyEmailValue, displaySplashScreenValue, splashScreenColourValue, cppStandardValue,
  439. headerSearchPathsValue, preprocessorDefsValue, userNotesValue, maxBinaryFileSizeValue, includeBinaryDataInJuceHeaderValue, binaryDataNamespaceValue,
  440. compilerFlagSchemesValue, postExportShellCommandPosixValue, postExportShellCommandWinValue, useAppConfigValue, addUsingNamespaceToJuceHeader;
  441. ValueTreePropertyWithDefault pluginFormatsValue, pluginNameValue, pluginDescriptionValue, pluginManufacturerValue, pluginManufacturerCodeValue,
  442. pluginCodeValue, pluginChannelConfigsValue, pluginCharacteristicsValue, pluginAUExportPrefixValue, pluginAAXIdentifierValue,
  443. pluginAUMainTypeValue, pluginAUSandboxSafeValue, pluginVSTCategoryValue, pluginVST3CategoryValue, pluginAAXCategoryValue,
  444. pluginEnableARA, pluginARAAnalyzableContentValue, pluginARAFactoryIDValue, pluginARAArchiveIDValue, pluginARACompatibleArchiveIDsValue, pluginARATransformFlagsValue,
  445. pluginVSTNumMidiInputsValue, pluginVSTNumMidiOutputsValue, pluginLV2URIValue;
  446. //==============================================================================
  447. std::unique_ptr<EnabledModulesList> enabledModulesList;
  448. AvailableModulesList exporterPathsModulesList;
  449. //==============================================================================
  450. void updateDeprecatedProjectSettings();
  451. //==============================================================================
  452. bool shouldWriteLegacyPluginFormatSettings = false;
  453. bool shouldWriteLegacyPluginCharacteristicsSettings = false;
  454. static Array<Identifier> getLegacyPluginFormatIdentifiers() noexcept;
  455. static Array<Identifier> getLegacyPluginCharacteristicsIdentifiers() noexcept;
  456. void writeLegacyPluginFormatSettings();
  457. void writeLegacyPluginCharacteristicsSettings();
  458. void coalescePluginFormatValues();
  459. void coalescePluginCharacteristicsValues();
  460. void updatePluginCategories();
  461. //==============================================================================
  462. File tempDirectory;
  463. std::pair<Time, String> cachedFileState;
  464. //==============================================================================
  465. StringPairArray parsedPreprocessorDefs;
  466. //==============================================================================
  467. void initialiseProjectValues();
  468. void initialiseMainGroup();
  469. void initialiseAudioPluginValues();
  470. bool setCppVersionFromOldExporterSettings();
  471. void createAudioPluginPropertyEditors (PropertyListBuilder& props);
  472. //==============================================================================
  473. void updateTitleDependencies();
  474. void updateCompanyNameDependencies();
  475. void updateProjectSettings();
  476. void updateWebsiteDependencies();
  477. ValueTree getConfigurations() const;
  478. ValueTree getConfigNode();
  479. void updateOldStyleConfigList();
  480. void moveOldPropertyFromProjectToAllExporters (Identifier name);
  481. void removeDefunctExporters();
  482. void updateOldModulePaths();
  483. //==============================================================================
  484. void licenseStateChanged() override;
  485. void changeListenerCallback (ChangeBroadcaster*) override;
  486. void availableModulesChanged (AvailableModulesList*) override;
  487. void updateLicenseWarning();
  488. void updateJUCEPathWarning();
  489. void updateModuleWarnings();
  490. void updateCppStandardWarning (bool showWarning);
  491. void updateMissingModuleDependenciesWarning (bool showWarning);
  492. void updateOldProjucerWarning (bool showWarning);
  493. void updateModuleNotFoundWarning (bool showWarning);
  494. void updateCodeWarning (Identifier identifier, String value);
  495. ValueTree projectMessages { ProjectMessages::Ids::projectMessages, {},
  496. { { ProjectMessages::Ids::notification, {} }, { ProjectMessages::Ids::warning, {} } } };
  497. std::map<Identifier, std::vector<ProjectMessages::MessageAction>> messageActions;
  498. ProjectFileModificationPoller fileModificationPoller { *this };
  499. std::unique_ptr<FileChooser> chooser;
  500. std::unique_ptr<ProjectSaver> saver;
  501. //==============================================================================
  502. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Project)
  503. JUCE_DECLARE_WEAK_REFERENCEABLE (Project)
  504. };