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.

1093 lines
46KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #include "../Application/jucer_Headers.h"
  20. #include "jucer_ProjectExporter.h"
  21. #include "jucer_ProjectSaver.h"
  22. #include "jucer_ProjectExport_Make.h"
  23. #include "jucer_ProjectExport_MSVC.h"
  24. #include "jucer_ProjectExport_Xcode.h"
  25. #include "jucer_ProjectExport_Android.h"
  26. #include "jucer_ProjectExport_CodeBlocks.h"
  27. #include "jucer_ProjectExport_CLion.h"
  28. #include "../Utility/UI/PropertyComponents/jucer_FilePathPropertyComponent.h"
  29. //==============================================================================
  30. static void addType (Array<ProjectExporter::ExporterTypeInfo>& list,
  31. const char* name, const void* iconData, int iconDataSize)
  32. {
  33. ProjectExporter::ExporterTypeInfo type = { name, iconData, iconDataSize };
  34. list.add (type);
  35. }
  36. Array<ProjectExporter::ExporterTypeInfo> ProjectExporter::getExporterTypes()
  37. {
  38. Array<ProjectExporter::ExporterTypeInfo> types;
  39. addType (types, XcodeProjectExporter::getNameMac(), BinaryData::export_xcode_svg, BinaryData::export_xcode_svgSize);
  40. addType (types, XcodeProjectExporter::getNameiOS(), BinaryData::export_xcode_svg, BinaryData::export_xcode_svgSize);
  41. addType (types, MSVCProjectExporterVC2019::getName(), BinaryData::export_visualStudio_svg, BinaryData::export_visualStudio_svgSize);
  42. addType (types, MSVCProjectExporterVC2017::getName(), BinaryData::export_visualStudio_svg, BinaryData::export_visualStudio_svgSize);
  43. addType (types, MSVCProjectExporterVC2015::getName(), BinaryData::export_visualStudio_svg, BinaryData::export_visualStudio_svgSize);
  44. addType (types, MSVCProjectExporterVC2013::getName(), BinaryData::export_visualStudio_svg, BinaryData::export_visualStudio_svgSize);
  45. addType (types, MakefileProjectExporter::getNameLinux(), BinaryData::export_linux_svg, BinaryData::export_linux_svgSize);
  46. addType (types, AndroidProjectExporter::getName(), BinaryData::export_android_svg, BinaryData::export_android_svgSize);
  47. addType (types, CodeBlocksProjectExporter::getNameWindows(), BinaryData::export_codeBlocks_svg, BinaryData::export_codeBlocks_svgSize);
  48. addType (types, CodeBlocksProjectExporter::getNameLinux(), BinaryData::export_codeBlocks_svg, BinaryData::export_codeBlocks_svgSize);
  49. addType (types, CLionProjectExporter::getName(), BinaryData::export_clion_svg, BinaryData::export_clion_svgSize);
  50. return types;
  51. }
  52. ProjectExporter* ProjectExporter::createNewExporter (Project& project, const int index)
  53. {
  54. ProjectExporter* exp = nullptr;
  55. switch (index)
  56. {
  57. case 0: exp = new XcodeProjectExporter (project, ValueTree (XcodeProjectExporter ::getValueTreeTypeName (false)), false); break;
  58. case 1: exp = new XcodeProjectExporter (project, ValueTree (XcodeProjectExporter ::getValueTreeTypeName (true)), true); break;
  59. case 2: exp = new MSVCProjectExporterVC2019 (project, ValueTree (MSVCProjectExporterVC2019 ::getValueTreeTypeName())); break;
  60. case 3: exp = new MSVCProjectExporterVC2017 (project, ValueTree (MSVCProjectExporterVC2017 ::getValueTreeTypeName())); break;
  61. case 4: exp = new MSVCProjectExporterVC2015 (project, ValueTree (MSVCProjectExporterVC2015 ::getValueTreeTypeName())); break;
  62. case 5: exp = new MSVCProjectExporterVC2013 (project, ValueTree (MSVCProjectExporterVC2013 ::getValueTreeTypeName())); break;
  63. case 6: exp = new MakefileProjectExporter (project, ValueTree (MakefileProjectExporter ::getValueTreeTypeName())); break;
  64. case 7: exp = new AndroidProjectExporter (project, ValueTree (AndroidProjectExporter ::getValueTreeTypeName())); break;
  65. case 8: exp = new CodeBlocksProjectExporter (project, ValueTree (CodeBlocksProjectExporter ::getValueTreeTypeName (CodeBlocksProjectExporter::windowsTarget)), CodeBlocksProjectExporter::windowsTarget); break;
  66. case 9: exp = new CodeBlocksProjectExporter (project, ValueTree (CodeBlocksProjectExporter ::getValueTreeTypeName (CodeBlocksProjectExporter::linuxTarget)), CodeBlocksProjectExporter::linuxTarget); break;
  67. case 10: exp = new CLionProjectExporter (project, ValueTree (CLionProjectExporter ::getValueTreeTypeName())); break;
  68. }
  69. exp->createDefaultConfigs();
  70. exp->createDefaultModulePaths();
  71. return exp;
  72. }
  73. StringArray ProjectExporter::getExporterNames()
  74. {
  75. StringArray s;
  76. for (auto& e : getExporterTypes())
  77. s.add (e.name);
  78. return s;
  79. }
  80. StringArray ProjectExporter::getExporterValueTreeNames()
  81. {
  82. StringArray s;
  83. for (auto& n : getExporterNames())
  84. s.add (getValueTreeNameForExporter (n));
  85. return s;
  86. }
  87. String ProjectExporter::getValueTreeNameForExporter (const String& exporterName)
  88. {
  89. if (exporterName == XcodeProjectExporter::getNameMac())
  90. return XcodeProjectExporter::getValueTreeTypeName (false);
  91. if (exporterName == XcodeProjectExporter::getNameiOS())
  92. return XcodeProjectExporter::getValueTreeTypeName (true);
  93. if (exporterName == MSVCProjectExporterVC2019::getName())
  94. return MSVCProjectExporterVC2019::getValueTreeTypeName();
  95. if (exporterName == MSVCProjectExporterVC2017::getName())
  96. return MSVCProjectExporterVC2017::getValueTreeTypeName();
  97. if (exporterName == MSVCProjectExporterVC2015::getName())
  98. return MSVCProjectExporterVC2015::getValueTreeTypeName();
  99. if (exporterName == MSVCProjectExporterVC2013::getName())
  100. return MSVCProjectExporterVC2013::getValueTreeTypeName();
  101. if (exporterName == MakefileProjectExporter::getNameLinux())
  102. return MakefileProjectExporter::getValueTreeTypeName();
  103. if (exporterName == AndroidProjectExporter::getName())
  104. return AndroidProjectExporter::getValueTreeTypeName();
  105. if (exporterName == CodeBlocksProjectExporter::getNameLinux())
  106. return CodeBlocksProjectExporter::getValueTreeTypeName (CodeBlocksProjectExporter::CodeBlocksOS::linuxTarget);
  107. if (exporterName == CodeBlocksProjectExporter::getNameWindows())
  108. return CodeBlocksProjectExporter::getValueTreeTypeName (CodeBlocksProjectExporter::CodeBlocksOS::windowsTarget);
  109. if (exporterName == CLionProjectExporter::getName())
  110. return CLionProjectExporter::getValueTreeTypeName();
  111. return {};
  112. }
  113. String ProjectExporter::getTargetFolderForExporter (const String& exporterValueTreeName)
  114. {
  115. if (exporterValueTreeName == "XCODE_MAC") return "MacOSX";
  116. if (exporterValueTreeName == "XCODE_IPHONE") return "iOS";
  117. if (exporterValueTreeName == "VS2019") return "VisualStudio2019";
  118. if (exporterValueTreeName == "VS2017") return "VisualStudio2017";
  119. if (exporterValueTreeName == "VS2015") return "VisualStudio2015";
  120. if (exporterValueTreeName == "VS2013") return "VisualStudio2013";
  121. if (exporterValueTreeName == "LINUX_MAKE") return "LinuxMakefile";
  122. if (exporterValueTreeName == "ANDROIDSTUDIO") return "Android";
  123. if (exporterValueTreeName == "CODEBLOCKS_WINDOWS") return "CodeBlocksWindows";
  124. if (exporterValueTreeName == "CODEBLOCKS_LINUX") return "CodeBlocksLinux";
  125. if (exporterValueTreeName == "CLION") return "CLion";
  126. return {};
  127. }
  128. StringArray ProjectExporter::getAllDefaultBuildsFolders()
  129. {
  130. StringArray folders;
  131. folders.add (getDefaultBuildsRootFolder() + "iOS");
  132. folders.add (getDefaultBuildsRootFolder() + "MacOSX");
  133. folders.add (getDefaultBuildsRootFolder() + "VisualStudio2019");
  134. folders.add (getDefaultBuildsRootFolder() + "VisualStudio2017");
  135. folders.add (getDefaultBuildsRootFolder() + "VisualStudio2015");
  136. folders.add (getDefaultBuildsRootFolder() + "VisualStudio2013");
  137. folders.add (getDefaultBuildsRootFolder() + "LinuxMakefile");
  138. folders.add (getDefaultBuildsRootFolder() + "CodeBlocksWindows");
  139. folders.add (getDefaultBuildsRootFolder() + "CodeBlocksLinux");
  140. folders.add (getDefaultBuildsRootFolder() + "Android");
  141. folders.add (getDefaultBuildsRootFolder() + "CLion");
  142. return folders;
  143. }
  144. String ProjectExporter::getCurrentPlatformExporterName()
  145. {
  146. #if JUCE_MAC
  147. return XcodeProjectExporter::getNameMac();
  148. #elif JUCE_WINDOWS
  149. return MSVCProjectExporterVC2019::getName();
  150. #elif JUCE_LINUX
  151. return MakefileProjectExporter::getNameLinux();
  152. #else
  153. #error // huh?
  154. #endif
  155. }
  156. ProjectExporter* ProjectExporter::createNewExporter (Project& project, const String& name)
  157. {
  158. return createNewExporter (project, getExporterNames().indexOf (name));
  159. }
  160. ProjectExporter* ProjectExporter::createExporter (Project& project, const ValueTree& settings)
  161. {
  162. ProjectExporter* exp = MSVCProjectExporterVC2019 ::createForSettings (project, settings);
  163. if (exp == nullptr) exp = MSVCProjectExporterVC2017 ::createForSettings (project, settings);
  164. if (exp == nullptr) exp = MSVCProjectExporterVC2015 ::createForSettings (project, settings);
  165. if (exp == nullptr) exp = MSVCProjectExporterVC2013 ::createForSettings (project, settings);
  166. if (exp == nullptr) exp = XcodeProjectExporter ::createForSettings (project, settings);
  167. if (exp == nullptr) exp = MakefileProjectExporter ::createForSettings (project, settings);
  168. if (exp == nullptr) exp = AndroidProjectExporter ::createForSettings (project, settings);
  169. if (exp == nullptr) exp = CodeBlocksProjectExporter ::createForSettings (project, settings);
  170. if (exp == nullptr) exp = CLionProjectExporter ::createForSettings (project, settings);
  171. jassert (exp != nullptr);
  172. return exp;
  173. }
  174. bool ProjectExporter::canProjectBeLaunched (Project* project)
  175. {
  176. if (project != nullptr)
  177. {
  178. const char* types[] =
  179. {
  180. #if JUCE_MAC
  181. XcodeProjectExporter::getValueTreeTypeName (false),
  182. XcodeProjectExporter::getValueTreeTypeName (true),
  183. #elif JUCE_WINDOWS
  184. MSVCProjectExporterVC2019::getValueTreeTypeName(),
  185. MSVCProjectExporterVC2017::getValueTreeTypeName(),
  186. MSVCProjectExporterVC2015::getValueTreeTypeName(),
  187. MSVCProjectExporterVC2013::getValueTreeTypeName(),
  188. #elif JUCE_LINUX
  189. // (this doesn't currently launch.. not really sure what it would do on linux)
  190. //MakefileProjectExporter::getValueTreeTypeName(),
  191. #endif
  192. AndroidProjectExporter::getValueTreeTypeName(),
  193. nullptr
  194. };
  195. for (const char** type = types; *type != nullptr; ++type)
  196. if (project->getExporters().getChildWithName (*type).isValid())
  197. return true;
  198. }
  199. return false;
  200. }
  201. //==============================================================================
  202. ProjectExporter::ProjectExporter (Project& p, const ValueTree& state)
  203. : settings (state),
  204. project (p),
  205. projectType (p.getProjectType()),
  206. projectName (p.getProjectNameString()),
  207. projectFolder (p.getProjectFolder()),
  208. targetLocationValue (settings, Ids::targetFolder, getUndoManager()),
  209. extraCompilerFlagsValue (settings, Ids::extraCompilerFlags, getUndoManager()),
  210. extraLinkerFlagsValue (settings, Ids::extraLinkerFlags, getUndoManager()),
  211. externalLibrariesValue (settings, Ids::externalLibraries, getUndoManager()),
  212. userNotesValue (settings, Ids::userNotes, getUndoManager()),
  213. gnuExtensionsValue (settings, Ids::enableGNUExtensions, getUndoManager()),
  214. bigIconValue (settings, Ids::bigIcon, getUndoManager()),
  215. smallIconValue (settings, Ids::smallIcon, getUndoManager()),
  216. extraPPDefsValue (settings, Ids::extraDefs, getUndoManager())
  217. {
  218. projectCompilerFlagSchemesValue = project.getProjectValue (Ids::compilerFlagSchemes);
  219. projectCompilerFlagSchemesValue.addListener (this);
  220. updateCompilerFlagValues();
  221. }
  222. ProjectExporter::~ProjectExporter()
  223. {
  224. }
  225. void ProjectExporter::updateDeprecatedProjectSettingsInteractively() {}
  226. String ProjectExporter::getName() const
  227. {
  228. if (! getAllDefaultBuildsFolders().contains (getTargetLocationString()))
  229. return name + " - " + getTargetLocationString();
  230. return name;
  231. }
  232. File ProjectExporter::getTargetFolder() const
  233. {
  234. return project.resolveFilename (getTargetLocationString());
  235. }
  236. RelativePath ProjectExporter::rebaseFromProjectFolderToBuildTarget (const RelativePath& path) const
  237. {
  238. return path.rebased (project.getProjectFolder(), getTargetFolder(), RelativePath::buildTargetFolder);
  239. }
  240. bool ProjectExporter::shouldFileBeCompiledByDefault (const File& file) const
  241. {
  242. return file.hasFileExtension (cOrCppFileExtensions)
  243. || file.hasFileExtension (asmFileExtensions);
  244. }
  245. void ProjectExporter::updateCompilerFlagValues()
  246. {
  247. compilerFlagSchemesMap.clear();
  248. for (auto& scheme : project.getCompilerFlagSchemes())
  249. compilerFlagSchemesMap.set (scheme, { settings, scheme, getUndoManager() });
  250. }
  251. //==============================================================================
  252. void ProjectExporter::createPropertyEditors (PropertyListBuilder& props)
  253. {
  254. if (! isCLion())
  255. {
  256. props.add (new TextPropertyComponent (targetLocationValue, "Target Project Folder", 2048, false),
  257. "The location of the folder in which the " + name + " project will be created. "
  258. "This path can be absolute, but it's much more sensible to make it relative to the jucer project directory.");
  259. if ((shouldBuildTargetType (ProjectType::Target::VSTPlugIn) && project.shouldBuildVST()) || project.isVSTPluginHost())
  260. {
  261. props.add (new FilePathPropertyComponent (vstLegacyPathValueWrapper.wrappedValue, "VST (Legacy) SDK Folder", true,
  262. getTargetOSForExporter() == TargetOS::getThisOS(), "*", project.getProjectFolder()),
  263. "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. "
  264. "This can be an absolute path, or a path relative to the Projucer project file.");
  265. }
  266. if ((shouldBuildTargetType (ProjectType::Target::VST3PlugIn) && project.shouldBuildVST3()) || project.isVST3PluginHost())
  267. {
  268. props.add (new FilePathPropertyComponent (vst3PathValueWrapper.wrappedValue, "VST3 SDK Folder", true,
  269. getTargetOSForExporter() == TargetOS::getThisOS(), "*", project.getProjectFolder()),
  270. "If you're building a VST3 plug-in or host, you can use this field to override the global VST3 SDK path with a project-specific path. "
  271. "This can be an absolute path, or a path relative to the Projucer project file.");
  272. }
  273. if (shouldBuildTargetType (ProjectType::Target::AAXPlugIn) && project.shouldBuildAAX())
  274. {
  275. props.add (new FilePathPropertyComponent (aaxPathValueWrapper.wrappedValue, "AAX SDK Folder", true,
  276. getTargetOSForExporter() == TargetOS::getThisOS(), "*", project.getProjectFolder()),
  277. "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.");
  278. }
  279. if (shouldBuildTargetType (ProjectType::Target::RTASPlugIn) && project.shouldBuildRTAS())
  280. {
  281. props.add (new FilePathPropertyComponent (rtasPathValueWrapper.wrappedValue, "RTAS SDK Folder", true,
  282. getTargetOSForExporter() == TargetOS::getThisOS(), "*", project.getProjectFolder()),
  283. "If you're building an RTAS plug-in, this must be the folder containing the RTAS SDK. This can be an absolute path, or a path relative to the Projucer project file.");
  284. }
  285. props.add (new TextPropertyComponent (extraPPDefsValue, "Extra Preprocessor Definitions", 32768, true),
  286. "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace, commas, "
  287. "or new-lines to separate the items - to include a space or comma in a definition, precede it with a backslash.");
  288. props.add (new TextPropertyComponent (extraCompilerFlagsValue, "Extra Compiler Flags", 8192, true),
  289. "Extra command-line flags to be passed to the compiler. This string can contain references to preprocessor definitions in the "
  290. "form ${NAME_OF_DEFINITION}, which will be replaced with their values.");
  291. for (HashMap<String, ValueWithDefault>::Iterator i (compilerFlagSchemesMap); i.next();)
  292. props.add (new TextPropertyComponent (compilerFlagSchemesMap.getReference (i.getKey()), "Compiler Flags for " + i.getKey().quoted(), 8192, false),
  293. "The exporter-specific compiler flags that will be added to files using this scheme.");
  294. props.add (new TextPropertyComponent (extraLinkerFlagsValue, "Extra Linker Flags", 8192, true),
  295. "Extra command-line flags to be passed to the linker. You might want to use this for adding additional libraries. "
  296. "This string can contain references to preprocessor definitions in the form ${NAME_OF_VALUE}, which will be replaced with their values.");
  297. props.add (new TextPropertyComponent (externalLibrariesValue, "External Libraries to Link", 8192, true),
  298. "Additional libraries to link (one per line). You should not add any platform specific decoration to these names. "
  299. "This string can contain references to preprocessor definitions in the form ${NAME_OF_VALUE}, which will be replaced with their values.");
  300. if (! isVisualStudio())
  301. props.add (new ChoicePropertyComponent (gnuExtensionsValue, "GNU Compiler Extensions"),
  302. "Enabling this will use the GNU C++ language standard variant for compilation.");
  303. createIconProperties (props);
  304. }
  305. createExporterProperties (props);
  306. props.add (new TextPropertyComponent (userNotesValue, "Notes", 32768, true),
  307. "Extra comments: This field is not used for code or project generation, it's just a space where you can express your thoughts.");
  308. }
  309. void ProjectExporter::createIconProperties (PropertyListBuilder& props)
  310. {
  311. OwnedArray<Project::Item> images;
  312. project.findAllImageItems (images);
  313. StringArray choices;
  314. Array<var> ids;
  315. choices.add ("<None>");
  316. ids.add (var());
  317. for (int i = 0; i < images.size(); ++i)
  318. {
  319. choices.add (images.getUnchecked(i)->getName());
  320. ids.add (images.getUnchecked(i)->getID());
  321. }
  322. props.add (new ChoicePropertyComponent (smallIconValue, "Icon (Small)", choices, ids),
  323. "Sets an icon to use for the executable.");
  324. props.add (new ChoicePropertyComponent (bigIconValue, "Icon (Large)", choices, ids),
  325. "Sets an icon to use for the executable.");
  326. }
  327. //==============================================================================
  328. void ProjectExporter::addSettingsForProjectType (const ProjectType& type)
  329. {
  330. addVSTPathsIfPluginOrHost();
  331. if (type.isAudioPlugin())
  332. addCommonAudioPluginSettings();
  333. addPlatformSpecificSettingsForProjectType (type);
  334. }
  335. void ProjectExporter::addVSTPathsIfPluginOrHost()
  336. {
  337. if (((shouldBuildTargetType (ProjectType::Target::VSTPlugIn) && project.shouldBuildVST()) || project.isVSTPluginHost())
  338. || ((shouldBuildTargetType (ProjectType::Target::VST3PlugIn) && project.shouldBuildVST3()) || project.isVST3PluginHost()))
  339. {
  340. addLegacyVSTFolderToPathIfSpecified();
  341. addVST3FolderToPath();
  342. }
  343. }
  344. void ProjectExporter::addCommonAudioPluginSettings()
  345. {
  346. if (shouldBuildTargetType (ProjectType::Target::AAXPlugIn))
  347. addAAXFoldersToPath();
  348. // Note: RTAS paths are platform-dependent, impl -> addPlatformSpecificSettingsForProjectType
  349. }
  350. void ProjectExporter::addLegacyVSTFolderToPathIfSpecified()
  351. {
  352. auto vstFolder = getVSTLegacyPathString();
  353. if (vstFolder.isNotEmpty())
  354. addToExtraSearchPaths (RelativePath (vstFolder, RelativePath::projectFolder), 0);
  355. }
  356. RelativePath ProjectExporter::getInternalVST3SDKPath()
  357. {
  358. return getModuleFolderRelativeToProject ("juce_audio_processors")
  359. .getChildFile ("format_types")
  360. .getChildFile ("VST3_SDK");
  361. }
  362. void ProjectExporter::addVST3FolderToPath()
  363. {
  364. auto vst3Folder = getVST3PathString();
  365. if (vst3Folder.isNotEmpty())
  366. addToExtraSearchPaths (RelativePath (vst3Folder, RelativePath::projectFolder), 0);
  367. else
  368. addToExtraSearchPaths (getInternalVST3SDKPath(), 0);
  369. }
  370. void ProjectExporter::addAAXFoldersToPath()
  371. {
  372. auto aaxFolder = getAAXPathString();
  373. if (aaxFolder.isNotEmpty())
  374. {
  375. RelativePath aaxFolderPath (aaxFolder, RelativePath::projectFolder);
  376. addToExtraSearchPaths (aaxFolderPath);
  377. addToExtraSearchPaths (aaxFolderPath.getChildFile ("Interfaces"));
  378. addToExtraSearchPaths (aaxFolderPath.getChildFile ("Interfaces").getChildFile ("ACF"));
  379. }
  380. }
  381. //==============================================================================
  382. StringPairArray ProjectExporter::getAllPreprocessorDefs (const BuildConfiguration& config, const ProjectType::Target::Type targetType) const
  383. {
  384. auto defs = mergePreprocessorDefs (config.getAllPreprocessorDefs(),
  385. parsePreprocessorDefs (getExporterPreprocessorDefsString()));
  386. addDefaultPreprocessorDefs (defs);
  387. addTargetSpecificPreprocessorDefs (defs, targetType);
  388. return defs;
  389. }
  390. StringPairArray ProjectExporter::getAllPreprocessorDefs() const
  391. {
  392. auto defs = mergePreprocessorDefs (project.getPreprocessorDefs(),
  393. parsePreprocessorDefs (getExporterPreprocessorDefsString()));
  394. addDefaultPreprocessorDefs (defs);
  395. return defs;
  396. }
  397. void ProjectExporter::addTargetSpecificPreprocessorDefs (StringPairArray& defs, const ProjectType::Target::Type targetType) const
  398. {
  399. std::pair<String, ProjectType::Target::Type> targetFlags[] = {
  400. {"JucePlugin_Build_VST", ProjectType::Target::VSTPlugIn},
  401. {"JucePlugin_Build_VST3", ProjectType::Target::VST3PlugIn},
  402. {"JucePlugin_Build_AU", ProjectType::Target::AudioUnitPlugIn},
  403. {"JucePlugin_Build_AUv3", ProjectType::Target::AudioUnitv3PlugIn},
  404. {"JucePlugin_Build_RTAS", ProjectType::Target::RTASPlugIn},
  405. {"JucePlugin_Build_AAX", ProjectType::Target::AAXPlugIn},
  406. {"JucePlugin_Build_Standalone", ProjectType::Target::StandalonePlugIn},
  407. {"JucePlugin_Build_Unity", ProjectType::Target::UnityPlugIn}
  408. };
  409. if (targetType == ProjectType::Target::SharedCodeTarget)
  410. {
  411. for (auto& flag : targetFlags)
  412. defs.set (flag.first, (shouldBuildTargetType (flag.second) ? "1" : "0"));
  413. defs.set ("JUCE_SHARED_CODE", "1");
  414. }
  415. else if (targetType != ProjectType::Target::unspecified)
  416. {
  417. for (auto& flag : targetFlags)
  418. defs.set (flag.first, (targetType == flag.second ? "1" : "0"));
  419. }
  420. }
  421. void ProjectExporter::addDefaultPreprocessorDefs (StringPairArray& defs) const
  422. {
  423. defs.set (getExporterIdentifierMacro(), "1");
  424. defs.set ("JUCE_APP_VERSION", project.getVersionString());
  425. defs.set ("JUCE_APP_VERSION_HEX", project.getVersionAsHex());
  426. }
  427. String ProjectExporter::replacePreprocessorTokens (const ProjectExporter::BuildConfiguration& config,
  428. const String& sourceString) const
  429. {
  430. return replacePreprocessorDefs (getAllPreprocessorDefs (config, ProjectType::Target::unspecified), sourceString);
  431. }
  432. void ProjectExporter::copyMainGroupFromProject()
  433. {
  434. jassert (itemGroups.size() == 0);
  435. itemGroups.add (project.getMainGroup().createCopy());
  436. }
  437. Project::Item& ProjectExporter::getModulesGroup()
  438. {
  439. if (modulesGroup == nullptr)
  440. {
  441. jassert (itemGroups.size() > 0); // must call copyMainGroupFromProject before this.
  442. itemGroups.add (Project::Item::createGroup (project, "JUCE Modules", "__modulesgroup__", true));
  443. modulesGroup = &(itemGroups.getReference (itemGroups.size() - 1));
  444. }
  445. return *modulesGroup;
  446. }
  447. void ProjectExporter::addProjectPathToBuildPathList (StringArray& pathList, const RelativePath& pathFromProjectFolder, int index) const
  448. {
  449. auto localPath = RelativePath (rebaseFromProjectFolderToBuildTarget (pathFromProjectFolder));
  450. auto path = isVisualStudio() ? localPath.toWindowsStyle() : localPath.toUnixStyle();
  451. if (! pathList.contains (path))
  452. pathList.insert (index, path);
  453. }
  454. void ProjectExporter::addToModuleLibPaths (const RelativePath& pathFromProjectFolder)
  455. {
  456. addProjectPathToBuildPathList (moduleLibSearchPaths, pathFromProjectFolder);
  457. }
  458. void ProjectExporter::addToExtraSearchPaths (const RelativePath& pathFromProjectFolder, int index)
  459. {
  460. addProjectPathToBuildPathList (extraSearchPaths, pathFromProjectFolder, index);
  461. }
  462. static var getStoredPathForModule (const String& id, const ProjectExporter& exp)
  463. {
  464. return getAppSettings().getStoredPath (isJUCEModule (id) ? Ids::defaultJuceModulePath : Ids::defaultUserModulePath,
  465. exp.getTargetOSForExporter()).get();
  466. }
  467. ValueWithDefault ProjectExporter::getPathForModuleValue (const String& moduleID)
  468. {
  469. auto* um = getUndoManager();
  470. auto paths = settings.getOrCreateChildWithName (Ids::MODULEPATHS, um);
  471. auto m = paths.getChildWithProperty (Ids::ID, moduleID);
  472. if (! m.isValid())
  473. {
  474. m = ValueTree (Ids::MODULEPATH);
  475. m.setProperty (Ids::ID, moduleID, um);
  476. paths.appendChild (m, um);
  477. }
  478. return { m, Ids::path, um, getStoredPathForModule (moduleID, *this) };
  479. }
  480. String ProjectExporter::getPathForModuleString (const String& moduleID) const
  481. {
  482. auto exporterPath = settings.getChildWithName (Ids::MODULEPATHS)
  483. .getChildWithProperty (Ids::ID, moduleID) [Ids::path].toString();
  484. if (exporterPath.isEmpty() || project.getEnabledModules().shouldUseGlobalPath (moduleID))
  485. return getStoredPathForModule (moduleID, *this);
  486. return exporterPath;
  487. }
  488. void ProjectExporter::removePathForModule (const String& moduleID)
  489. {
  490. auto paths = settings.getChildWithName (Ids::MODULEPATHS);
  491. auto m = paths.getChildWithProperty (Ids::ID, moduleID);
  492. paths.removeChild (m, project.getUndoManagerFor (settings));
  493. }
  494. TargetOS::OS ProjectExporter::getTargetOSForExporter() const
  495. {
  496. auto targetOS = TargetOS::unknown;
  497. if (isWindows()) targetOS = TargetOS::windows;
  498. else if (isOSX() || isiOS()) targetOS = TargetOS::osx;
  499. else if (isLinux()) targetOS = TargetOS::linux;
  500. else if (isAndroid() || isCLion()) targetOS = TargetOS::getThisOS();
  501. return targetOS;
  502. }
  503. RelativePath ProjectExporter::getModuleFolderRelativeToProject (const String& moduleID) const
  504. {
  505. if (project.getEnabledModules().shouldCopyModuleFilesLocally (moduleID).getValue())
  506. return RelativePath (project.getRelativePathForFile (project.getLocalModuleFolder (moduleID)),
  507. RelativePath::projectFolder);
  508. auto path = getPathForModuleString (moduleID);
  509. if (path.isEmpty())
  510. return getLegacyModulePath (moduleID).getChildFile (moduleID);
  511. return RelativePath (path, RelativePath::projectFolder).getChildFile (moduleID);
  512. }
  513. String ProjectExporter::getLegacyModulePath() const
  514. {
  515. return getSettingString ("juceFolder");
  516. }
  517. RelativePath ProjectExporter::getLegacyModulePath (const String& moduleID) const
  518. {
  519. if (project.getEnabledModules().state.getChildWithProperty (Ids::ID, moduleID) ["useLocalCopy"])
  520. return RelativePath (project.getRelativePathForFile (project.getGeneratedCodeFolder()
  521. .getChildFile ("modules")
  522. .getChildFile (moduleID)), RelativePath::projectFolder);
  523. auto oldJucePath = getLegacyModulePath();
  524. if (oldJucePath.isEmpty())
  525. return RelativePath();
  526. RelativePath p (oldJucePath, RelativePath::projectFolder);
  527. if (p.getFileName() != "modules")
  528. p = p.getChildFile ("modules");
  529. return p.getChildFile (moduleID);
  530. }
  531. void ProjectExporter::updateOldModulePaths()
  532. {
  533. auto oldPath = getLegacyModulePath();
  534. if (oldPath.isNotEmpty())
  535. {
  536. for (int i = project.getEnabledModules().getNumModules(); --i >= 0;)
  537. {
  538. auto modID = project.getEnabledModules().getModuleID (i);
  539. getPathForModuleValue (modID) = getLegacyModulePath (modID).getParentDirectory().toUnixStyle();
  540. }
  541. settings.removeProperty ("juceFolder", nullptr);
  542. }
  543. }
  544. static bool areCompatibleExporters (const ProjectExporter& p1, const ProjectExporter& p2)
  545. {
  546. return (p1.isVisualStudio() && p2.isVisualStudio())
  547. || (p1.isXcode() && p2.isXcode())
  548. || (p1.isMakefile() && p2.isMakefile())
  549. || (p1.isAndroidStudio() && p2.isAndroidStudio())
  550. || (p1.isCodeBlocks() && p2.isCodeBlocks() && p1.isWindows() != p2.isLinux());
  551. }
  552. void ProjectExporter::createDefaultModulePaths()
  553. {
  554. for (Project::ExporterIterator exporter (project); exporter.next();)
  555. {
  556. if (areCompatibleExporters (*this, *exporter))
  557. {
  558. for (int i = project.getEnabledModules().getNumModules(); --i >= 0;)
  559. {
  560. auto modID = project.getEnabledModules().getModuleID (i);
  561. getPathForModuleValue (modID) = exporter->getPathForModuleValue (modID);
  562. }
  563. return;
  564. }
  565. }
  566. for (Project::ExporterIterator exporter (project); exporter.next();)
  567. {
  568. if (exporter->canLaunchProject())
  569. {
  570. for (int i = project.getEnabledModules().getNumModules(); --i >= 0;)
  571. {
  572. auto modID = project.getEnabledModules().getModuleID (i);
  573. getPathForModuleValue (modID) = exporter->getPathForModuleValue (modID);
  574. }
  575. return;
  576. }
  577. }
  578. for (int i = project.getEnabledModules().getNumModules(); --i >= 0;)
  579. {
  580. auto modID = project.getEnabledModules().getModuleID (i);
  581. getPathForModuleValue (modID) = "../../juce";
  582. }
  583. }
  584. //==============================================================================
  585. ValueTree ProjectExporter::getConfigurations() const
  586. {
  587. return settings.getChildWithName (Ids::CONFIGURATIONS);
  588. }
  589. int ProjectExporter::getNumConfigurations() const
  590. {
  591. return getConfigurations().getNumChildren();
  592. }
  593. ProjectExporter::BuildConfiguration::Ptr ProjectExporter::getConfiguration (int index) const
  594. {
  595. return createBuildConfig (getConfigurations().getChild (index));
  596. }
  597. bool ProjectExporter::hasConfigurationNamed (const String& nameToFind) const
  598. {
  599. auto configs = getConfigurations();
  600. for (int i = configs.getNumChildren(); --i >= 0;)
  601. if (configs.getChild(i) [Ids::name].toString() == nameToFind)
  602. return true;
  603. return false;
  604. }
  605. String ProjectExporter::getUniqueConfigName (String nm) const
  606. {
  607. auto nameRoot = nm;
  608. while (CharacterFunctions::isDigit (nameRoot.getLastCharacter()))
  609. nameRoot = nameRoot.dropLastCharacters (1);
  610. nameRoot = nameRoot.trim();
  611. int suffix = 2;
  612. while (hasConfigurationNamed (name))
  613. nm = nameRoot + " " + String (suffix++);
  614. return nm;
  615. }
  616. void ProjectExporter::addNewConfigurationFromExisting (const BuildConfiguration& configToCopy)
  617. {
  618. auto configs = getConfigurations();
  619. if (! configs.isValid())
  620. {
  621. settings.addChild (ValueTree (Ids::CONFIGURATIONS), 0, project.getUndoManagerFor (settings));
  622. configs = getConfigurations();
  623. }
  624. ValueTree newConfig (Ids::CONFIGURATION);
  625. newConfig = configToCopy.config.createCopy();
  626. newConfig.setProperty (Ids::name, configToCopy.getName(), nullptr);
  627. configs.appendChild (newConfig, project.getUndoManagerFor (configs));
  628. }
  629. void ProjectExporter::addNewConfiguration (bool isDebugConfig)
  630. {
  631. auto configs = getConfigurations();
  632. if (! configs.isValid())
  633. {
  634. settings.addChild (ValueTree (Ids::CONFIGURATIONS), 0, project.getUndoManagerFor (settings));
  635. configs = getConfigurations();
  636. }
  637. ValueTree newConfig (Ids::CONFIGURATION);
  638. newConfig.setProperty (Ids::isDebug, isDebugConfig, project.getUndoManagerFor (settings));
  639. configs.appendChild (newConfig, project.getUndoManagerFor (settings));
  640. }
  641. void ProjectExporter::BuildConfiguration::removeFromExporter()
  642. {
  643. ValueTree configs (config.getParent());
  644. configs.removeChild (config, project.getUndoManagerFor (configs));
  645. }
  646. void ProjectExporter::createDefaultConfigs()
  647. {
  648. settings.getOrCreateChildWithName (Ids::CONFIGURATIONS, nullptr);
  649. for (int i = 0; i < 2; ++i)
  650. {
  651. auto isDebug = i == 0;
  652. addNewConfiguration (isDebug);
  653. BuildConfiguration::Ptr config (getConfiguration (i));
  654. config->getValue (Ids::name) = (isDebug ? "Debug" : "Release");
  655. }
  656. }
  657. std::unique_ptr<Drawable> ProjectExporter::getBigIcon() const
  658. {
  659. return project.getMainGroup().findItemWithID (settings [Ids::bigIcon]).loadAsImageFile();
  660. }
  661. std::unique_ptr<Drawable> ProjectExporter::getSmallIcon() const
  662. {
  663. return project.getMainGroup().findItemWithID (settings [Ids::smallIcon]).loadAsImageFile();
  664. }
  665. Image ProjectExporter::getBestIconForSize (int size, bool returnNullIfNothingBigEnough) const
  666. {
  667. Drawable* im = nullptr;
  668. auto im1 = getSmallIcon();
  669. auto im2 = getBigIcon();
  670. if (im1 != nullptr && im2 != nullptr)
  671. {
  672. if (im1->getWidth() >= size && im2->getWidth() >= size)
  673. im = im1->getWidth() < im2->getWidth() ? im1.get() : im2.get();
  674. else if (im1->getWidth() >= size)
  675. im = im1.get();
  676. else if (im2->getWidth() >= size)
  677. im = im2.get();
  678. }
  679. else
  680. {
  681. im = im1 != nullptr ? im1.get() : im2.get();
  682. }
  683. if (im == nullptr)
  684. return {};
  685. if (returnNullIfNothingBigEnough && im->getWidth() < size && im->getHeight() < size)
  686. return {};
  687. return rescaleImageForIcon (*im, size);
  688. }
  689. Image ProjectExporter::rescaleImageForIcon (Drawable& d, const int size)
  690. {
  691. if (auto* drawableImage = dynamic_cast<DrawableImage*> (&d))
  692. {
  693. auto im = SoftwareImageType().convert (drawableImage->getImage());
  694. if (im.getWidth() == size && im.getHeight() == size)
  695. return im;
  696. // (scale it down in stages for better resampling)
  697. while (im.getWidth() > 2 * size && im.getHeight() > 2 * size)
  698. im = im.rescaled (im.getWidth() / 2,
  699. im.getHeight() / 2);
  700. Image newIm (Image::ARGB, size, size, true, SoftwareImageType());
  701. Graphics g (newIm);
  702. g.drawImageWithin (im, 0, 0, size, size,
  703. RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false);
  704. return newIm;
  705. }
  706. Image im (Image::ARGB, size, size, true, SoftwareImageType());
  707. Graphics g (im);
  708. d.drawWithin (g, im.getBounds().toFloat(), RectanglePlacement::centred, 1.0f);
  709. return im;
  710. }
  711. //==============================================================================
  712. ProjectExporter::ConfigIterator::ConfigIterator (ProjectExporter& e)
  713. : index (-1), exporter (e)
  714. {
  715. }
  716. bool ProjectExporter::ConfigIterator::next()
  717. {
  718. if (++index >= exporter.getNumConfigurations())
  719. return false;
  720. config = exporter.getConfiguration (index);
  721. return true;
  722. }
  723. ProjectExporter::ConstConfigIterator::ConstConfigIterator (const ProjectExporter& exporter_)
  724. : index (-1), exporter (exporter_)
  725. {
  726. }
  727. bool ProjectExporter::ConstConfigIterator::next()
  728. {
  729. if (++index >= exporter.getNumConfigurations())
  730. return false;
  731. config = exporter.getConfiguration (index);
  732. return true;
  733. }
  734. //==============================================================================
  735. ProjectExporter::BuildConfiguration::BuildConfiguration (Project& p, const ValueTree& configNode, const ProjectExporter& e)
  736. : config (configNode), project (p), exporter (e),
  737. isDebugValue (config, Ids::isDebug, getUndoManager(), getValue (Ids::isDebug)),
  738. configNameValue (config, Ids::name, getUndoManager(), "Build Configuration"),
  739. targetNameValue (config, Ids::targetName, getUndoManager(), project.getProjectFilenameRootString()),
  740. targetBinaryPathValue (config, Ids::binaryPath, getUndoManager()),
  741. recommendedWarningsValue (config, Ids::recommendedWarnings, getUndoManager()),
  742. optimisationLevelValue (config, Ids::optimisation, getUndoManager()),
  743. linkTimeOptimisationValue (config, Ids::linkTimeOptimisation, getUndoManager(), ! isDebug()),
  744. ppDefinesValue (config, Ids::defines, getUndoManager()),
  745. headerSearchPathValue (config, Ids::headerPath, getUndoManager()),
  746. librarySearchPathValue (config, Ids::libraryPath, getUndoManager()),
  747. userNotesValue (config, Ids::userNotes, getUndoManager())
  748. {
  749. recommendedCompilerWarningFlags["LLVM"] = { "-Wall", "-Wshadow-all", "-Wshorten-64-to-32", "-Wstrict-aliasing", "-Wuninitialized", "-Wunused-parameter",
  750. "-Wconversion", "-Wsign-compare", "-Wint-conversion", "-Wconditional-uninitialized", "-Woverloaded-virtual",
  751. "-Wreorder", "-Wconstant-conversion", "-Wsign-conversion", "-Wunused-private-field", "-Wbool-conversion",
  752. "-Wextra-semi", "-Wunreachable-code", "-Wzero-as-null-pointer-constant", "-Wcast-align",
  753. "-Winconsistent-missing-destructor-override", "-Wshift-sign-overflow", "-Wnullable-to-nonnull-conversion",
  754. "-Wno-missing-field-initializers", "-Wno-ignored-qualifiers" };
  755. recommendedCompilerWarningFlags["GCC"] = { "-Wall", "-Wextra", "-Wstrict-aliasing", "-Wuninitialized", "-Wunused-parameter", "-Wsign-compare",
  756. "-Woverloaded-virtual", "-Wreorder", "-Wsign-conversion", "-Wunreachable-code",
  757. "-Wzero-as-null-pointer-constant", "-Wcast-align", "-Wno-implicit-fallthrough",
  758. "-Wno-maybe-uninitialized", "-Wno-missing-field-initializers", "-Wno-ignored-qualifiers" };
  759. recommendedCompilerWarningFlags["GCC-7"] = recommendedCompilerWarningFlags["GCC"];
  760. recommendedCompilerWarningFlags["GCC-7"].add ("-Wno-strict-overflow");
  761. }
  762. ProjectExporter::BuildConfiguration::~BuildConfiguration()
  763. {
  764. }
  765. String ProjectExporter::BuildConfiguration::getGCCOptimisationFlag() const
  766. {
  767. switch (getOptimisationLevelInt())
  768. {
  769. case gccO0: return "0";
  770. case gccO1: return "1";
  771. case gccO2: return "2";
  772. case gccO3: return "3";
  773. case gccOs: return "s";
  774. case gccOfast: return "fast";
  775. default: break;
  776. }
  777. return "0";
  778. }
  779. void ProjectExporter::BuildConfiguration::addGCCOptimisationProperty (PropertyListBuilder& props)
  780. {
  781. props.add (new ChoicePropertyComponent (optimisationLevelValue, "Optimisation",
  782. { "-O0 (no optimisation)", "-Os (minimise code size)", "-O1 (fast)", "-O2 (faster)",
  783. "-O3 (fastest with safe optimisations)", "-Ofast (uses aggressive optimisations)" },
  784. { gccO0, gccOs, gccO1, gccO2, gccO3, gccOfast }),
  785. "The optimisation level for this configuration");
  786. }
  787. void ProjectExporter::BuildConfiguration::addRecommendedLinuxCompilerWarningsProperty (PropertyListBuilder& props)
  788. {
  789. props.add (new ChoicePropertyComponent (recommendedWarningsValue, "Add Recommended Compiler Warning Flags",
  790. { "GCC", "GCC 7 and below", "LLVM", "Disabled" },
  791. { "GCC", "GCC-7", "LLVM", "" }),
  792. "Enable this to add a set of recommended compiler warning flags.");
  793. recommendedWarningsValue.setDefault ("");
  794. }
  795. void ProjectExporter::BuildConfiguration::addRecommendedLLVMCompilerWarningsProperty (PropertyListBuilder& props)
  796. {
  797. props.add (new ChoicePropertyComponent (recommendedWarningsValue, "Add Recommended Compiler Warning Flags",
  798. { "Enabled", "Disabled" },
  799. { "LLVM", "" }),
  800. "Enable this to add a set of recommended compiler warning flags.");
  801. recommendedWarningsValue.setDefault ("");
  802. }
  803. StringArray ProjectExporter::BuildConfiguration::getRecommendedCompilerWarningFlags() const
  804. {
  805. auto label = recommendedWarningsValue.get().toString();
  806. auto it = recommendedCompilerWarningFlags.find (label);
  807. if (it != recommendedCompilerWarningFlags.end())
  808. return it->second;
  809. return {};
  810. }
  811. void ProjectExporter::BuildConfiguration::createPropertyEditors (PropertyListBuilder& props)
  812. {
  813. if (exporter.supportsUserDefinedConfigurations())
  814. props.add (new TextPropertyComponent (configNameValue, "Name", 96, false),
  815. "The name of this configuration.");
  816. props.add (new ChoicePropertyComponent (isDebugValue, "Debug Mode"),
  817. "If enabled, this means that the configuration should be built with debug symbols.");
  818. props.add (new TextPropertyComponent (targetNameValue, "Binary Name", 256, false),
  819. "The filename to use for the destination binary executable file. If you don't add a suffix to this name, "
  820. "a suitable platform-specific suffix will be added automatically.");
  821. props.add (new TextPropertyComponent (targetBinaryPathValue, "Binary Location", 1024, false),
  822. "The folder in which the finished binary should be placed. Leave this blank to cause the binary to be placed "
  823. "in its default location in the build folder.");
  824. props.addSearchPathProperty (headerSearchPathValue, "Header Search Paths", "Extra header search paths.");
  825. props.addSearchPathProperty (librarySearchPathValue, "Extra Library Search Paths", "Extra library search paths.");
  826. props.add (new TextPropertyComponent (ppDefinesValue, "Preprocessor Definitions", 32768, true),
  827. "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace, commas, or "
  828. "new-lines to separate the items - to include a space or comma in a definition, precede it with a backslash.");
  829. props.add (new ChoicePropertyComponent (linkTimeOptimisationValue, "Link-Time Optimisation"),
  830. "Enable this to perform link-time code optimisation. This is recommended for release builds.");
  831. createConfigProperties (props);
  832. props.add (new TextPropertyComponent (userNotesValue, "Notes", 32768, true),
  833. "Extra comments: This field is not used for code or project generation, it's just a space where you can express your thoughts.");
  834. }
  835. StringPairArray ProjectExporter::BuildConfiguration::getAllPreprocessorDefs() const
  836. {
  837. return mergePreprocessorDefs (project.getPreprocessorDefs(),
  838. parsePreprocessorDefs (getBuildConfigPreprocessorDefsString()));
  839. }
  840. StringPairArray ProjectExporter::BuildConfiguration::getUniquePreprocessorDefs() const
  841. {
  842. auto perConfigurationDefs = parsePreprocessorDefs (getBuildConfigPreprocessorDefsString());
  843. auto globalDefs = project.getPreprocessorDefs();
  844. for (int i = 0; i < globalDefs.size(); ++i)
  845. {
  846. auto globalKey = globalDefs.getAllKeys()[i];
  847. int idx = perConfigurationDefs.getAllKeys().indexOf (globalKey);
  848. if (idx >= 0)
  849. {
  850. auto globalValue = globalDefs.getAllValues()[i];
  851. if (globalValue == perConfigurationDefs.getAllValues()[idx])
  852. perConfigurationDefs.remove (idx);
  853. }
  854. }
  855. return perConfigurationDefs;
  856. }
  857. StringArray ProjectExporter::BuildConfiguration::getHeaderSearchPaths() const
  858. {
  859. return getSearchPathsFromString (getHeaderSearchPathString() + ';' + project.getHeaderSearchPathsString());
  860. }
  861. StringArray ProjectExporter::BuildConfiguration::getLibrarySearchPaths() const
  862. {
  863. auto separator = exporter.isVisualStudio() ? "\\" : "/";
  864. auto s = getSearchPathsFromString (getLibrarySearchPathString());
  865. for (auto path : exporter.moduleLibSearchPaths)
  866. s.add (path + separator + getModuleLibraryArchName());
  867. return s;
  868. }
  869. String ProjectExporter::getExternalLibraryFlags (const BuildConfiguration& config) const
  870. {
  871. auto libraries = StringArray::fromTokens (getExternalLibrariesString(), ";\n", "\"'");
  872. libraries.removeEmptyStrings (true);
  873. if (libraries.size() != 0)
  874. return replacePreprocessorTokens (config, "-l" + libraries.joinIntoString (" -l")).trim();
  875. return {};
  876. }