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.

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