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.

1389 lines
49KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #include "../jucer_Headers.h"
  18. #include "jucer_Project.h"
  19. #include "../Project Saving/jucer_ProjectExporter.h"
  20. #include "../Project Saving/jucer_ProjectSaver.h"
  21. #include "../Application/jucer_OpenDocumentManager.h"
  22. #include "../Application/jucer_Application.h"
  23. namespace
  24. {
  25. String makeValid4CC (const String& seed)
  26. {
  27. String s (CodeHelpers::makeValidIdentifier (seed, false, true, false) + "xxxx");
  28. return s.substring (0, 1).toUpperCase()
  29. + s.substring (1, 4).toLowerCase();
  30. }
  31. }
  32. //==============================================================================
  33. Project::Project (const File& f)
  34. : FileBasedDocument (projectFileExtension,
  35. String ("*") + projectFileExtension,
  36. "Choose a Jucer project to load",
  37. "Save Jucer project"),
  38. projectRoot (Ids::JUCERPROJECT),
  39. isSaving (false)
  40. {
  41. Logger::writeToLog ("Loading project: " + f.getFullPathName());
  42. setFile (f);
  43. removeDefunctExporters();
  44. updateOldModulePaths();
  45. setMissingDefaultValues();
  46. setChangedFlag (false);
  47. projectRoot.addListener (this);
  48. modificationTime = getFile().getLastModificationTime();
  49. }
  50. Project::~Project()
  51. {
  52. projectRoot.removeListener (this);
  53. ProjucerApplication::getApp().openDocumentManager.closeAllDocumentsUsingProject (*this, false);
  54. }
  55. const char* Project::projectFileExtension = ".jucer";
  56. //==============================================================================
  57. void Project::setTitle (const String& newTitle)
  58. {
  59. projectRoot.setProperty (Ids::name, newTitle, getUndoManagerFor (projectRoot));
  60. getMainGroup().getNameValue() = newTitle;
  61. }
  62. String Project::getTitle() const
  63. {
  64. return projectRoot.getChildWithName (Ids::MAINGROUP) [Ids::name];
  65. }
  66. String Project::getDocumentTitle()
  67. {
  68. return getTitle();
  69. }
  70. void Project::updateProjectSettings()
  71. {
  72. projectRoot.setProperty (Ids::jucerVersion, ProjectInfo::versionString, nullptr);
  73. projectRoot.setProperty (Ids::name, getDocumentTitle(), nullptr);
  74. }
  75. void Project::setMissingDefaultValues()
  76. {
  77. if (! projectRoot.hasProperty (Ids::ID))
  78. projectRoot.setProperty (Ids::ID, createAlphaNumericUID(), nullptr);
  79. // Create main file group if missing
  80. if (! projectRoot.getChildWithName (Ids::MAINGROUP).isValid())
  81. {
  82. Item mainGroup (*this, ValueTree (Ids::MAINGROUP), false);
  83. projectRoot.addChild (mainGroup.state, 0, 0);
  84. }
  85. getMainGroup().initialiseMissingProperties();
  86. if (getDocumentTitle().isEmpty())
  87. setTitle ("JUCE Project");
  88. if (! projectRoot.hasProperty (Ids::projectType))
  89. getProjectTypeValue() = ProjectType_GUIApp::getTypeName();
  90. if (! projectRoot.hasProperty (Ids::version))
  91. getVersionValue() = "1.0.0";
  92. updateOldStyleConfigList();
  93. moveOldPropertyFromProjectToAllExporters (Ids::bigIcon);
  94. moveOldPropertyFromProjectToAllExporters (Ids::smallIcon);
  95. if (getProjectType().isAudioPlugin())
  96. setMissingAudioPluginDefaultValues();
  97. getModules().sortAlphabetically();
  98. if (getBundleIdentifier().toString().isEmpty())
  99. getBundleIdentifier() = getDefaultBundleIdentifier();
  100. if (shouldIncludeBinaryInAppConfig() == var())
  101. shouldIncludeBinaryInAppConfig() = true;
  102. ProjucerApplication::getApp().updateNewlyOpenedProject (*this);
  103. }
  104. void Project::updateDeprecatedProjectSettingsInteractively()
  105. {
  106. jassert (! ProjucerApplication::getApp().isRunningCommandLine);
  107. for (Project::ExporterIterator exporter (*this); exporter.next();)
  108. exporter->updateDeprecatedProjectSettingsInteractively();
  109. }
  110. void Project::setMissingAudioPluginDefaultValues()
  111. {
  112. const String sanitisedProjectName (CodeHelpers::makeValidIdentifier (getTitle(), false, true, false));
  113. setValueIfVoid (getShouldBuildVSTAsValue(), true);
  114. setValueIfVoid (getShouldBuildVST3AsValue(), false);
  115. setValueIfVoid (getShouldBuildAUAsValue(), true);
  116. setValueIfVoid (getShouldBuildAUv3AsValue(), false);
  117. setValueIfVoid (getShouldBuildRTASAsValue(), false);
  118. setValueIfVoid (getShouldBuildAAXAsValue(), false);
  119. setValueIfVoid (getShouldBuildStandalonePluginAsValue(), false);
  120. setValueIfVoid (getShouldEnableIAAAsValue(), false);
  121. setValueIfVoid (getPluginName(), getTitle());
  122. setValueIfVoid (getPluginDesc(), getTitle());
  123. setValueIfVoid (getPluginManufacturer(), "yourcompany");
  124. setValueIfVoid (getPluginManufacturerCode(), "Manu");
  125. setValueIfVoid (getPluginCode(), makeValid4CC (getProjectUID() + getProjectUID()));
  126. setValueIfVoid (getPluginChannelConfigs(), String());
  127. setValueIfVoid (getPluginIsSynth(), false);
  128. setValueIfVoid (getPluginWantsMidiInput(), false);
  129. setValueIfVoid (getPluginProducesMidiOut(), false);
  130. setValueIfVoid (getPluginIsMidiEffectPlugin(), false);
  131. setValueIfVoid (getPluginEditorNeedsKeyFocus(), false);
  132. setValueIfVoid (getPluginAUExportPrefix(), sanitisedProjectName + "AU");
  133. setValueIfVoid (getPluginRTASCategory(), String());
  134. setValueIfVoid (getBundleIdentifier(), getDefaultBundleIdentifier());
  135. setValueIfVoid (getAAXIdentifier(), getDefaultAAXIdentifier());
  136. setValueIfVoid (getPluginAAXCategory(), "AAX_ePlugInCategory_Dynamics");
  137. }
  138. void Project::updateOldStyleConfigList()
  139. {
  140. ValueTree deprecatedConfigsList (projectRoot.getChildWithName (Ids::CONFIGURATIONS));
  141. if (deprecatedConfigsList.isValid())
  142. {
  143. projectRoot.removeChild (deprecatedConfigsList, nullptr);
  144. for (Project::ExporterIterator exporter (*this); exporter.next();)
  145. {
  146. if (exporter->getNumConfigurations() == 0)
  147. {
  148. ValueTree newConfigs (deprecatedConfigsList.createCopy());
  149. if (! exporter->isXcode())
  150. {
  151. for (int j = newConfigs.getNumChildren(); --j >= 0;)
  152. {
  153. ValueTree config (newConfigs.getChild(j));
  154. config.removeProperty (Ids::osxSDK, nullptr);
  155. config.removeProperty (Ids::osxCompatibility, nullptr);
  156. config.removeProperty (Ids::osxArchitecture, nullptr);
  157. }
  158. }
  159. exporter->settings.addChild (newConfigs, 0, nullptr);
  160. }
  161. }
  162. }
  163. }
  164. void Project::moveOldPropertyFromProjectToAllExporters (Identifier name)
  165. {
  166. if (projectRoot.hasProperty (name))
  167. {
  168. for (Project::ExporterIterator exporter (*this); exporter.next();)
  169. exporter->settings.setProperty (name, projectRoot [name], nullptr);
  170. projectRoot.removeProperty (name, nullptr);
  171. }
  172. }
  173. void Project::removeDefunctExporters()
  174. {
  175. ValueTree exporters (projectRoot.getChildWithName (Ids::EXPORTFORMATS));
  176. for (;;)
  177. {
  178. ValueTree oldVC6Exporter (exporters.getChildWithName ("MSVC6"));
  179. ValueTree oldAndroidAntExporter (exporters.getChildWithName ("ANDROID"));
  180. if (oldVC6Exporter.isValid())
  181. exporters.removeChild (oldVC6Exporter, nullptr);
  182. else if (oldAndroidAntExporter.isValid())
  183. {
  184. AlertWindow::showMessageBox (AlertWindow::WarningIcon,
  185. TRANS("Android Ant Exporter"),
  186. TRANS("The Android Ant Exporter is deprecated. The exporter will be removed from this project."));
  187. exporters.removeChild (oldAndroidAntExporter, nullptr);
  188. }
  189. else
  190. break;
  191. }
  192. }
  193. void Project::updateOldModulePaths()
  194. {
  195. for (Project::ExporterIterator exporter (*this); exporter.next();)
  196. exporter->updateOldModulePaths();
  197. }
  198. //==============================================================================
  199. static int getVersionElement (StringRef v, int index)
  200. {
  201. StringArray parts;
  202. parts.addTokens (v, "., ", StringRef());
  203. return parts [parts.size() - index - 1].getIntValue();
  204. }
  205. static int getJuceVersion (const String& v)
  206. {
  207. return getVersionElement (v, 2) * 100000
  208. + getVersionElement (v, 1) * 1000
  209. + getVersionElement (v, 0);
  210. }
  211. static int getBuiltJuceVersion()
  212. {
  213. return JUCE_MAJOR_VERSION * 100000
  214. + JUCE_MINOR_VERSION * 1000
  215. + JUCE_BUILDNUMBER;
  216. }
  217. static bool isAnyModuleNewerThanProjucer (const OwnedArray<ModuleDescription>& modules)
  218. {
  219. for (int i = modules.size(); --i >= 0;)
  220. {
  221. const ModuleDescription* m = modules.getUnchecked(i);
  222. if (m->getID().startsWith ("juce_")
  223. && getJuceVersion (m->getVersion()) > getBuiltJuceVersion())
  224. return true;
  225. }
  226. return false;
  227. }
  228. void Project::warnAboutOldProjucerVersion()
  229. {
  230. ModuleList available;
  231. available.scanAllKnownFolders (*this);
  232. if (isAnyModuleNewerThanProjucer (available.modules))
  233. {
  234. if (ProjucerApplication::getApp().isRunningCommandLine)
  235. std::cout << "WARNING! This version of the Projucer is out-of-date!" << std::endl;
  236. else
  237. AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
  238. "Projucer",
  239. "This version of the Projucer is out-of-date!"
  240. "\n\n"
  241. "Always make sure that you're running the very latest version, "
  242. "preferably compiled directly from the JUCE repository that you're working with!");
  243. }
  244. }
  245. //==============================================================================
  246. static File lastDocumentOpened;
  247. File Project::getLastDocumentOpened() { return lastDocumentOpened; }
  248. void Project::setLastDocumentOpened (const File& file) { lastDocumentOpened = file; }
  249. static void registerRecentFile (const File& file)
  250. {
  251. RecentlyOpenedFilesList::registerRecentFileNatively (file);
  252. getAppSettings().recentFiles.addFile (file);
  253. getAppSettings().flush();
  254. }
  255. //==============================================================================
  256. Result Project::loadDocument (const File& file)
  257. {
  258. ScopedPointer<XmlElement> xml (XmlDocument::parse (file));
  259. if (xml == nullptr || ! xml->hasTagName (Ids::JUCERPROJECT.toString()))
  260. return Result::fail ("Not a valid Jucer project!");
  261. ValueTree newTree (ValueTree::fromXml (*xml));
  262. if (! newTree.hasType (Ids::JUCERPROJECT))
  263. return Result::fail ("The document contains errors and couldn't be parsed!");
  264. registerRecentFile (file);
  265. enabledModulesList = nullptr;
  266. projectRoot = newTree;
  267. removeDefunctExporters();
  268. setMissingDefaultValues();
  269. updateOldModulePaths();
  270. setChangedFlag (false);
  271. if (! ProjucerApplication::getApp().isRunningCommandLine)
  272. warnAboutOldProjucerVersion();
  273. return Result::ok();
  274. }
  275. Result Project::saveDocument (const File& file)
  276. {
  277. return saveProject (file, false);
  278. }
  279. Result Project::saveProject (const File& file, bool isCommandLineApp)
  280. {
  281. if (isSaving)
  282. return Result::ok();
  283. updateProjectSettings();
  284. sanitiseConfigFlags();
  285. if (! isCommandLineApp)
  286. registerRecentFile (file);
  287. const ScopedValueSetter<bool> vs (isSaving, true, false);
  288. ProjectSaver saver (*this, file);
  289. return saver.save (! isCommandLineApp);
  290. }
  291. Result Project::saveResourcesOnly (const File& file)
  292. {
  293. ProjectSaver saver (*this, file);
  294. return saver.saveResourcesOnly();
  295. }
  296. //==============================================================================
  297. void Project::valueTreePropertyChanged (ValueTree&, const Identifier& property)
  298. {
  299. if (property == Ids::projectType)
  300. setMissingDefaultValues();
  301. changed();
  302. }
  303. void Project::valueTreeChildAdded (ValueTree&, ValueTree&) { changed(); }
  304. void Project::valueTreeChildRemoved (ValueTree&, ValueTree&, int) { changed(); }
  305. void Project::valueTreeChildOrderChanged (ValueTree&, int, int) { changed(); }
  306. void Project::valueTreeParentChanged (ValueTree&) {}
  307. //==============================================================================
  308. bool Project::hasProjectBeenModified()
  309. {
  310. Time newModificationTime = getFile().getLastModificationTime();
  311. Time oldModificationTime = modificationTime;
  312. modificationTime = newModificationTime;
  313. return (newModificationTime.toMilliseconds() > (oldModificationTime.toMilliseconds() + 1000LL));
  314. }
  315. //==============================================================================
  316. File Project::resolveFilename (String filename) const
  317. {
  318. if (filename.isEmpty())
  319. return File();
  320. filename = replacePreprocessorDefs (getPreprocessorDefs(), filename);
  321. if (FileHelpers::isAbsolutePath (filename))
  322. return File::createFileWithoutCheckingPath (FileHelpers::currentOSStylePath (filename)); // (avoid assertions for windows-style paths)
  323. return getFile().getSiblingFile (FileHelpers::currentOSStylePath (filename));
  324. }
  325. String Project::getRelativePathForFile (const File& file) const
  326. {
  327. String filename (file.getFullPathName());
  328. File relativePathBase (getFile().getParentDirectory());
  329. String p1 (relativePathBase.getFullPathName());
  330. String p2 (file.getFullPathName());
  331. while (p1.startsWithChar (File::separator))
  332. p1 = p1.substring (1);
  333. while (p2.startsWithChar (File::separator))
  334. p2 = p2.substring (1);
  335. if (p1.upToFirstOccurrenceOf (File::separatorString, true, false)
  336. .equalsIgnoreCase (p2.upToFirstOccurrenceOf (File::separatorString, true, false)))
  337. {
  338. filename = FileHelpers::getRelativePathFrom (file, relativePathBase);
  339. }
  340. return filename;
  341. }
  342. //==============================================================================
  343. const ProjectType& Project::getProjectType() const
  344. {
  345. if (const ProjectType* type = ProjectType::findType (getProjectTypeString()))
  346. return *type;
  347. const ProjectType* guiType = ProjectType::findType (ProjectType_GUIApp::getTypeName());
  348. jassert (guiType != nullptr);
  349. return *guiType;
  350. }
  351. bool Project::shouldBuildTargetType (ProjectType::Target::Type targetType) const noexcept
  352. {
  353. const ProjectType& projectType = getProjectType();
  354. if (! projectType.supportsTargetType (targetType))
  355. return false;
  356. switch (targetType)
  357. {
  358. case ProjectType::Target::VSTPlugIn:
  359. return shouldBuildVST();
  360. case ProjectType::Target::VST3PlugIn:
  361. return shouldBuildVST3();
  362. case ProjectType::Target::AAXPlugIn:
  363. return shouldBuildAAX();
  364. case ProjectType::Target::RTASPlugIn:
  365. return shouldBuildRTAS();
  366. case ProjectType::Target::AudioUnitPlugIn:
  367. return shouldBuildAU();
  368. case ProjectType::Target::AudioUnitv3PlugIn:
  369. return shouldBuildAUv3();
  370. case ProjectType::Target::StandalonePlugIn:
  371. return shouldBuildStandalonePlugin();
  372. case ProjectType::Target::AggregateTarget:
  373. case ProjectType::Target::SharedCodeTarget:
  374. return projectType.isAudioPlugin();
  375. case ProjectType::Target::unspecified:
  376. return false;
  377. default:
  378. break;
  379. }
  380. return true;
  381. }
  382. ProjectType::Target::Type Project::getTargetTypeFromFilePath (const File& file, bool returnSharedTargetIfNoValidSuffix)
  383. {
  384. if (LibraryModule::CompileUnit::hasSuffix (file, "_AU")) return ProjectType::Target::AudioUnitPlugIn;
  385. else if (LibraryModule::CompileUnit::hasSuffix (file, "_AUv3")) return ProjectType::Target::AudioUnitv3PlugIn;
  386. else if (LibraryModule::CompileUnit::hasSuffix (file, "_AAX")) return ProjectType::Target::AAXPlugIn;
  387. else if (LibraryModule::CompileUnit::hasSuffix (file, "_RTAS")) return ProjectType::Target::RTASPlugIn;
  388. else if (LibraryModule::CompileUnit::hasSuffix (file, "_VST2")) return ProjectType::Target::VSTPlugIn;
  389. else if (LibraryModule::CompileUnit::hasSuffix (file, "_VST3")) return ProjectType::Target::VST3PlugIn;
  390. else if (LibraryModule::CompileUnit::hasSuffix (file, "_Standalone")) return ProjectType::Target::StandalonePlugIn;
  391. return (returnSharedTargetIfNoValidSuffix ? ProjectType::Target::SharedCodeTarget : ProjectType::Target::unspecified);
  392. }
  393. const char* ProjectType::Target::getName() const noexcept
  394. {
  395. switch (type)
  396. {
  397. case GUIApp: return "App";
  398. case ConsoleApp: return "ConsoleApp";
  399. case StaticLibrary: return "Static Library";
  400. case DynamicLibrary: return "Dynamic Library";
  401. case VSTPlugIn: return "VST";
  402. case VST3PlugIn: return "VST3";
  403. case AudioUnitPlugIn: return "AU";
  404. case StandalonePlugIn: return "Standalone Plugin";
  405. case AudioUnitv3PlugIn: return "AUv3 AppExtension";
  406. case AAXPlugIn: return "AAX";
  407. case RTASPlugIn: return "RTAS";
  408. case SharedCodeTarget: return "Shared Code";
  409. case AggregateTarget: return "All";
  410. default: return "undefined";
  411. }
  412. }
  413. ProjectType::Target::TargetFileType ProjectType::Target::getTargetFileType() const noexcept
  414. {
  415. switch (type)
  416. {
  417. case GUIApp: return executable;
  418. case ConsoleApp: return executable;
  419. case StaticLibrary: return staticLibrary;
  420. case DynamicLibrary: return sharedLibraryOrDLL;
  421. case VSTPlugIn: return pluginBundle;
  422. case VST3PlugIn: return pluginBundle;
  423. case AudioUnitPlugIn: return pluginBundle;
  424. case StandalonePlugIn: return executable;
  425. case AudioUnitv3PlugIn: return macOSAppex;
  426. case AAXPlugIn: return pluginBundle;
  427. case RTASPlugIn: return pluginBundle;
  428. case SharedCodeTarget: return staticLibrary;
  429. default:
  430. break;
  431. }
  432. return unknown;
  433. }
  434. //==============================================================================
  435. void Project::createPropertyEditors (PropertyListBuilder& props)
  436. {
  437. props.add (new TextPropertyComponent (getProjectNameValue(), "Project Name", 256, false),
  438. "The name of the project.");
  439. props.add (new TextPropertyComponent (getVersionValue(), "Project Version", 16, false),
  440. "The project's version number, This should be in the format major.minor.point[.point]");
  441. props.add (new TextPropertyComponent (getCompanyName(), "Company Name", 256, false),
  442. "Your company name, which will be added to the properties of the binary where possible");
  443. props.add (new TextPropertyComponent (getCompanyWebsite(), "Company Website", 256, false),
  444. "Your company website, which will be added to the properties of the binary where possible");
  445. props.add (new TextPropertyComponent (getCompanyEmail(), "Company E-mail", 256, false),
  446. "Your company e-mail, which will be added to the properties of the binary where possible");
  447. {
  448. StringArray projectTypeNames;
  449. Array<var> projectTypeCodes;
  450. const Array<ProjectType*>& types = ProjectType::getAllTypes();
  451. for (int i = 0; i < types.size(); ++i)
  452. {
  453. projectTypeNames.add (types.getUnchecked(i)->getDescription());
  454. projectTypeCodes.add (types.getUnchecked(i)->getType());
  455. }
  456. props.add (new ChoicePropertyComponent (getProjectTypeValue(), "Project Type", projectTypeNames, projectTypeCodes));
  457. }
  458. props.add (new TextPropertyComponent (getBundleIdentifier(), "Bundle Identifier", 256, false),
  459. "A unique identifier for this product, mainly for use in OSX/iOS builds. It should be something like 'com.yourcompanyname.yourproductname'");
  460. if (getProjectType().isAudioPlugin())
  461. createAudioPluginPropertyEditors (props);
  462. {
  463. const int maxSizes[] = { 20480, 10240, 6144, 2048, 1024, 512, 256, 128, 64 };
  464. StringArray maxSizeNames;
  465. Array<var> maxSizeCodes;
  466. maxSizeNames.add (TRANS("Default"));
  467. maxSizeCodes.add (var());
  468. maxSizeNames.add (String());
  469. maxSizeCodes.add (var());
  470. for (int i = 0; i < numElementsInArray (maxSizes); ++i)
  471. {
  472. const int sizeInBytes = maxSizes[i] * 1024;
  473. maxSizeNames.add (File::descriptionOfSizeInBytes (sizeInBytes));
  474. maxSizeCodes.add (sizeInBytes);
  475. }
  476. props.add (new ChoicePropertyComponent (getMaxBinaryFileSize(), "BinaryData.cpp size limit", maxSizeNames, maxSizeCodes),
  477. "When splitting binary data into multiple cpp files, the Projucer attempts to keep the file sizes below this threshold. "
  478. "(Note that individual resource files which are larger than this size cannot be split across multiple cpp files).");
  479. }
  480. props.add (new BooleanPropertyComponent (shouldIncludeBinaryInAppConfig(), "Include Binary",
  481. "Include BinaryData.h in the AppConfig.h file"));
  482. props.add (new TextPropertyComponent (binaryDataNamespace(), "BinaryData Namespace", 256, false),
  483. "The namespace containing the binary assests. If left empty this defaults to \"BinaryData\".");
  484. props.add (new TextPropertyComponent (getProjectPreprocessorDefs(), "Preprocessor definitions", 32768, true),
  485. "Global preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace, commas, or "
  486. "new-lines to separate the items - to include a space or comma in a definition, precede it with a backslash.");
  487. props.add (new TextPropertyComponent (getProjectUserNotes(), "Notes", 32768, true),
  488. "Extra comments: This field is not used for code or project generation, it's just a space where you can express your thoughts.");
  489. }
  490. void Project::createAudioPluginPropertyEditors (PropertyListBuilder& props)
  491. {
  492. props.add (new BooleanPropertyComponent (getShouldBuildVSTAsValue(), "Build VST", "Enabled"),
  493. "Whether the project should produce a VST plugin.");
  494. props.add (new BooleanPropertyComponent (getShouldBuildVST3AsValue(), "Build VST3", "Enabled"),
  495. "Whether the project should produce a VST3 plugin.");
  496. props.add (new BooleanPropertyComponent (getShouldBuildAUAsValue(), "Build AudioUnit", "Enabled"),
  497. "Whether the project should produce an AudioUnit plugin.");
  498. props.add (new BooleanPropertyComponent (getShouldBuildAUv3AsValue(), "Build AudioUnit v3", "Enabled"),
  499. "Whether the project should produce an AudioUnit version 3 plugin.");
  500. props.add (new BooleanPropertyComponent (getShouldBuildRTASAsValue(), "Build RTAS", "Enabled"),
  501. "Whether the project should produce an RTAS plugin.");
  502. props.add (new BooleanPropertyComponent (getShouldBuildAAXAsValue(), "Build AAX", "Enabled"),
  503. "Whether the project should produce an AAX plugin.");
  504. props.add (new BooleanPropertyComponent (getShouldBuildStandalonePluginAsValue(), "Build Standalone Plug-In", "Enabled"),
  505. "Whether the project should produce a standalone version of your plugin.");
  506. props.add (new BooleanPropertyComponent (getShouldEnableIAAAsValue(), "Enable Inter-App Audio", "Enabled"),
  507. "Whether a standalone plug-in should be an Inter-App Audio app. You should also enable the audio "
  508. "background capability in the iOS exporter.");
  509. props.add (new TextPropertyComponent (getPluginName(), "Plugin Name", 128, false),
  510. "The name of your plugin (keep it short!)");
  511. props.add (new TextPropertyComponent (getPluginDesc(), "Plugin Description", 256, false),
  512. "A short description of your plugin.");
  513. props.add (new TextPropertyComponent (getPluginManufacturer(), "Plugin Manufacturer", 256, false),
  514. "The name of your company (cannot be blank).");
  515. props.add (new TextPropertyComponent (getPluginManufacturerCode(), "Plugin Manufacturer Code", 4, false),
  516. "A four-character unique ID for your company. Note that for AU compatibility, this must contain at least one upper-case letter!");
  517. props.add (new TextPropertyComponent (getPluginCode(), "Plugin Code", 4, false),
  518. "A four-character unique ID for your plugin. Note that for AU compatibility, this must contain at least one upper-case letter!");
  519. props.add (new TextPropertyComponent (getPluginChannelConfigs(), "Plugin Channel Configurations", 1024, false),
  520. "This list is a comma-separated set list in the form {numIns, numOuts} and each pair indicates a valid plug-in "
  521. "configuration. For example {1, 1}, {2, 2} means that the plugin can be used either with 1 input and 1 output, "
  522. "or with 2 inputs and 2 outputs. If your plug-in requires side-chains, aux output buses etc., then you must leave "
  523. "this field empty and override the setPreferredBusArrangement method in your AudioProcessor.");
  524. props.add (new BooleanPropertyComponent (getPluginIsSynth(), "Plugin is a Synth", "Is a Synth"),
  525. "Enable this if you want your plugin to be treated as a synth or generator. It doesn't make much difference to the plugin itself, but some hosts treat synths differently to other plugins.");
  526. props.add (new BooleanPropertyComponent (getPluginWantsMidiInput(), "Plugin Midi Input", "Plugin wants midi input"),
  527. "Enable this if you want your plugin to accept midi messages.");
  528. props.add (new BooleanPropertyComponent (getPluginProducesMidiOut(), "Plugin Midi Output", "Plugin produces midi output"),
  529. "Enable this if your plugin is going to produce midi messages.");
  530. props.add (new BooleanPropertyComponent (getPluginIsMidiEffectPlugin(), "Midi Effect Plugin", "Plugin is a midi effect plugin"),
  531. "Enable this if your plugin only processes midi and no audio.");
  532. props.add (new BooleanPropertyComponent (getPluginEditorNeedsKeyFocus(), "Key Focus", "Plugin editor requires keyboard focus"),
  533. "Enable this if your plugin needs keyboard input - some hosts can be a bit funny about keyboard focus..");
  534. props.add (new TextPropertyComponent (getPluginAUExportPrefix(), "Plugin AU Export Prefix", 64, false),
  535. "A prefix for the names of exported entry-point functions that the component exposes - typically this will be a version of your plugin's name that can be used as part of a C++ token.");
  536. props.add (new TextPropertyComponent (getPluginAUMainType(), "Plugin AU Main Type", 128, false),
  537. "In an AU, this is the value that is set as JucePlugin_AUMainType. Leave it blank unless you want to use a custom value.");
  538. props.add (new TextPropertyComponent (getPluginVSTCategory(), "VST Category", 64, false),
  539. "In a VST, this is the value that is set as JucePlugin_VSTCategory. Leave it blank unless you want to use a custom value.");
  540. props.add (new TextPropertyComponent (getPluginRTASCategory(), "Plugin RTAS Category", 64, false),
  541. "(Leave this blank if your plugin is a synth). This is one of the RTAS categories from FicPluginEnums.h, such as: ePlugInCategory_None, ePlugInCategory_EQ, ePlugInCategory_Dynamics, "
  542. "ePlugInCategory_PitchShift, ePlugInCategory_Reverb, ePlugInCategory_Delay, "
  543. "ePlugInCategory_Modulation, ePlugInCategory_Harmonic, ePlugInCategory_NoiseReduction, "
  544. "ePlugInCategory_Dither, ePlugInCategory_SoundField");
  545. props.add (new TextPropertyComponent (getPluginAAXCategory(), "Plugin AAX Category", 64, false),
  546. "This is one of the categories from the AAX_EPlugInCategory enum");
  547. props.add (new TextPropertyComponent (getAAXIdentifier(), "Plugin AAX Identifier", 256, false),
  548. "The value to use for the JucePlugin_AAXIdentifier setting");
  549. }
  550. //==============================================================================
  551. static StringArray getVersionSegments (const Project& p)
  552. {
  553. StringArray segments;
  554. segments.addTokens (p.getVersionString(), ",.", "");
  555. segments.trim();
  556. segments.removeEmptyStrings();
  557. return segments;
  558. }
  559. int Project::getVersionAsHexInteger() const
  560. {
  561. const StringArray segments (getVersionSegments (*this));
  562. int value = (segments[0].getIntValue() << 16)
  563. + (segments[1].getIntValue() << 8)
  564. + segments[2].getIntValue();
  565. if (segments.size() >= 4)
  566. value = (value << 8) + segments[3].getIntValue();
  567. return value;
  568. }
  569. String Project::getVersionAsHex() const
  570. {
  571. return "0x" + String::toHexString (getVersionAsHexInteger());
  572. }
  573. StringPairArray Project::getPreprocessorDefs() const
  574. {
  575. return parsePreprocessorDefs (projectRoot [Ids::defines]);
  576. }
  577. File Project::getBinaryDataCppFile (int index) const
  578. {
  579. const File cpp (getGeneratedCodeFolder().getChildFile ("BinaryData.cpp"));
  580. if (index > 0)
  581. return cpp.getSiblingFile (cpp.getFileNameWithoutExtension() + String (index + 1))
  582. .withFileExtension (cpp.getFileExtension());
  583. return cpp;
  584. }
  585. Project::Item Project::getMainGroup()
  586. {
  587. return Item (*this, projectRoot.getChildWithName (Ids::MAINGROUP), false);
  588. }
  589. PropertiesFile& Project::getStoredProperties() const
  590. {
  591. return getAppSettings().getProjectProperties (getProjectUID());
  592. }
  593. static void findImages (const Project::Item& item, OwnedArray<Project::Item>& found)
  594. {
  595. if (item.isImageFile())
  596. {
  597. found.add (new Project::Item (item));
  598. }
  599. else if (item.isGroup())
  600. {
  601. for (int i = 0; i < item.getNumChildren(); ++i)
  602. findImages (item.getChild (i), found);
  603. }
  604. }
  605. void Project::findAllImageItems (OwnedArray<Project::Item>& items)
  606. {
  607. findImages (getMainGroup(), items);
  608. }
  609. //==============================================================================
  610. Project::Item::Item (Project& p, const ValueTree& s, bool isModuleCode)
  611. : project (p), state (s), belongsToModule (isModuleCode)
  612. {
  613. }
  614. Project::Item::Item (const Item& other)
  615. : project (other.project), state (other.state), belongsToModule (other.belongsToModule)
  616. {
  617. }
  618. Project::Item Project::Item::createCopy() { Item i (*this); i.state = i.state.createCopy(); return i; }
  619. String Project::Item::getID() const { return state [Ids::ID]; }
  620. void Project::Item::setID (const String& newID) { state.setProperty (Ids::ID, newID, nullptr); }
  621. Drawable* Project::Item::loadAsImageFile() const
  622. {
  623. return isValid() ? Drawable::createFromImageFile (getFile())
  624. : nullptr;
  625. }
  626. Project::Item Project::Item::createGroup (Project& project, const String& name, const String& uid, bool isModuleCode)
  627. {
  628. Item group (project, ValueTree (Ids::GROUP), isModuleCode);
  629. group.setID (uid);
  630. group.initialiseMissingProperties();
  631. group.getNameValue() = name;
  632. return group;
  633. }
  634. bool Project::Item::isFile() const { return state.hasType (Ids::FILE); }
  635. bool Project::Item::isGroup() const { return state.hasType (Ids::GROUP) || isMainGroup(); }
  636. bool Project::Item::isMainGroup() const { return state.hasType (Ids::MAINGROUP); }
  637. bool Project::Item::isImageFile() const
  638. {
  639. return isFile() && (ImageFileFormat::findImageFormatForFileExtension (getFile()) != nullptr
  640. || getFile().hasFileExtension ("svg"));
  641. }
  642. Project::Item Project::Item::findItemWithID (const String& targetId) const
  643. {
  644. if (state [Ids::ID] == targetId)
  645. return *this;
  646. if (isGroup())
  647. {
  648. for (int i = getNumChildren(); --i >= 0;)
  649. {
  650. Item found (getChild(i).findItemWithID (targetId));
  651. if (found.isValid())
  652. return found;
  653. }
  654. }
  655. return Item (project, ValueTree(), false);
  656. }
  657. bool Project::Item::canContain (const Item& child) const
  658. {
  659. if (isFile())
  660. return false;
  661. if (isGroup())
  662. return child.isFile() || child.isGroup();
  663. jassertfalse;
  664. return false;
  665. }
  666. bool Project::Item::shouldBeAddedToTargetProject() const { return isFile(); }
  667. Value Project::Item::getShouldCompileValue() { return state.getPropertyAsValue (Ids::compile, getUndoManager()); }
  668. bool Project::Item::shouldBeCompiled() const { return state [Ids::compile]; }
  669. Value Project::Item::getShouldAddToBinaryResourcesValue() { return state.getPropertyAsValue (Ids::resource, getUndoManager()); }
  670. bool Project::Item::shouldBeAddedToBinaryResources() const { return state [Ids::resource]; }
  671. Value Project::Item::getShouldAddToXcodeResourcesValue() { return state.getPropertyAsValue (Ids::xcodeResource, getUndoManager()); }
  672. bool Project::Item::shouldBeAddedToXcodeResources() const { return state [Ids::xcodeResource]; }
  673. Value Project::Item::getShouldInhibitWarningsValue() { return state.getPropertyAsValue (Ids::noWarnings, getUndoManager()); }
  674. bool Project::Item::shouldInhibitWarnings() const { return state [Ids::noWarnings]; }
  675. bool Project::Item::isModuleCode() const { return belongsToModule; }
  676. String Project::Item::getFilePath() const
  677. {
  678. if (isFile())
  679. return state [Ids::file].toString();
  680. return String();
  681. }
  682. File Project::Item::getFile() const
  683. {
  684. if (isFile())
  685. return project.resolveFilename (state [Ids::file].toString());
  686. return File();
  687. }
  688. void Project::Item::setFile (const File& file)
  689. {
  690. setFile (RelativePath (project.getRelativePathForFile (file), RelativePath::projectFolder));
  691. jassert (getFile() == file);
  692. }
  693. void Project::Item::setFile (const RelativePath& file)
  694. {
  695. jassert (isFile());
  696. state.setProperty (Ids::file, file.toUnixStyle(), getUndoManager());
  697. state.setProperty (Ids::name, file.getFileName(), getUndoManager());
  698. }
  699. bool Project::Item::renameFile (const File& newFile)
  700. {
  701. const File oldFile (getFile());
  702. if (oldFile.moveFileTo (newFile)
  703. || (newFile.exists() && ! oldFile.exists()))
  704. {
  705. setFile (newFile);
  706. ProjucerApplication::getApp().openDocumentManager.fileHasBeenRenamed (oldFile, newFile);
  707. return true;
  708. }
  709. return false;
  710. }
  711. bool Project::Item::containsChildForFile (const RelativePath& file) const
  712. {
  713. return state.getChildWithProperty (Ids::file, file.toUnixStyle()).isValid();
  714. }
  715. Project::Item Project::Item::findItemForFile (const File& file) const
  716. {
  717. if (getFile() == file)
  718. return *this;
  719. if (isGroup())
  720. {
  721. for (int i = getNumChildren(); --i >= 0;)
  722. {
  723. Item found (getChild(i).findItemForFile (file));
  724. if (found.isValid())
  725. return found;
  726. }
  727. }
  728. return Item (project, ValueTree(), false);
  729. }
  730. File Project::Item::determineGroupFolder() const
  731. {
  732. jassert (isGroup());
  733. File f;
  734. for (int i = 0; i < getNumChildren(); ++i)
  735. {
  736. f = getChild(i).getFile();
  737. if (f.exists())
  738. return f.getParentDirectory();
  739. }
  740. Item parent (getParent());
  741. if (parent != *this)
  742. {
  743. f = parent.determineGroupFolder();
  744. if (f.getChildFile (getName()).isDirectory())
  745. f = f.getChildFile (getName());
  746. }
  747. else
  748. {
  749. f = project.getProjectFolder();
  750. if (f.getChildFile ("Source").isDirectory())
  751. f = f.getChildFile ("Source");
  752. }
  753. return f;
  754. }
  755. void Project::Item::initialiseMissingProperties()
  756. {
  757. if (! state.hasProperty (Ids::ID))
  758. setID (createAlphaNumericUID());
  759. if (isFile())
  760. {
  761. state.setProperty (Ids::name, getFile().getFileName(), nullptr);
  762. }
  763. else if (isGroup())
  764. {
  765. for (int i = getNumChildren(); --i >= 0;)
  766. getChild(i).initialiseMissingProperties();
  767. }
  768. }
  769. Value Project::Item::getNameValue()
  770. {
  771. return state.getPropertyAsValue (Ids::name, getUndoManager());
  772. }
  773. String Project::Item::getName() const
  774. {
  775. return state [Ids::name];
  776. }
  777. void Project::Item::addChild (const Item& newChild, int insertIndex)
  778. {
  779. state.addChild (newChild.state, insertIndex, getUndoManager());
  780. }
  781. void Project::Item::removeItemFromProject()
  782. {
  783. state.getParent().removeChild (state, getUndoManager());
  784. }
  785. Project::Item Project::Item::getParent() const
  786. {
  787. if (isMainGroup() || ! isGroup())
  788. return *this;
  789. return Item (project, state.getParent(), belongsToModule);
  790. }
  791. struct ItemSorter
  792. {
  793. static int compareElements (const ValueTree& first, const ValueTree& second)
  794. {
  795. return first [Ids::name].toString().compareNatural (second [Ids::name].toString());
  796. }
  797. };
  798. struct ItemSorterWithGroupsAtStart
  799. {
  800. static int compareElements (const ValueTree& first, const ValueTree& second)
  801. {
  802. const bool firstIsGroup = first.hasType (Ids::GROUP);
  803. const bool secondIsGroup = second.hasType (Ids::GROUP);
  804. if (firstIsGroup == secondIsGroup)
  805. return first [Ids::name].toString().compareNatural (second [Ids::name].toString());
  806. return firstIsGroup ? -1 : 1;
  807. }
  808. };
  809. static void sortGroup (ValueTree& state, bool keepGroupsAtStart, UndoManager* undoManager)
  810. {
  811. if (keepGroupsAtStart)
  812. {
  813. ItemSorterWithGroupsAtStart sorter;
  814. state.sort (sorter, undoManager, true);
  815. }
  816. else
  817. {
  818. ItemSorter sorter;
  819. state.sort (sorter, undoManager, true);
  820. }
  821. }
  822. static bool isGroupSorted (const ValueTree& state, bool keepGroupsAtStart)
  823. {
  824. if (state.getNumChildren() == 0)
  825. return false;
  826. if (state.getNumChildren() == 1)
  827. return true;
  828. ValueTree stateCopy (state.createCopy());
  829. sortGroup (stateCopy, keepGroupsAtStart, nullptr);
  830. return stateCopy.isEquivalentTo (state);
  831. }
  832. void Project::Item::sortAlphabetically (bool keepGroupsAtStart, bool recursive)
  833. {
  834. sortGroup (state, keepGroupsAtStart, getUndoManager());
  835. if (recursive)
  836. for (int i = getNumChildren(); --i >= 0;)
  837. getChild(i).sortAlphabetically (keepGroupsAtStart, true);
  838. }
  839. Project::Item Project::Item::getOrCreateSubGroup (const String& name)
  840. {
  841. for (int i = state.getNumChildren(); --i >= 0;)
  842. {
  843. const ValueTree child (state.getChild (i));
  844. if (child.getProperty (Ids::name) == name && child.hasType (Ids::GROUP))
  845. return Item (project, child, belongsToModule);
  846. }
  847. return addNewSubGroup (name, -1);
  848. }
  849. Project::Item Project::Item::addNewSubGroup (const String& name, int insertIndex)
  850. {
  851. String newID (createGUID (getID() + name + String (getNumChildren())));
  852. int n = 0;
  853. while (project.getMainGroup().findItemWithID (newID).isValid())
  854. newID = createGUID (newID + String (++n));
  855. Item group (createGroup (project, name, newID, belongsToModule));
  856. jassert (canContain (group));
  857. addChild (group, insertIndex);
  858. return group;
  859. }
  860. bool Project::Item::addFileAtIndex (const File& file, int insertIndex, const bool shouldCompile)
  861. {
  862. if (file == File() || file.isHidden() || file.getFileName().startsWithChar ('.'))
  863. return false;
  864. if (file.isDirectory())
  865. {
  866. Item group (addNewSubGroup (file.getFileName(), insertIndex));
  867. for (DirectoryIterator iter (file, false, "*", File::findFilesAndDirectories); iter.next();)
  868. if (! project.getMainGroup().findItemForFile (iter.getFile()).isValid())
  869. group.addFileRetainingSortOrder (iter.getFile(), shouldCompile);
  870. }
  871. else if (file.existsAsFile())
  872. {
  873. if (! project.getMainGroup().findItemForFile (file).isValid())
  874. addFileUnchecked (file, insertIndex, shouldCompile);
  875. }
  876. else
  877. {
  878. jassertfalse;
  879. }
  880. return true;
  881. }
  882. bool Project::Item::addFileRetainingSortOrder (const File& file, bool shouldCompile)
  883. {
  884. const bool wasSortedGroupsNotFirst = isGroupSorted (state, false);
  885. const bool wasSortedGroupsFirst = isGroupSorted (state, true);
  886. if (! addFileAtIndex (file, 0, shouldCompile))
  887. return false;
  888. if (wasSortedGroupsNotFirst || wasSortedGroupsFirst)
  889. sortAlphabetically (wasSortedGroupsFirst, false);
  890. return true;
  891. }
  892. void Project::Item::addFileUnchecked (const File& file, int insertIndex, const bool shouldCompile)
  893. {
  894. Item item (project, ValueTree (Ids::FILE), belongsToModule);
  895. item.initialiseMissingProperties();
  896. item.getNameValue() = file.getFileName();
  897. item.getShouldCompileValue() = shouldCompile && file.hasFileExtension (fileTypesToCompileByDefault);
  898. item.getShouldAddToBinaryResourcesValue() = project.shouldBeAddedToBinaryResourcesByDefault (file);
  899. if (canContain (item))
  900. {
  901. item.setFile (file);
  902. addChild (item, insertIndex);
  903. }
  904. }
  905. bool Project::Item::addRelativeFile (const RelativePath& file, int insertIndex, bool shouldCompile)
  906. {
  907. Item item (project, ValueTree (Ids::FILE), belongsToModule);
  908. item.initialiseMissingProperties();
  909. item.getNameValue() = file.getFileName();
  910. item.getShouldCompileValue() = shouldCompile;
  911. item.getShouldAddToBinaryResourcesValue() = project.shouldBeAddedToBinaryResourcesByDefault (file);
  912. if (canContain (item))
  913. {
  914. item.setFile (file);
  915. addChild (item, insertIndex);
  916. return true;
  917. }
  918. return false;
  919. }
  920. Icon Project::Item::getIcon() const
  921. {
  922. const Icons& icons = getIcons();
  923. if (isFile())
  924. {
  925. if (isImageFile())
  926. return Icon (icons.imageDoc, Colours::blue);
  927. return Icon (icons.document, Colours::yellow);
  928. }
  929. if (isMainGroup())
  930. return Icon (icons.juceLogo, Colours::orange);
  931. return Icon (icons.folder, Colours::darkgrey);
  932. }
  933. bool Project::Item::isIconCrossedOut() const
  934. {
  935. return isFile()
  936. && ! (shouldBeCompiled()
  937. || shouldBeAddedToBinaryResources()
  938. || getFile().hasFileExtension (headerFileExtensions));
  939. }
  940. //==============================================================================
  941. ValueTree Project::getConfigNode()
  942. {
  943. return projectRoot.getOrCreateChildWithName (Ids::JUCEOPTIONS, nullptr);
  944. }
  945. const char* const Project::configFlagDefault = "default";
  946. const char* const Project::configFlagEnabled = "enabled";
  947. const char* const Project::configFlagDisabled = "disabled";
  948. Value Project::getConfigFlag (const String& name)
  949. {
  950. ValueTree configNode (getConfigNode());
  951. Value v (configNode.getPropertyAsValue (name, getUndoManagerFor (configNode)));
  952. if (v.getValue().toString().isEmpty())
  953. v = configFlagDefault;
  954. return v;
  955. }
  956. bool Project::isConfigFlagEnabled (const String& name) const
  957. {
  958. return projectRoot.getChildWithName (Ids::JUCEOPTIONS).getProperty (name) == configFlagEnabled;
  959. }
  960. void Project::sanitiseConfigFlags()
  961. {
  962. ValueTree configNode (getConfigNode());
  963. for (int i = configNode.getNumProperties(); --i >= 0;)
  964. {
  965. const var value (configNode [configNode.getPropertyName(i)]);
  966. if (value != configFlagEnabled && value != configFlagDisabled)
  967. configNode.removeProperty (configNode.getPropertyName(i), getUndoManagerFor (configNode));
  968. }
  969. }
  970. //==============================================================================
  971. String Project::getPluginRTASCategoryCode()
  972. {
  973. if (static_cast<bool> (getPluginIsSynth().getValue()))
  974. return "ePlugInCategory_SWGenerators";
  975. String s (getPluginRTASCategory().toString());
  976. if (s.isEmpty())
  977. s = "ePlugInCategory_None";
  978. return s;
  979. }
  980. String Project::getAUMainTypeString()
  981. {
  982. String s (getPluginAUMainType().toString());
  983. if (s.isEmpty())
  984. {
  985. // Unfortunately, Rez uses a header where kAudioUnitType_MIDIProcessor is undefined
  986. // Use aumi instead.
  987. if (getPluginIsMidiEffectPlugin().getValue()) s = "'aumi'";
  988. else if (getPluginIsSynth().getValue()) s = "kAudioUnitType_MusicDevice";
  989. else if (getPluginWantsMidiInput().getValue()) s = "kAudioUnitType_MusicEffect";
  990. else s = "kAudioUnitType_Effect";
  991. }
  992. return s;
  993. }
  994. String Project::getAUMainTypeCode()
  995. {
  996. String s (getPluginAUMainType().toString());
  997. if (s.isEmpty())
  998. {
  999. if (getPluginIsMidiEffectPlugin().getValue()) s = "aumi";
  1000. else if (getPluginIsSynth().getValue()) s = "aumu";
  1001. else if (getPluginWantsMidiInput().getValue()) s = "aumf";
  1002. else s = "aufx";
  1003. }
  1004. return s;
  1005. }
  1006. String Project::getIAATypeCode()
  1007. {
  1008. String s;
  1009. if (getPluginWantsMidiInput().getValue())
  1010. {
  1011. if (getPluginIsSynth().getValue())
  1012. s = "auri";
  1013. else
  1014. s = "aurm";
  1015. }
  1016. else
  1017. {
  1018. if (getPluginIsSynth().getValue())
  1019. s = "aurg";
  1020. else
  1021. s = "aurx";
  1022. }
  1023. return s;
  1024. }
  1025. String Project::getIAAPluginName()
  1026. {
  1027. String s = getPluginManufacturer().toString();
  1028. s << ": ";
  1029. s << getPluginName().toString();
  1030. return s;
  1031. }
  1032. String Project::getPluginVSTCategoryString()
  1033. {
  1034. String s (getPluginVSTCategory().toString().trim());
  1035. if (s.isEmpty())
  1036. s = static_cast<bool> (getPluginIsSynth().getValue()) ? "kPlugCategSynth"
  1037. : "kPlugCategEffect";
  1038. return s;
  1039. }
  1040. bool Project::isAUPluginHost()
  1041. {
  1042. return getModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_AU");
  1043. }
  1044. bool Project::isVSTPluginHost()
  1045. {
  1046. return getModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_VST");
  1047. }
  1048. bool Project::isVST3PluginHost()
  1049. {
  1050. return getModules().isModuleEnabled ("juce_audio_processors") && isConfigFlagEnabled ("JUCE_PLUGINHOST_VST3");
  1051. }
  1052. //==============================================================================
  1053. EnabledModuleList& Project::getModules()
  1054. {
  1055. if (enabledModulesList == nullptr)
  1056. enabledModulesList = new EnabledModuleList (*this, projectRoot.getOrCreateChildWithName (Ids::MODULES, nullptr));
  1057. return *enabledModulesList;
  1058. }
  1059. //==============================================================================
  1060. ValueTree Project::getExporters()
  1061. {
  1062. return projectRoot.getOrCreateChildWithName (Ids::EXPORTFORMATS, nullptr);
  1063. }
  1064. int Project::getNumExporters()
  1065. {
  1066. return getExporters().getNumChildren();
  1067. }
  1068. ProjectExporter* Project::createExporter (int index)
  1069. {
  1070. jassert (index >= 0 && index < getNumExporters());
  1071. return ProjectExporter::createExporter (*this, getExporters().getChild (index));
  1072. }
  1073. void Project::addNewExporter (const String& exporterName)
  1074. {
  1075. ScopedPointer<ProjectExporter> exp (ProjectExporter::createNewExporter (*this, exporterName));
  1076. ValueTree exporters (getExporters());
  1077. exporters.addChild (exp->settings, -1, getUndoManagerFor (exporters));
  1078. }
  1079. void Project::createExporterForCurrentPlatform()
  1080. {
  1081. addNewExporter (ProjectExporter::getCurrentPlatformExporterName());
  1082. }
  1083. //==============================================================================
  1084. String Project::getFileTemplate (const String& templateName)
  1085. {
  1086. int dataSize;
  1087. if (const char* data = BinaryData::getNamedResource (templateName.toUTF8(), dataSize))
  1088. return String::fromUTF8 (data, dataSize);
  1089. jassertfalse;
  1090. return String();
  1091. }
  1092. //==============================================================================
  1093. Project::ExporterIterator::ExporterIterator (Project& p) : index (-1), project (p) {}
  1094. Project::ExporterIterator::~ExporterIterator() {}
  1095. bool Project::ExporterIterator::next()
  1096. {
  1097. if (++index >= project.getNumExporters())
  1098. return false;
  1099. exporter = project.createExporter (index);
  1100. if (exporter == nullptr)
  1101. {
  1102. jassertfalse; // corrupted project file?
  1103. return next();
  1104. }
  1105. return true;
  1106. }