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.

1134 lines
48KB

  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. #include "../Application/jucer_Headers.h"
  19. #include "jucer_ProjectExporter.h"
  20. #include "jucer_ProjectSaver.h"
  21. #include "jucer_ProjectExport_Make.h"
  22. #include "jucer_ProjectExport_MSVC.h"
  23. #include "jucer_ProjectExport_Xcode.h"
  24. #include "jucer_ProjectExport_Android.h"
  25. #include "jucer_ProjectExport_CodeBlocks.h"
  26. #include "../Utility/UI/PropertyComponents/jucer_FilePathPropertyComponent.h"
  27. //==============================================================================
  28. static auto createIcon (const void* iconData, size_t iconDataSize)
  29. {
  30. Image image (Image::ARGB, 200, 200, true);
  31. Graphics g (image);
  32. std::unique_ptr<Drawable> svgDrawable (Drawable::createFromImageData (iconData, iconDataSize));
  33. svgDrawable->drawWithin (g, image.getBounds().toFloat(), RectanglePlacement::fillDestination, 1.0f);
  34. return image;
  35. }
  36. template <typename Exporter>
  37. static ProjectExporter::ExporterTypeInfo createExporterTypeInfo (const void* iconData, size_t iconDataSize)
  38. {
  39. return { Exporter::getValueTreeTypeName(),
  40. Exporter::getDisplayName(),
  41. Exporter::getTargetFolderName(),
  42. createIcon (iconData, iconDataSize) };
  43. }
  44. std::vector<ProjectExporter::ExporterTypeInfo> ProjectExporter::getExporterTypeInfos()
  45. {
  46. using namespace BinaryData;
  47. static std::vector<ProjectExporter::ExporterTypeInfo> infos
  48. {
  49. { XcodeProjectExporter::getValueTreeTypeNameMac(),
  50. XcodeProjectExporter::getDisplayNameMac(),
  51. XcodeProjectExporter::getTargetFolderNameMac(),
  52. createIcon (export_xcode_svg, (size_t) export_xcode_svgSize) },
  53. { XcodeProjectExporter::getValueTreeTypeNameiOS(),
  54. XcodeProjectExporter::getDisplayNameiOS(),
  55. XcodeProjectExporter::getTargetFolderNameiOS(),
  56. createIcon (export_xcode_svg, (size_t) export_xcode_svgSize) },
  57. createExporterTypeInfo<MSVCProjectExporterVC2022> (export_visualStudio_svg, export_visualStudio_svgSize),
  58. createExporterTypeInfo<MSVCProjectExporterVC2019> (export_visualStudio_svg, export_visualStudio_svgSize),
  59. createExporterTypeInfo<MSVCProjectExporterVC2017> (export_visualStudio_svg, export_visualStudio_svgSize),
  60. createExporterTypeInfo<MakefileProjectExporter> (export_linux_svg, export_linux_svgSize),
  61. createExporterTypeInfo<AndroidProjectExporter> (export_android_svg, export_android_svgSize),
  62. { CodeBlocksProjectExporter::getValueTreeTypeNameWindows(),
  63. CodeBlocksProjectExporter::getDisplayNameWindows(),
  64. CodeBlocksProjectExporter::getTargetFolderNameWindows(),
  65. createIcon (export_codeBlocks_svg, export_codeBlocks_svgSize) },
  66. { CodeBlocksProjectExporter::getValueTreeTypeNameLinux(),
  67. CodeBlocksProjectExporter::getDisplayNameLinux(),
  68. CodeBlocksProjectExporter::getTargetFolderNameLinux(),
  69. createIcon (export_codeBlocks_svg, export_codeBlocks_svgSize) }
  70. };
  71. return infos;
  72. }
  73. ProjectExporter::ExporterTypeInfo ProjectExporter::getTypeInfoForExporter (const Identifier& exporterIdentifier)
  74. {
  75. auto typeInfos = getExporterTypeInfos();
  76. auto iter = std::find_if (typeInfos.begin(), typeInfos.end(),
  77. [exporterIdentifier] (const ProjectExporter::ExporterTypeInfo& info) { return info.identifier == exporterIdentifier; });
  78. if (iter != typeInfos.end())
  79. return *iter;
  80. jassertfalse;
  81. return {};
  82. }
  83. ProjectExporter::ExporterTypeInfo ProjectExporter::getCurrentPlatformExporterTypeInfo()
  84. {
  85. #if JUCE_MAC
  86. return ProjectExporter::getTypeInfoForExporter (XcodeProjectExporter::getValueTreeTypeNameMac());
  87. #elif JUCE_WINDOWS
  88. return ProjectExporter::getTypeInfoForExporter (MSVCProjectExporterVC2022::getValueTreeTypeName());
  89. #elif JUCE_LINUX || JUCE_BSD
  90. return ProjectExporter::getTypeInfoForExporter (MakefileProjectExporter::getValueTreeTypeName());
  91. #else
  92. #error "unknown platform!"
  93. #endif
  94. }
  95. std::unique_ptr<ProjectExporter> ProjectExporter::createNewExporter (Project& project, const Identifier& exporterIdentifier)
  96. {
  97. auto exporter = createExporterFromSettings (project, ValueTree (exporterIdentifier));
  98. jassert (exporter != nullptr);
  99. exporter->createDefaultConfigs();
  100. exporter->createDefaultModulePaths();
  101. return exporter;
  102. }
  103. template <typename T> struct Tag {};
  104. static std::unique_ptr<ProjectExporter> tryCreatingExporter (Project&, const ValueTree&) { return nullptr; }
  105. template <typename Exporter, typename... Exporters>
  106. static std::unique_ptr<ProjectExporter> tryCreatingExporter (Project& project,
  107. const ValueTree& settings,
  108. Tag<Exporter>,
  109. Tag<Exporters>... exporters)
  110. {
  111. if (auto* exporter = Exporter::createForSettings (project, settings))
  112. return rawToUniquePtr (exporter);
  113. return tryCreatingExporter (project, settings, exporters...);
  114. }
  115. std::unique_ptr<ProjectExporter> ProjectExporter::createExporterFromSettings (Project& project, const ValueTree& settings)
  116. {
  117. return tryCreatingExporter (project,
  118. settings,
  119. Tag<XcodeProjectExporter>{},
  120. Tag<MSVCProjectExporterVC2022>{},
  121. Tag<MSVCProjectExporterVC2019>{},
  122. Tag<MSVCProjectExporterVC2017>{},
  123. Tag<MakefileProjectExporter>{},
  124. Tag<AndroidProjectExporter>{},
  125. Tag<CodeBlocksProjectExporter>{});
  126. }
  127. bool ProjectExporter::canProjectBeLaunched (Project* project)
  128. {
  129. if (project != nullptr)
  130. {
  131. static Identifier types[]
  132. {
  133. #if JUCE_MAC
  134. XcodeProjectExporter::getValueTreeTypeNameMac(),
  135. XcodeProjectExporter::getValueTreeTypeNameiOS(),
  136. #elif JUCE_WINDOWS
  137. MSVCProjectExporterVC2022::getValueTreeTypeName(),
  138. MSVCProjectExporterVC2019::getValueTreeTypeName(),
  139. MSVCProjectExporterVC2017::getValueTreeTypeName(),
  140. #endif
  141. AndroidProjectExporter::getValueTreeTypeName()
  142. };
  143. for (auto& exporterIdentifier : types)
  144. if (project->getExporters().getChildWithName (exporterIdentifier).isValid())
  145. return true;
  146. }
  147. return false;
  148. }
  149. //==============================================================================
  150. ProjectExporter::ProjectExporter (Project& p, const ValueTree& state)
  151. : settings (state),
  152. project (p),
  153. projectType (p.getProjectType()),
  154. projectName (p.getProjectNameString()),
  155. projectFolder (p.getProjectFolder()),
  156. targetLocationValue (settings, Ids::targetFolder, getUndoManager()),
  157. extraCompilerFlagsValue (settings, Ids::extraCompilerFlags, getUndoManager()),
  158. extraLinkerFlagsValue (settings, Ids::extraLinkerFlags, getUndoManager()),
  159. externalLibrariesValue (settings, Ids::externalLibraries, getUndoManager()),
  160. userNotesValue (settings, Ids::userNotes, getUndoManager()),
  161. gnuExtensionsValue (settings, Ids::enableGNUExtensions, getUndoManager()),
  162. bigIconValue (settings, Ids::bigIcon, getUndoManager()),
  163. smallIconValue (settings, Ids::smallIcon, getUndoManager()),
  164. extraPPDefsValue (settings, Ids::extraDefs, getUndoManager())
  165. {
  166. projectCompilerFlagSchemesValue = project.getProjectValue (Ids::compilerFlagSchemes);
  167. projectCompilerFlagSchemesValue.addListener (this);
  168. updateCompilerFlagValues();
  169. }
  170. String ProjectExporter::getUniqueName() const
  171. {
  172. auto targetLocationString = getTargetLocationString();
  173. auto defaultBuildsRootFolder = getDefaultBuildsRootFolder();
  174. auto typeInfos = getExporterTypeInfos();
  175. auto predicate = [targetLocationString, defaultBuildsRootFolder] (const ProjectExporter::ExporterTypeInfo& info)
  176. {
  177. return defaultBuildsRootFolder + info.targetFolder == targetLocationString;
  178. };
  179. if (std::none_of (typeInfos.begin(), typeInfos.end(), std::move (predicate)))
  180. return name + " - " + targetLocationString;
  181. return name;
  182. }
  183. File ProjectExporter::getTargetFolder() const
  184. {
  185. return project.resolveFilename (getTargetLocationString());
  186. }
  187. build_tools::RelativePath ProjectExporter::rebaseFromProjectFolderToBuildTarget (const build_tools::RelativePath& path) const
  188. {
  189. return path.rebased (project.getProjectFolder(), getTargetFolder(), build_tools::RelativePath::buildTargetFolder);
  190. }
  191. bool ProjectExporter::shouldFileBeCompiledByDefault (const File& file) const
  192. {
  193. return file.hasFileExtension (cOrCppFileExtensions)
  194. || file.hasFileExtension (asmFileExtensions);
  195. }
  196. void ProjectExporter::updateCompilerFlagValues()
  197. {
  198. compilerFlagSchemesMap.clear();
  199. for (auto& scheme : project.getCompilerFlagSchemes())
  200. compilerFlagSchemesMap.set (scheme, { settings, scheme, getUndoManager() });
  201. }
  202. //==============================================================================
  203. void ProjectExporter::createPropertyEditors (PropertyListBuilder& props)
  204. {
  205. props.add (new TextPropertyComponent (targetLocationValue, "Target Project Folder", 2048, false),
  206. "The location of the folder in which the " + name + " project will be created. "
  207. "This path can be absolute, but it's much more sensible to make it relative to the jucer project directory.");
  208. if ((shouldBuildTargetType (build_tools::ProjectType::Target::VSTPlugIn) && project.shouldBuildVST()) || (project.isVSTPluginHost() && supportsTargetType (build_tools::ProjectType::Target::VSTPlugIn)))
  209. {
  210. props.add (new FilePathPropertyComponent (vstLegacyPathValueWrapper.getWrappedValueTreePropertyWithDefault(), "VST (Legacy) SDK Folder", true,
  211. getTargetOSForExporter() == TargetOS::getThisOS(), "*", project.getProjectFolder()),
  212. "If you're building a VST plug-in or host, you can use this field to override the global VST (Legacy) SDK path with a project-specific path. "
  213. "This can be an absolute path, or a path relative to the Projucer project file.");
  214. }
  215. if (shouldBuildTargetType (build_tools::ProjectType::Target::AAXPlugIn) && project.shouldBuildAAX())
  216. {
  217. props.add (new FilePathPropertyComponent (aaxPathValueWrapper.getWrappedValueTreePropertyWithDefault(), "AAX SDK Folder", true,
  218. getTargetOSForExporter() == TargetOS::getThisOS(), "*", project.getProjectFolder()),
  219. "If you're building an AAX plug-in, this must be the folder containing the AAX SDK. This can be an absolute path, or a path relative to the Projucer project file.");
  220. }
  221. if (project.shouldEnableARA() || project.isARAPluginHost())
  222. {
  223. props.add (new FilePathPropertyComponent (araPathValueWrapper.getWrappedValueTreePropertyWithDefault(), "ARA SDK Folder", true,
  224. getTargetOSForExporter() == TargetOS::getThisOS(), "*", project.getProjectFolder()),
  225. "If you're building an ARA enabled plug-in, this must be the folder containing the ARA SDK. This can be an absolute path, or a path relative to the Projucer project file.");
  226. }
  227. props.add (new TextPropertyComponent (extraPPDefsValue, "Extra Preprocessor Definitions", 32768, true),
  228. "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace, commas, "
  229. "or new-lines to separate the items - to include a space or comma in a definition, precede it with a backslash.");
  230. props.add (new TextPropertyComponent (extraCompilerFlagsValue, "Extra Compiler Flags", 8192, true),
  231. "Extra command-line flags to be passed to the compiler. This string can contain references to preprocessor definitions in the "
  232. "form ${NAME_OF_DEFINITION}, which will be replaced with their values.");
  233. for (HashMap<String, ValueTreePropertyWithDefault>::Iterator i (compilerFlagSchemesMap); i.next();)
  234. props.add (new TextPropertyComponent (compilerFlagSchemesMap.getReference (i.getKey()), "Compiler Flags for " + i.getKey().quoted(), 8192, false),
  235. "The exporter-specific compiler flags that will be added to files using this scheme.");
  236. props.add (new TextPropertyComponent (extraLinkerFlagsValue, "Extra Linker Flags", 8192, true),
  237. "Extra command-line flags to be passed to the linker. You might want to use this for adding additional libraries. "
  238. "This string can contain references to preprocessor definitions in the form ${NAME_OF_VALUE}, which will be replaced with their values.");
  239. props.add (new TextPropertyComponent (externalLibrariesValue, "External Libraries to Link", 8192, true),
  240. "Additional libraries to link (one per line). You should not add any platform specific decoration to these names. "
  241. "This string can contain references to preprocessor definitions in the form ${NAME_OF_VALUE}, which will be replaced with their values.");
  242. if (! isVisualStudio())
  243. props.add (new ChoicePropertyComponent (gnuExtensionsValue, "GNU Compiler Extensions"),
  244. "Enabling this will use the GNU C++ language standard variant for compilation.");
  245. createIconProperties (props);
  246. createExporterProperties (props);
  247. props.add (new TextPropertyComponent (userNotesValue, "Notes", 32768, true),
  248. "Extra comments: This field is not used for code or project generation, it's just a space where you can express your thoughts.");
  249. }
  250. void ProjectExporter::createIconProperties (PropertyListBuilder& props)
  251. {
  252. OwnedArray<Project::Item> images;
  253. project.findAllImageItems (images);
  254. StringArray choices;
  255. Array<var> ids;
  256. choices.add ("<None>");
  257. ids.add (var());
  258. for (const auto* imageItem : images)
  259. {
  260. choices.add (imageItem->getName());
  261. ids.add (imageItem->getID());
  262. }
  263. props.add (new ChoicePropertyComponent (smallIconValue, "Icon (Small)", choices, ids),
  264. "Sets an icon to use for the executable.");
  265. props.add (new ChoicePropertyComponent (bigIconValue, "Icon (Large)", choices, ids),
  266. "Sets an icon to use for the executable.");
  267. }
  268. //==============================================================================
  269. void ProjectExporter::addSettingsForProjectType (const build_tools::ProjectType& type)
  270. {
  271. addExtraIncludePathsIfPluginOrHost();
  272. addARAPathsIfPluginOrHost();
  273. if (type.isAudioPlugin())
  274. addCommonAudioPluginSettings();
  275. addPlatformSpecificSettingsForProjectType (type);
  276. }
  277. void ProjectExporter::addExtraIncludePathsIfPluginOrHost()
  278. {
  279. using Target = build_tools::ProjectType::Target;
  280. if (((shouldBuildTargetType (Target::VSTPlugIn) && project.shouldBuildVST()) || project.isVSTPluginHost())
  281. || ((shouldBuildTargetType (Target::VST3PlugIn) && project.shouldBuildVST3()) || project.isVST3PluginHost()))
  282. {
  283. addLegacyVSTFolderToPathIfSpecified();
  284. if (! project.isConfigFlagEnabled ("JUCE_CUSTOM_VST3_SDK"))
  285. addToExtraSearchPaths (getInternalVST3SDKPath(), 0);
  286. }
  287. const auto lv2BasePath = getModuleFolderRelativeToProject ("juce_audio_processors").getChildFile ("format_types")
  288. .getChildFile ("LV2_SDK");
  289. if ((shouldBuildTargetType (Target::LV2PlugIn) && project.shouldBuildLV2()) || project.isLV2PluginHost())
  290. {
  291. const std::vector<const char*> paths[] { { "" },
  292. { "lv2" },
  293. { "serd" },
  294. { "sord" },
  295. { "sord", "src" },
  296. { "sratom" },
  297. { "lilv" },
  298. { "lilv", "src" } };
  299. for (const auto& components : paths)
  300. {
  301. const auto appendComponent = [] (const build_tools::RelativePath& f, const char* component)
  302. {
  303. return f.getChildFile (component);
  304. };
  305. const auto includePath = std::accumulate (components.begin(),
  306. components.end(),
  307. lv2BasePath,
  308. appendComponent);
  309. addToExtraSearchPaths (includePath, 0);
  310. }
  311. }
  312. }
  313. void ProjectExporter::addARAPathsIfPluginOrHost()
  314. {
  315. if (project.shouldEnableARA() || project.isARAPluginHost())
  316. addARAFoldersToPath();
  317. }
  318. void ProjectExporter::addCommonAudioPluginSettings()
  319. {
  320. if (shouldBuildTargetType (build_tools::ProjectType::Target::AAXPlugIn))
  321. addAAXFoldersToPath();
  322. }
  323. void ProjectExporter::addLegacyVSTFolderToPathIfSpecified()
  324. {
  325. auto vstFolder = getVSTLegacyPathString();
  326. if (vstFolder.isNotEmpty())
  327. addToExtraSearchPaths (build_tools::RelativePath (vstFolder, build_tools::RelativePath::projectFolder), 0);
  328. }
  329. build_tools::RelativePath ProjectExporter::getInternalVST3SDKPath()
  330. {
  331. return getModuleFolderRelativeToProject ("juce_audio_processors")
  332. .getChildFile ("format_types")
  333. .getChildFile ("VST3_SDK");
  334. }
  335. void ProjectExporter::addAAXFoldersToPath()
  336. {
  337. auto aaxFolder = getAAXPathString();
  338. if (aaxFolder.isNotEmpty())
  339. {
  340. build_tools::RelativePath aaxFolderPath (aaxFolder, build_tools::RelativePath::projectFolder);
  341. addToExtraSearchPaths (aaxFolderPath);
  342. addToExtraSearchPaths (aaxFolderPath.getChildFile ("Interfaces"));
  343. addToExtraSearchPaths (aaxFolderPath.getChildFile ("Interfaces").getChildFile ("ACF"));
  344. }
  345. }
  346. void ProjectExporter::addARAFoldersToPath()
  347. {
  348. const auto araFolder = getARAPathString();
  349. if (araFolder.isNotEmpty())
  350. addToExtraSearchPaths (build_tools::RelativePath (araFolder, build_tools::RelativePath::projectFolder));
  351. }
  352. //==============================================================================
  353. StringPairArray ProjectExporter::getAllPreprocessorDefs (const BuildConfiguration& config, const build_tools::ProjectType::Target::Type targetType) const
  354. {
  355. auto defs = mergePreprocessorDefs (config.getAllPreprocessorDefs(),
  356. parsePreprocessorDefs (getExporterPreprocessorDefsString()));
  357. addDefaultPreprocessorDefs (defs);
  358. addTargetSpecificPreprocessorDefs (defs, targetType);
  359. if (! project.shouldUseAppConfig())
  360. defs = mergePreprocessorDefs (project.getAppConfigDefs(), defs);
  361. return defs;
  362. }
  363. StringPairArray ProjectExporter::getAllPreprocessorDefs() const
  364. {
  365. auto defs = mergePreprocessorDefs (project.getPreprocessorDefs(),
  366. parsePreprocessorDefs (getExporterPreprocessorDefsString()));
  367. addDefaultPreprocessorDefs (defs);
  368. return defs;
  369. }
  370. void ProjectExporter::addTargetSpecificPreprocessorDefs (StringPairArray& defs, const build_tools::ProjectType::Target::Type targetType) const
  371. {
  372. using Target = build_tools::ProjectType::Target::Type;
  373. const std::pair<const char*, Target> targetFlags[] { { "JucePlugin_Build_VST", Target::VSTPlugIn },
  374. { "JucePlugin_Build_VST3", Target::VST3PlugIn },
  375. { "JucePlugin_Build_AU", Target::AudioUnitPlugIn },
  376. { "JucePlugin_Build_AUv3", Target::AudioUnitv3PlugIn },
  377. { "JucePlugin_Build_AAX", Target::AAXPlugIn },
  378. { "JucePlugin_Build_Standalone", Target::StandalonePlugIn },
  379. { "JucePlugin_Build_Unity", Target::UnityPlugIn },
  380. { "JucePlugin_Build_LV2", Target::LV2PlugIn } };
  381. if (targetType == build_tools::ProjectType::Target::SharedCodeTarget)
  382. {
  383. for (auto& flag : targetFlags)
  384. defs.set (flag.first, (shouldBuildTargetType (flag.second) ? "1" : "0"));
  385. defs.set ("JUCE_SHARED_CODE", "1");
  386. }
  387. else if (targetType != build_tools::ProjectType::Target::unspecified)
  388. {
  389. for (auto& flag : targetFlags)
  390. defs.set (flag.first, (targetType == flag.second ? "1" : "0"));
  391. }
  392. if (project.shouldEnableARA())
  393. {
  394. defs.set ("JucePlugin_Enable_ARA", "1");
  395. }
  396. }
  397. void ProjectExporter::addDefaultPreprocessorDefs (StringPairArray& defs) const
  398. {
  399. defs.set (getExporterIdentifierMacro(), "1");
  400. defs.set ("JUCE_APP_VERSION", project.getVersionString());
  401. defs.set ("JUCE_APP_VERSION_HEX", project.getVersionAsHex());
  402. }
  403. String ProjectExporter::replacePreprocessorTokens (const ProjectExporter::BuildConfiguration& config,
  404. const String& sourceString) const
  405. {
  406. return build_tools::replacePreprocessorDefs (getAllPreprocessorDefs (config, build_tools::ProjectType::Target::unspecified),
  407. sourceString);
  408. }
  409. String ProjectExporter::getCompilerFlagsForProjectItem (const Project::Item& projectItem) const
  410. {
  411. if (auto buildConfigurationForFile = getBuildConfigurationWithName (projectItem.getCompilerFlagSchemeString()))
  412. return buildConfigurationForFile->getAllCompilerFlagsString();
  413. return {};
  414. }
  415. void ProjectExporter::copyMainGroupFromProject()
  416. {
  417. jassert (itemGroups.size() == 0);
  418. itemGroups.add (project.getMainGroup().createCopy());
  419. }
  420. Project::Item& ProjectExporter::getModulesGroup()
  421. {
  422. if (modulesGroup == nullptr)
  423. {
  424. jassert (itemGroups.size() > 0); // must call copyMainGroupFromProject before this.
  425. itemGroups.add (Project::Item::createGroup (project, "JUCE Modules", "__modulesgroup__", true));
  426. modulesGroup = &(itemGroups.getReference (itemGroups.size() - 1));
  427. }
  428. return *modulesGroup;
  429. }
  430. //==============================================================================
  431. static bool isWebBrowserComponentEnabled (Project& project)
  432. {
  433. static String guiExtrasModule ("juce_gui_extra");
  434. return (project.getEnabledModules().isModuleEnabled (guiExtrasModule)
  435. && project.isConfigFlagEnabled ("JUCE_WEB_BROWSER", true));
  436. }
  437. static bool isCurlEnabled (Project& project)
  438. {
  439. static String juceCoreModule ("juce_core");
  440. return (project.getEnabledModules().isModuleEnabled (juceCoreModule)
  441. && project.isConfigFlagEnabled ("JUCE_USE_CURL", true));
  442. }
  443. static bool isLoadCurlSymbolsLazilyEnabled (Project& project)
  444. {
  445. static String juceCoreModule ("juce_core");
  446. return (project.getEnabledModules().isModuleEnabled (juceCoreModule)
  447. && project.isConfigFlagEnabled ("JUCE_LOAD_CURL_SYMBOLS_LAZILY", false));
  448. }
  449. StringArray ProjectExporter::getLinuxPackages (PackageDependencyType type) const
  450. {
  451. auto packages = linuxPackages;
  452. // don't add libcurl if curl symbols are loaded at runtime
  453. if (isCurlEnabled (project) && ! isLoadCurlSymbolsLazilyEnabled (project))
  454. packages.add ("libcurl");
  455. if (isWebBrowserComponentEnabled (project) && type == PackageDependencyType::compile)
  456. {
  457. packages.add ("webkit2gtk-4.0");
  458. packages.add ("gtk+-x11-3.0");
  459. }
  460. packages.removeEmptyStrings();
  461. packages.removeDuplicates (false);
  462. return packages;
  463. }
  464. void ProjectExporter::addProjectPathToBuildPathList (StringArray& pathList,
  465. const build_tools::RelativePath& pathFromProjectFolder,
  466. int index) const
  467. {
  468. auto localPath = build_tools::RelativePath (rebaseFromProjectFolderToBuildTarget (pathFromProjectFolder));
  469. auto path = isVisualStudio() ? localPath.toWindowsStyle() : localPath.toUnixStyle();
  470. if (! pathList.contains (path))
  471. pathList.insert (index, path);
  472. }
  473. void ProjectExporter::addToModuleLibPaths (const build_tools::RelativePath& pathFromProjectFolder)
  474. {
  475. addProjectPathToBuildPathList (moduleLibSearchPaths, pathFromProjectFolder);
  476. }
  477. void ProjectExporter::addToExtraSearchPaths (const build_tools::RelativePath& pathFromProjectFolder, int index)
  478. {
  479. addProjectPathToBuildPathList (extraSearchPaths, pathFromProjectFolder, index);
  480. }
  481. static var getStoredPathForModule (const String& id, const ProjectExporter& exp)
  482. {
  483. return getAppSettings().getStoredPath (isJUCEModule (id) ? Ids::defaultJuceModulePath : Ids::defaultUserModulePath,
  484. exp.getTargetOSForExporter()).get();
  485. }
  486. ValueTreePropertyWithDefault ProjectExporter::getPathForModuleValue (const String& moduleID)
  487. {
  488. auto* um = getUndoManager();
  489. auto paths = settings.getOrCreateChildWithName (Ids::MODULEPATHS, um);
  490. auto m = paths.getChildWithProperty (Ids::ID, moduleID);
  491. if (! m.isValid())
  492. {
  493. m = ValueTree (Ids::MODULEPATH);
  494. m.setProperty (Ids::ID, moduleID, um);
  495. paths.appendChild (m, um);
  496. }
  497. return { m, Ids::path, um, getStoredPathForModule (moduleID, *this) };
  498. }
  499. String ProjectExporter::getPathForModuleString (const String& moduleID) const
  500. {
  501. auto exporterPath = settings.getChildWithName (Ids::MODULEPATHS)
  502. .getChildWithProperty (Ids::ID, moduleID) [Ids::path].toString();
  503. if (exporterPath.isEmpty() || project.getEnabledModules().shouldUseGlobalPath (moduleID))
  504. return getStoredPathForModule (moduleID, *this);
  505. return exporterPath;
  506. }
  507. void ProjectExporter::removePathForModule (const String& moduleID)
  508. {
  509. auto paths = settings.getChildWithName (Ids::MODULEPATHS);
  510. auto m = paths.getChildWithProperty (Ids::ID, moduleID);
  511. paths.removeChild (m, project.getUndoManagerFor (settings));
  512. }
  513. TargetOS::OS ProjectExporter::getTargetOSForExporter() const
  514. {
  515. auto targetOS = TargetOS::unknown;
  516. if (isWindows()) targetOS = TargetOS::windows;
  517. else if (isOSX() || isiOS()) targetOS = TargetOS::osx;
  518. else if (isLinux()) targetOS = TargetOS::linux;
  519. else if (isAndroid()) targetOS = TargetOS::getThisOS();
  520. return targetOS;
  521. }
  522. build_tools::RelativePath ProjectExporter::getModuleFolderRelativeToProject (const String& moduleID) const
  523. {
  524. if (project.getEnabledModules().shouldCopyModuleFilesLocally (moduleID))
  525. return build_tools::RelativePath (project.getRelativePathForFile (project.getLocalModuleFolder (moduleID)),
  526. build_tools::RelativePath::projectFolder);
  527. auto path = getPathForModuleString (moduleID);
  528. if (path.isEmpty())
  529. return getLegacyModulePath (moduleID).getChildFile (moduleID);
  530. return build_tools::RelativePath (path, build_tools::RelativePath::projectFolder).getChildFile (moduleID);
  531. }
  532. String ProjectExporter::getLegacyModulePath() const
  533. {
  534. return getSettingString ("juceFolder");
  535. }
  536. build_tools::RelativePath ProjectExporter::getLegacyModulePath (const String& moduleID) const
  537. {
  538. if (project.getEnabledModules().shouldCopyModuleFilesLocally (moduleID))
  539. return build_tools::RelativePath (project.getRelativePathForFile (project.getGeneratedCodeFolder()
  540. .getChildFile ("modules")
  541. .getChildFile (moduleID)), build_tools::RelativePath::projectFolder);
  542. auto oldJucePath = getLegacyModulePath();
  543. if (oldJucePath.isEmpty())
  544. return build_tools::RelativePath();
  545. build_tools::RelativePath p (oldJucePath, build_tools::RelativePath::projectFolder);
  546. if (p.getFileName() != "modules")
  547. p = p.getChildFile ("modules");
  548. return p.getChildFile (moduleID);
  549. }
  550. void ProjectExporter::updateOldModulePaths()
  551. {
  552. auto oldPath = getLegacyModulePath();
  553. if (oldPath.isNotEmpty())
  554. {
  555. for (int i = project.getEnabledModules().getNumModules(); --i >= 0;)
  556. {
  557. auto modID = project.getEnabledModules().getModuleID (i);
  558. getPathForModuleValue (modID) = getLegacyModulePath (modID).getParentDirectory().toUnixStyle();
  559. }
  560. settings.removeProperty ("juceFolder", nullptr);
  561. }
  562. }
  563. static bool areSameExporters (const ProjectExporter& p1, const ProjectExporter& p2)
  564. {
  565. return p1.getExporterIdentifier() == p2.getExporterIdentifier();
  566. }
  567. static bool areCompatibleExporters (const ProjectExporter& p1, const ProjectExporter& p2)
  568. {
  569. return (p1.isVisualStudio() && p2.isVisualStudio())
  570. || (p1.isXcode() && p2.isXcode())
  571. || (p1.isMakefile() && p2.isMakefile())
  572. || (p1.isAndroidStudio() && p2.isAndroidStudio())
  573. || (p1.isCodeBlocks() && p2.isCodeBlocks() && p1.isWindows() != p2.isLinux());
  574. }
  575. void ProjectExporter::createDefaultModulePaths()
  576. {
  577. auto exporterToCopy = [this]() -> std::unique_ptr<ProjectExporter>
  578. {
  579. std::vector<std::unique_ptr<ProjectExporter>> exporters;
  580. for (Project::ExporterIterator exporter (project); exporter.next();)
  581. exporters.push_back (std::move (exporter.exporter));
  582. auto getIf = [&exporters] (auto predicate)
  583. {
  584. auto iter = std::find_if (exporters.begin(), exporters.end(), predicate);
  585. return iter != exporters.end() ? std::move (*iter) : nullptr;
  586. };
  587. if (auto exporter = getIf ([this] (auto& x) { return areSameExporters (*this, *x); }))
  588. return exporter;
  589. if (auto exporter = getIf ([this] (auto& x) { return areCompatibleExporters (*this, *x); }))
  590. return exporter;
  591. if (auto exporter = getIf ([] (auto& x) { return x->canLaunchProject(); }))
  592. return exporter;
  593. return {};
  594. }();
  595. for (const auto& modID : project.getEnabledModules().getAllModules())
  596. getPathForModuleValue (modID) = (exporterToCopy != nullptr ? exporterToCopy->getPathForModuleString (modID) : "../../juce");
  597. }
  598. //==============================================================================
  599. ValueTree ProjectExporter::getConfigurations() const
  600. {
  601. return settings.getChildWithName (Ids::CONFIGURATIONS);
  602. }
  603. int ProjectExporter::getNumConfigurations() const
  604. {
  605. return getConfigurations().getNumChildren();
  606. }
  607. ProjectExporter::BuildConfiguration::Ptr ProjectExporter::getConfiguration (int index) const
  608. {
  609. return createBuildConfig (getConfigurations().getChild (index));
  610. }
  611. std::optional<ValueTree> ProjectExporter::getConfigurationWithName (const String& nameToFind) const
  612. {
  613. auto configs = getConfigurations();
  614. for (int i = configs.getNumChildren(); --i >= 0;)
  615. {
  616. auto config = configs.getChild (i);
  617. if (config[Ids::name].toString() == nameToFind)
  618. return config;
  619. }
  620. return {};
  621. }
  622. ProjectExporter::BuildConfiguration::Ptr ProjectExporter::getBuildConfigurationWithName (const String& nameToFind) const
  623. {
  624. if (auto config = getConfigurationWithName (nameToFind))
  625. return createBuildConfig (*config);
  626. return nullptr;
  627. }
  628. String ProjectExporter::getUniqueConfigName (String nm) const
  629. {
  630. auto nameRoot = nm;
  631. while (CharacterFunctions::isDigit (nameRoot.getLastCharacter()))
  632. nameRoot = nameRoot.dropLastCharacters (1);
  633. nameRoot = nameRoot.trim();
  634. int suffix = 2;
  635. while (getConfigurationWithName (name).has_value())
  636. nm = nameRoot + " " + String (suffix++);
  637. return nm;
  638. }
  639. void ProjectExporter::addNewConfigurationFromExisting (const BuildConfiguration& configToCopy)
  640. {
  641. auto configs = getConfigurations();
  642. if (! configs.isValid())
  643. {
  644. settings.addChild (ValueTree (Ids::CONFIGURATIONS), 0, project.getUndoManagerFor (settings));
  645. configs = getConfigurations();
  646. }
  647. ValueTree newConfig (Ids::CONFIGURATION);
  648. newConfig = configToCopy.config.createCopy();
  649. newConfig.setProperty (Ids::name, configToCopy.getName(), nullptr);
  650. configs.appendChild (newConfig, project.getUndoManagerFor (configs));
  651. }
  652. void ProjectExporter::addNewConfiguration (bool isDebugConfig)
  653. {
  654. auto configs = getConfigurations();
  655. if (! configs.isValid())
  656. {
  657. settings.addChild (ValueTree (Ids::CONFIGURATIONS), 0, project.getUndoManagerFor (settings));
  658. configs = getConfigurations();
  659. }
  660. ValueTree newConfig (Ids::CONFIGURATION);
  661. newConfig.setProperty (Ids::isDebug, isDebugConfig, project.getUndoManagerFor (settings));
  662. configs.appendChild (newConfig, project.getUndoManagerFor (settings));
  663. }
  664. void ProjectExporter::BuildConfiguration::removeFromExporter()
  665. {
  666. ValueTree configs (config.getParent());
  667. configs.removeChild (config, project.getUndoManagerFor (configs));
  668. }
  669. void ProjectExporter::createDefaultConfigs()
  670. {
  671. settings.getOrCreateChildWithName (Ids::CONFIGURATIONS, nullptr);
  672. for (int i = 0; i < 2; ++i)
  673. {
  674. auto isDebug = i == 0;
  675. addNewConfiguration (isDebug);
  676. BuildConfiguration::Ptr config (getConfiguration (i));
  677. config->getValue (Ids::name) = (isDebug ? "Debug" : "Release");
  678. }
  679. }
  680. std::unique_ptr<Drawable> ProjectExporter::getBigIcon() const
  681. {
  682. return project.getMainGroup().findItemWithID (settings [Ids::bigIcon]).loadAsImageFile();
  683. }
  684. std::unique_ptr<Drawable> ProjectExporter::getSmallIcon() const
  685. {
  686. return project.getMainGroup().findItemWithID (settings [Ids::smallIcon]).loadAsImageFile();
  687. }
  688. //==============================================================================
  689. ProjectExporter::ConfigIterator::ConfigIterator (ProjectExporter& e)
  690. : index (-1), exporter (e)
  691. {
  692. }
  693. bool ProjectExporter::ConfigIterator::next()
  694. {
  695. if (++index >= exporter.getNumConfigurations())
  696. return false;
  697. config = exporter.getConfiguration (index);
  698. return true;
  699. }
  700. ProjectExporter::ConstConfigIterator::ConstConfigIterator (const ProjectExporter& exporter_)
  701. : index (-1), exporter (exporter_)
  702. {
  703. }
  704. bool ProjectExporter::ConstConfigIterator::next()
  705. {
  706. if (++index >= exporter.getNumConfigurations())
  707. return false;
  708. config = exporter.getConfiguration (index);
  709. return true;
  710. }
  711. //==============================================================================
  712. ProjectExporter::BuildConfiguration::BuildConfiguration (Project& p, const ValueTree& configNode, const ProjectExporter& e)
  713. : config (configNode), project (p), exporter (e),
  714. isDebugValue (config, Ids::isDebug, getUndoManager(), getValue (Ids::isDebug)),
  715. configNameValue (config, Ids::name, getUndoManager(), "Build Configuration"),
  716. targetNameValue (config, Ids::targetName, getUndoManager(), project.getProjectFilenameRootString()),
  717. targetBinaryPathValue (config, Ids::binaryPath, getUndoManager()),
  718. recommendedWarningsValue (config, Ids::recommendedWarnings, getUndoManager()),
  719. optimisationLevelValue (config, Ids::optimisation, getUndoManager()),
  720. linkTimeOptimisationValue (config, Ids::linkTimeOptimisation, getUndoManager(), ! isDebug()),
  721. ppDefinesValue (config, Ids::defines, getUndoManager()),
  722. headerSearchPathValue (config, Ids::headerPath, getUndoManager()),
  723. librarySearchPathValue (config, Ids::libraryPath, getUndoManager()),
  724. userNotesValue (config, Ids::userNotes, getUndoManager()),
  725. usePrecompiledHeaderFileValue (config, Ids::usePrecompiledHeaderFile, getUndoManager(), false),
  726. precompiledHeaderFileValue (config, Ids::precompiledHeaderFile, getUndoManager()),
  727. configCompilerFlagsValue (config, Ids::extraCompilerFlags, getUndoManager()),
  728. configLinkerFlagsValue (config, Ids::extraLinkerFlags, getUndoManager())
  729. {
  730. auto& llvmFlags = recommendedCompilerWarningFlags[CompilerNames::llvm] = BuildConfiguration::CompilerWarningFlags::getRecommendedForGCCAndLLVM();
  731. llvmFlags.common.addArray ({ "-Wshorten-64-to-32", "-Wconversion", "-Wint-conversion",
  732. "-Wconditional-uninitialized", "-Wconstant-conversion", "-Wbool-conversion",
  733. "-Wextra-semi", "-Wshift-sign-overflow",
  734. "-Wshadow-all", "-Wnullable-to-nonnull-conversion",
  735. "-Wmissing-prototypes" });
  736. llvmFlags.cpp.addArray ({ "-Wunused-private-field", "-Winconsistent-missing-destructor-override" });
  737. llvmFlags.objc.addArray ({ "-Wunguarded-availability", "-Wunguarded-availability-new" });
  738. auto& gccFlags = recommendedCompilerWarningFlags[CompilerNames::gcc] = BuildConfiguration::CompilerWarningFlags::getRecommendedForGCCAndLLVM();
  739. gccFlags.common.addArray ({ "-Wextra", "-Wsign-compare", "-Wno-implicit-fallthrough", "-Wno-maybe-uninitialized",
  740. "-Wredundant-decls", "-Wno-strict-overflow", "-Wshadow" });
  741. }
  742. String ProjectExporter::BuildConfiguration::getGCCOptimisationFlag() const
  743. {
  744. switch (getOptimisationLevelInt())
  745. {
  746. case gccO0: return "0";
  747. case gccO1: return "1";
  748. case gccO2: return "2";
  749. case gccO3: return "3";
  750. case gccOs: return "s";
  751. case gccOfast: return "fast";
  752. default: break;
  753. }
  754. return "0";
  755. }
  756. void ProjectExporter::BuildConfiguration::addGCCOptimisationProperty (PropertyListBuilder& props)
  757. {
  758. props.add (new ChoicePropertyComponent (optimisationLevelValue, "Optimisation",
  759. { "-O0 (no optimisation)", "-Os (minimise code size)", "-O1 (fast)", "-O2 (faster)",
  760. "-O3 (fastest with safe optimisations)", "-Ofast (uses aggressive optimisations)" },
  761. { gccO0, gccOs, gccO1, gccO2, gccO3, gccOfast }),
  762. "The optimisation level for this configuration");
  763. }
  764. void ProjectExporter::BuildConfiguration::addRecommendedLinuxCompilerWarningsProperty (PropertyListBuilder& props)
  765. {
  766. recommendedWarningsValue.setDefault ("");
  767. props.add (new ChoicePropertyComponent (recommendedWarningsValue, "Add Recommended Compiler Warning Flags",
  768. { CompilerNames::gcc, CompilerNames::llvm, "Disabled" },
  769. { CompilerNames::gcc, CompilerNames::llvm, "" }),
  770. "Enable this to add a set of recommended compiler warning flags.");
  771. }
  772. void ProjectExporter::BuildConfiguration::addRecommendedLLVMCompilerWarningsProperty (PropertyListBuilder& props)
  773. {
  774. recommendedWarningsValue.setDefault ("");
  775. props.add (new ChoicePropertyComponent (recommendedWarningsValue, "Add Recommended Compiler Warning Flags",
  776. { "Enabled", "Disabled" },
  777. { CompilerNames::llvm, "" }),
  778. "Enable this to add a set of recommended compiler warning flags.");
  779. }
  780. ProjectExporter::BuildConfiguration::CompilerWarningFlags ProjectExporter::BuildConfiguration::getRecommendedCompilerWarningFlags() const
  781. {
  782. auto label = recommendedWarningsValue.get().toString();
  783. if (label == "GCC-7")
  784. label = CompilerNames::gcc;
  785. auto it = recommendedCompilerWarningFlags.find (label);
  786. if (it != recommendedCompilerWarningFlags.end())
  787. return it->second;
  788. return {};
  789. }
  790. void ProjectExporter::BuildConfiguration::createPropertyEditors (PropertyListBuilder& props)
  791. {
  792. if (exporter.supportsUserDefinedConfigurations())
  793. props.add (new TextPropertyComponent (configNameValue, "Name", 96, false),
  794. "The name of this configuration.");
  795. props.add (new ChoicePropertyComponent (isDebugValue, "Debug Mode"),
  796. "If enabled, this means that the configuration should be built with debug symbols.");
  797. props.add (new TextPropertyComponent (targetNameValue, "Binary Name", 256, false),
  798. "The filename to use for the destination binary executable file. If you don't add a suffix to this name, "
  799. "a suitable platform-specific suffix will be added automatically.");
  800. props.add (new TextPropertyComponent (targetBinaryPathValue, "Binary Location", 1024, false),
  801. "The folder in which the finished binary should be placed. Leave this blank to cause the binary to be placed "
  802. "in its default location in the build folder.");
  803. props.addSearchPathProperty (headerSearchPathValue, "Header Search Paths", "Extra header search paths.");
  804. props.addSearchPathProperty (librarySearchPathValue, "Extra Library Search Paths", "Extra library search paths.");
  805. props.add (new TextPropertyComponent (ppDefinesValue, "Preprocessor Definitions", 32768, true),
  806. "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace, commas, or "
  807. "new-lines to separate the items - to include a space or comma in a definition, precede it with a backslash.");
  808. props.add (new TextPropertyComponent (configCompilerFlagsValue, "Configuration-specific Compiler Flags", 8192, true),
  809. "Compiler flags that are only to be used in this configuration.");
  810. props.add (new TextPropertyComponent (configLinkerFlagsValue, "Configuration-specific Linker Flags", 8192, true),
  811. "Linker flags that are only to be used in this configuration.");
  812. props.add (new ChoicePropertyComponent (linkTimeOptimisationValue, "Link-Time Optimisation"),
  813. "Enable this to perform link-time code optimisation. This is recommended for release builds.");
  814. if (exporter.supportsPrecompiledHeaders())
  815. {
  816. props.add (new ChoicePropertyComponent (usePrecompiledHeaderFileValue, "Use Precompiled Header"),
  817. "Enable this to turn on precompiled header support for this configuration. Use the setting "
  818. "below to specify the header file to use.");
  819. auto quotedHeaderFileName = (getPrecompiledHeaderFilename() + ".h").quoted();
  820. props.add (new FilePathPropertyComponentWithEnablement (precompiledHeaderFileValue, usePrecompiledHeaderFileValue,
  821. "Precompiled Header File", false, true, "*", project.getProjectFolder()),
  822. "Specify an input header file that will be used to generate a file named " + quotedHeaderFileName + " which is used to generate the "
  823. "PCH file artefact for this exporter configuration. This file can be an absolute path, or relative to the jucer project folder. "
  824. "The " + quotedHeaderFileName + " file will be force included to all source files unless the \"Skip PCH\" setting has been enabled. "
  825. "The generated header will be written on project save and placed in the target folder for this exporter.");
  826. }
  827. createConfigProperties (props);
  828. props.add (new TextPropertyComponent (userNotesValue, "Notes", 32768, true),
  829. "Extra comments: This field is not used for code or project generation, it's just a space where you can express your thoughts.");
  830. }
  831. StringPairArray ProjectExporter::BuildConfiguration::getAllPreprocessorDefs() const
  832. {
  833. return mergePreprocessorDefs (project.getPreprocessorDefs(),
  834. parsePreprocessorDefs (getBuildConfigPreprocessorDefsString()));
  835. }
  836. StringPairArray ProjectExporter::BuildConfiguration::getUniquePreprocessorDefs() const
  837. {
  838. auto perConfigurationDefs = parsePreprocessorDefs (getBuildConfigPreprocessorDefsString());
  839. auto globalDefs = project.getPreprocessorDefs();
  840. for (int i = 0; i < globalDefs.size(); ++i)
  841. {
  842. auto globalKey = globalDefs.getAllKeys()[i];
  843. int idx = perConfigurationDefs.getAllKeys().indexOf (globalKey);
  844. if (idx >= 0)
  845. {
  846. auto globalValue = globalDefs.getAllValues()[i];
  847. if (globalValue == perConfigurationDefs.getAllValues()[idx])
  848. perConfigurationDefs.remove (idx);
  849. }
  850. }
  851. return perConfigurationDefs;
  852. }
  853. StringArray ProjectExporter::BuildConfiguration::getHeaderSearchPaths() const
  854. {
  855. return getSearchPathsFromString (getHeaderSearchPathString() + ';' + project.getHeaderSearchPathsString());
  856. }
  857. StringArray ProjectExporter::BuildConfiguration::getLibrarySearchPaths() const
  858. {
  859. auto separator = exporter.isVisualStudio() ? "\\" : "/";
  860. auto s = getSearchPathsFromString (getLibrarySearchPathString());
  861. for (auto path : exporter.moduleLibSearchPaths)
  862. {
  863. if (exporter.isXcode())
  864. s.add (path);
  865. s.add (path + separator + getModuleLibraryArchName());
  866. }
  867. return s;
  868. }
  869. String ProjectExporter::BuildConfiguration::getPrecompiledHeaderFileContent() const
  870. {
  871. if (shouldUsePrecompiledHeaderFile())
  872. {
  873. auto f = project.getProjectFolder().getChildFile (precompiledHeaderFileValue.get().toString());
  874. if (f.existsAsFile() && f.hasFileExtension (headerFileExtensions))
  875. {
  876. MemoryOutputStream content;
  877. content.setNewLineString (exporter.getNewLineString());
  878. writeAutoGenWarningComment (content);
  879. content << "*/" << newLine << newLine
  880. << "#ifndef " << getSkipPrecompiledHeaderDefine() << newLine << newLine
  881. << f.loadFileAsString() << newLine
  882. << "#endif" << newLine;
  883. return content.toString();
  884. }
  885. }
  886. return {};
  887. }
  888. String ProjectExporter::getExternalLibraryFlags (const BuildConfiguration& config) const
  889. {
  890. auto libraries = StringArray::fromTokens (getExternalLibrariesString(), ";\n", "\"'");
  891. libraries.removeEmptyStrings (true);
  892. if (libraries.size() != 0)
  893. return replacePreprocessorTokens (config, "-l" + libraries.joinIntoString (" -l")).trim();
  894. return {};
  895. }