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.

682 lines
26KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #include "jucer_ProjectExporter.h"
  18. #include "jucer_ProjectSaver.h"
  19. #include "jucer_ProjectExport_Make.h"
  20. #include "jucer_ProjectExport_MSVC.h"
  21. #include "jucer_ProjectExport_XCode.h"
  22. #include "jucer_ProjectExport_Android.h"
  23. #include "jucer_ProjectExport_CodeBlocks.h"
  24. //==============================================================================
  25. StringArray ProjectExporter::getExporterNames()
  26. {
  27. StringArray s;
  28. s.add (XCodeProjectExporter::getNameMac());
  29. s.add (XCodeProjectExporter::getNameiOS());
  30. s.add (MSVCProjectExporterVC2005::getName());
  31. s.add (MSVCProjectExporterVC2008::getName());
  32. s.add (MSVCProjectExporterVC2010::getName());
  33. s.add (MSVCProjectExporterVC2012::getName());
  34. s.add (MSVCProjectExporterVC2013::getName());
  35. s.add (MakefileProjectExporter::getNameLinux());
  36. s.add (AndroidProjectExporter::getNameAndroid());
  37. s.add (CodeBlocksProjectExporter::getNameCodeBlocks());
  38. return s;
  39. }
  40. String ProjectExporter::getCurrentPlatformExporterName()
  41. {
  42. #if JUCE_MAC
  43. return XCodeProjectExporter::getNameMac();
  44. #elif JUCE_WINDOWS
  45. return MSVCProjectExporterVC2010::getName();
  46. #elif JUCE_LINUX
  47. return MakefileProjectExporter::getNameLinux();
  48. #else
  49. #error // huh?
  50. #endif
  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 MSVCProjectExporterVC2005 (project, ValueTree (MSVCProjectExporterVC2005::getValueTreeTypeName())); break;
  60. case 3: exp = new MSVCProjectExporterVC2008 (project, ValueTree (MSVCProjectExporterVC2008::getValueTreeTypeName())); break;
  61. case 4: exp = new MSVCProjectExporterVC2010 (project, ValueTree (MSVCProjectExporterVC2010::getValueTreeTypeName())); break;
  62. case 5: exp = new MSVCProjectExporterVC2012 (project, ValueTree (MSVCProjectExporterVC2012::getValueTreeTypeName())); break;
  63. case 6: exp = new MSVCProjectExporterVC2013 (project, ValueTree (MSVCProjectExporterVC2013::getValueTreeTypeName())); break;
  64. case 7: exp = new MakefileProjectExporter (project, ValueTree (MakefileProjectExporter ::getValueTreeTypeName())); break;
  65. case 8: exp = new AndroidProjectExporter (project, ValueTree (AndroidProjectExporter ::getValueTreeTypeName())); break;
  66. case 9: exp = new CodeBlocksProjectExporter (project, ValueTree (CodeBlocksProjectExporter::getValueTreeTypeName())); break;
  67. default: jassertfalse; return 0;
  68. }
  69. exp->createDefaultConfigs();
  70. exp->createDefaultModulePaths();
  71. return exp;
  72. }
  73. ProjectExporter* ProjectExporter::createNewExporter (Project& project, const String& name)
  74. {
  75. return createNewExporter (project, getExporterNames().indexOf (name));
  76. }
  77. ProjectExporter* ProjectExporter::createExporter (Project& project, const ValueTree& settings)
  78. {
  79. ProjectExporter* exp = MSVCProjectExporterVC2005::createForSettings (project, settings);
  80. if (exp == nullptr) exp = MSVCProjectExporterVC2008::createForSettings (project, settings);
  81. if (exp == nullptr) exp = MSVCProjectExporterVC2010::createForSettings (project, settings);
  82. if (exp == nullptr) exp = MSVCProjectExporterVC2012::createForSettings (project, settings);
  83. if (exp == nullptr) exp = MSVCProjectExporterVC2013::createForSettings (project, settings);
  84. if (exp == nullptr) exp = XCodeProjectExporter ::createForSettings (project, settings);
  85. if (exp == nullptr) exp = MakefileProjectExporter ::createForSettings (project, settings);
  86. if (exp == nullptr) exp = AndroidProjectExporter ::createForSettings (project, settings);
  87. if (exp == nullptr) exp = CodeBlocksProjectExporter::createForSettings (project, settings);
  88. jassert (exp != nullptr);
  89. return exp;
  90. }
  91. bool ProjectExporter::canProjectBeLaunched (Project* project)
  92. {
  93. if (project != nullptr)
  94. {
  95. const char* types[] =
  96. {
  97. #if JUCE_MAC
  98. XCodeProjectExporter::getValueTreeTypeName (false),
  99. XCodeProjectExporter::getValueTreeTypeName (true),
  100. #elif JUCE_WINDOWS
  101. MSVCProjectExporterVC2005::getValueTreeTypeName(),
  102. MSVCProjectExporterVC2008::getValueTreeTypeName(),
  103. MSVCProjectExporterVC2010::getValueTreeTypeName(),
  104. MSVCProjectExporterVC2012::getValueTreeTypeName(),
  105. MSVCProjectExporterVC2013::getValueTreeTypeName(),
  106. #elif JUCE_LINUX
  107. // (this doesn't currently launch.. not really sure what it would do on linux)
  108. //MakefileProjectExporter::getValueTreeTypeName(),
  109. #endif
  110. nullptr
  111. };
  112. for (const char** type = types; *type != nullptr; ++type)
  113. if (project->getExporters().getChildWithName (*type).isValid())
  114. return true;
  115. }
  116. return false;
  117. }
  118. //==============================================================================
  119. ProjectExporter::ProjectExporter (Project& p, const ValueTree& settings_)
  120. : xcodeIsBundle (false),
  121. xcodeCreatePList (false),
  122. xcodeCanUseDwarf (true),
  123. makefileIsDLL (false),
  124. msvcIsDLL (false),
  125. msvcIsWindowsSubsystem (true),
  126. settings (settings_),
  127. project (p),
  128. projectType (p.getProjectType()),
  129. projectName (p.getTitle()),
  130. projectFolder (p.getProjectFolder()),
  131. modulesGroup (nullptr)
  132. {
  133. }
  134. ProjectExporter::~ProjectExporter()
  135. {
  136. }
  137. File ProjectExporter::getTargetFolder() const
  138. {
  139. return project.resolveFilename (getTargetLocationString());
  140. }
  141. RelativePath ProjectExporter::rebaseFromProjectFolderToBuildTarget (const RelativePath& path) const
  142. {
  143. return path.rebased (project.getProjectFolder(), getTargetFolder(), RelativePath::buildTargetFolder);
  144. }
  145. bool ProjectExporter::shouldFileBeCompiledByDefault (const RelativePath& file) const
  146. {
  147. return file.hasFileExtension ("cpp;cc;c;cxx");
  148. }
  149. void ProjectExporter::createPropertyEditors (PropertyListBuilder& props)
  150. {
  151. props.add (new TextPropertyComponent (getTargetLocationValue(), "Target Project Folder", 1024, false),
  152. "The location of the folder in which the " + name + " project will be created. "
  153. "This path can be absolute, but it's much more sensible to make it relative to the jucer project directory.");
  154. OwnedArray<LibraryModule> modules;
  155. project.getModules().createRequiredModules (modules);
  156. for (int i = 0; i < modules.size(); ++i)
  157. modules.getUnchecked(i)->createPropertyEditors (*this, props);
  158. props.add (new TextPropertyComponent (getExporterPreprocessorDefs(), "Extra Preprocessor Definitions", 32768, true),
  159. "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace, commas, "
  160. "or new-lines to separate the items - to include a space or comma in a definition, precede it with a backslash.");
  161. props.add (new TextPropertyComponent (getExtraCompilerFlags(), "Extra compiler flags", 2048, true),
  162. "Extra command-line flags to be passed to the compiler. This string can contain references to preprocessor definitions in the "
  163. "form ${NAME_OF_DEFINITION}, which will be replaced with their values.");
  164. props.add (new TextPropertyComponent (getExtraLinkerFlags(), "Extra linker flags", 2048, true),
  165. "Extra command-line flags to be passed to the linker. You might want to use this for adding additional libraries. "
  166. "This string can contain references to preprocessor definitions in the form ${NAME_OF_VALUE}, which will be replaced with their values.");
  167. props.add (new TextPropertyComponent (getExternalLibraries(), "External libraries to link", 2048, true),
  168. "Additional libraries to link (one per line). You should not add any platform specific decoration to these names. "
  169. "This string can contain references to preprocessor definitions in the form ${NAME_OF_VALUE}, which will be replaced with their values.");
  170. {
  171. OwnedArray<Project::Item> images;
  172. project.findAllImageItems (images);
  173. StringArray choices;
  174. Array<var> ids;
  175. choices.add ("<None>");
  176. ids.add (var::null);
  177. choices.add (String::empty);
  178. ids.add (var::null);
  179. for (int i = 0; i < images.size(); ++i)
  180. {
  181. choices.add (images.getUnchecked(i)->getName());
  182. ids.add (images.getUnchecked(i)->getID());
  183. }
  184. props.add (new ChoicePropertyComponent (getSmallIconImageItemID(), "Icon (small)", choices, ids),
  185. "Sets an icon to use for the executable.");
  186. props.add (new ChoicePropertyComponent (getBigIconImageItemID(), "Icon (large)", choices, ids),
  187. "Sets an icon to use for the executable.");
  188. }
  189. createExporterProperties (props);
  190. props.add (new TextPropertyComponent (getUserNotes(), "Notes", 32768, true),
  191. "Extra comments: This field is not used for code or project generation, it's just a space where you can express your thoughts.");
  192. }
  193. StringPairArray ProjectExporter::getAllPreprocessorDefs (const ProjectExporter::BuildConfiguration& config) const
  194. {
  195. StringPairArray defs (mergePreprocessorDefs (config.getAllPreprocessorDefs(),
  196. parsePreprocessorDefs (getExporterPreprocessorDefsString())));
  197. defs.set (getExporterIdentifierMacro(), "1");
  198. return defs;
  199. }
  200. StringPairArray ProjectExporter::getAllPreprocessorDefs() const
  201. {
  202. StringPairArray defs (mergePreprocessorDefs (project.getPreprocessorDefs(),
  203. parsePreprocessorDefs (getExporterPreprocessorDefsString())));
  204. defs.set (getExporterIdentifierMacro(), "1");
  205. return defs;
  206. }
  207. String ProjectExporter::replacePreprocessorTokens (const ProjectExporter::BuildConfiguration& config, const String& sourceString) const
  208. {
  209. return replacePreprocessorDefs (getAllPreprocessorDefs (config), sourceString);
  210. }
  211. void ProjectExporter::copyMainGroupFromProject()
  212. {
  213. jassert (itemGroups.size() == 0);
  214. itemGroups.add (project.getMainGroup().createCopy());
  215. }
  216. Project::Item& ProjectExporter::getModulesGroup()
  217. {
  218. if (modulesGroup == nullptr)
  219. {
  220. jassert (itemGroups.size() > 0); // must call copyMainGroupFromProject before this.
  221. itemGroups.add (Project::Item::createGroup (project, "Juce Modules", "__modulesgroup__"));
  222. modulesGroup = &(itemGroups.getReference (itemGroups.size() - 1));
  223. }
  224. return *modulesGroup;
  225. }
  226. void ProjectExporter::addToExtraSearchPaths (const RelativePath& pathFromProjectFolder)
  227. {
  228. RelativePath localPath (rebaseFromProjectFolderToBuildTarget (pathFromProjectFolder));
  229. const String path (isVisualStudio() ? localPath.toWindowsStyle() : localPath.toUnixStyle());
  230. extraSearchPaths.addIfNotAlreadyThere (path, false);
  231. }
  232. Value ProjectExporter::getPathForModuleValue (const String& moduleID)
  233. {
  234. UndoManager* um = project.getUndoManagerFor (settings);
  235. ValueTree paths (settings.getOrCreateChildWithName (Ids::MODULEPATHS, um));
  236. ValueTree m (paths.getChildWithProperty (Ids::ID, moduleID));
  237. if (! m.isValid())
  238. {
  239. m = ValueTree (Ids::MODULEPATH);
  240. m.setProperty (Ids::ID, moduleID, um);
  241. paths.addChild (m, -1, um);
  242. }
  243. return m.getPropertyAsValue (Ids::path, um);
  244. }
  245. String ProjectExporter::getPathForModuleString (const String& moduleID) const
  246. {
  247. return settings.getChildWithName (Ids::MODULEPATHS)
  248. .getChildWithProperty (Ids::ID, moduleID) [Ids::path].toString();
  249. }
  250. void ProjectExporter::removePathForModule (const String& moduleID)
  251. {
  252. ValueTree paths (settings.getChildWithName (Ids::MODULEPATHS));
  253. ValueTree m (paths.getChildWithProperty (Ids::ID, moduleID));
  254. paths.removeChild (m, project.getUndoManagerFor (settings));
  255. }
  256. RelativePath ProjectExporter::getModuleFolderRelativeToProject (const String& moduleID, ProjectSaver& projectSaver) const
  257. {
  258. if (project.getModules().shouldCopyModuleFilesLocally (moduleID).getValue())
  259. return RelativePath (project.getRelativePathForFile (projectSaver.getLocalModuleFolder (moduleID)),
  260. RelativePath::projectFolder);
  261. String path (getPathForModuleString (moduleID));
  262. if (path.isEmpty())
  263. return getLegacyModulePath (moduleID).getChildFile (moduleID);
  264. return RelativePath (path, RelativePath::projectFolder).getChildFile (moduleID);
  265. }
  266. String ProjectExporter::getLegacyModulePath() const
  267. {
  268. return getSettingString ("juceFolder");
  269. }
  270. RelativePath ProjectExporter::getLegacyModulePath (const String& moduleID) const
  271. {
  272. if (project.getModules().state.getChildWithProperty (Ids::ID, moduleID) ["useLocalCopy"])
  273. return RelativePath (project.getRelativePathForFile (project.getGeneratedCodeFolder()
  274. .getChildFile ("modules")
  275. .getChildFile (moduleID)), RelativePath::projectFolder);
  276. String oldJucePath (getLegacyModulePath());
  277. if (oldJucePath.isEmpty())
  278. return RelativePath();
  279. RelativePath p (oldJucePath, RelativePath::projectFolder);
  280. if (p.getFileName() != "modules")
  281. p = p.getChildFile ("modules");
  282. return p.getChildFile (moduleID);
  283. }
  284. void ProjectExporter::updateOldModulePaths()
  285. {
  286. String oldPath (getLegacyModulePath());
  287. if (oldPath.isNotEmpty())
  288. {
  289. for (int i = project.getModules().getNumModules(); --i >= 0;)
  290. {
  291. String modID (project.getModules().getModuleID(i));
  292. getPathForModuleValue (modID) = getLegacyModulePath (modID).getParentDirectory().toUnixStyle();
  293. }
  294. settings.removeProperty ("juceFolder", nullptr);
  295. }
  296. }
  297. static bool areCompatibleExporters (const ProjectExporter& p1, const ProjectExporter& p2)
  298. {
  299. return (p1.isVisualStudio() && p2.isVisualStudio())
  300. || (p1.isXcode() && p2.isXcode())
  301. || (p1.isLinux() && p2.isLinux())
  302. || (p1.isAndroid() && p2.isAndroid())
  303. || (p1.isCodeBlocks() && p2.isCodeBlocks());
  304. }
  305. void ProjectExporter::createDefaultModulePaths()
  306. {
  307. for (Project::ExporterIterator exporter (project); exporter.next();)
  308. {
  309. if (areCompatibleExporters (*this, *exporter))
  310. {
  311. for (int i = project.getModules().getNumModules(); --i >= 0;)
  312. {
  313. String modID (project.getModules().getModuleID(i));
  314. getPathForModuleValue (modID) = exporter->getPathForModuleValue (modID).getValue();
  315. }
  316. return;
  317. }
  318. }
  319. for (Project::ExporterIterator exporter (project); exporter.next();)
  320. {
  321. if (exporter->canLaunchProject())
  322. {
  323. for (int i = project.getModules().getNumModules(); --i >= 0;)
  324. {
  325. String modID (project.getModules().getModuleID(i));
  326. getPathForModuleValue (modID) = exporter->getPathForModuleValue (modID).getValue();
  327. }
  328. return;
  329. }
  330. }
  331. for (int i = project.getModules().getNumModules(); --i >= 0;)
  332. {
  333. String modID (project.getModules().getModuleID(i));
  334. getPathForModuleValue (modID) = "../../juce";
  335. }
  336. }
  337. //==============================================================================
  338. ValueTree ProjectExporter::getConfigurations() const
  339. {
  340. return settings.getChildWithName (Ids::CONFIGURATIONS);
  341. }
  342. int ProjectExporter::getNumConfigurations() const
  343. {
  344. return getConfigurations().getNumChildren();
  345. }
  346. ProjectExporter::BuildConfiguration::Ptr ProjectExporter::getConfiguration (int index) const
  347. {
  348. return createBuildConfig (getConfigurations().getChild (index));
  349. }
  350. bool ProjectExporter::hasConfigurationNamed (const String& nameToFind) const
  351. {
  352. const ValueTree configs (getConfigurations());
  353. for (int i = configs.getNumChildren(); --i >= 0;)
  354. if (configs.getChild(i) [Ids::name].toString() == nameToFind)
  355. return true;
  356. return false;
  357. }
  358. String ProjectExporter::getUniqueConfigName (String nm) const
  359. {
  360. String nameRoot (nm);
  361. while (CharacterFunctions::isDigit (nameRoot.getLastCharacter()))
  362. nameRoot = nameRoot.dropLastCharacters (1);
  363. nameRoot = nameRoot.trim();
  364. int suffix = 2;
  365. while (hasConfigurationNamed (name))
  366. nm = nameRoot + " " + String (suffix++);
  367. return nm;
  368. }
  369. void ProjectExporter::addNewConfiguration (const BuildConfiguration* configToCopy)
  370. {
  371. const String configName (getUniqueConfigName (configToCopy != nullptr ? configToCopy->config [Ids::name].toString()
  372. : "New Build Configuration"));
  373. ValueTree configs (getConfigurations());
  374. if (! configs.isValid())
  375. {
  376. settings.addChild (ValueTree (Ids::CONFIGURATIONS), 0, project.getUndoManagerFor (settings));
  377. configs = getConfigurations();
  378. }
  379. ValueTree newConfig (Ids::CONFIGURATION);
  380. if (configToCopy != nullptr)
  381. newConfig = configToCopy->config.createCopy();
  382. newConfig.setProperty (Ids::name, configName, 0);
  383. configs.addChild (newConfig, -1, project.getUndoManagerFor (configs));
  384. }
  385. void ProjectExporter::BuildConfiguration::removeFromExporter()
  386. {
  387. ValueTree configs (config.getParent());
  388. configs.removeChild (config, project.getUndoManagerFor (configs));
  389. }
  390. void ProjectExporter::createDefaultConfigs()
  391. {
  392. settings.getOrCreateChildWithName (Ids::CONFIGURATIONS, nullptr);
  393. for (int i = 0; i < 2; ++i)
  394. {
  395. addNewConfiguration (nullptr);
  396. BuildConfiguration::Ptr config (getConfiguration (i));
  397. const bool debugConfig = i == 0;
  398. config->getNameValue() = debugConfig ? "Debug" : "Release";
  399. config->isDebugValue() = debugConfig;
  400. config->getOptimisationLevel() = debugConfig ? optimisationOff : optimiseMinSize;
  401. config->getTargetBinaryName() = project.getProjectFilenameRoot();
  402. }
  403. }
  404. Image ProjectExporter::getBigIcon() const
  405. {
  406. return project.getMainGroup().findItemWithID (settings [Ids::bigIcon]).loadAsImageFile();
  407. }
  408. Image ProjectExporter::getSmallIcon() const
  409. {
  410. return project.getMainGroup().findItemWithID (settings [Ids::smallIcon]).loadAsImageFile();
  411. }
  412. Image ProjectExporter::getBestIconForSize (int size, bool returnNullIfNothingBigEnough) const
  413. {
  414. Image im;
  415. const Image im1 (getSmallIcon());
  416. const Image im2 (getBigIcon());
  417. if (im1.isValid() && im2.isValid())
  418. {
  419. if (im1.getWidth() >= size && im2.getWidth() >= size)
  420. im = im1.getWidth() < im2.getWidth() ? im1 : im2;
  421. else if (im1.getWidth() >= size)
  422. im = im1;
  423. else if (im2.getWidth() >= size)
  424. im = im2;
  425. else
  426. return Image::null;
  427. }
  428. else
  429. {
  430. im = im1.isValid() ? im1 : im2;
  431. }
  432. if (returnNullIfNothingBigEnough && im.getWidth() < size && im.getHeight() < size)
  433. return Image::null;
  434. return rescaleImageForIcon (im, size);
  435. }
  436. Image ProjectExporter::rescaleImageForIcon (Image im, const int size)
  437. {
  438. im = SoftwareImageType().convert (im);
  439. if (size == im.getWidth() && size == im.getHeight())
  440. return im;
  441. // (scale it down in stages for better resampling)
  442. while (im.getWidth() > 2 * size && im.getHeight() > 2 * size)
  443. im = im.rescaled (im.getWidth() / 2,
  444. im.getHeight() / 2);
  445. Image newIm (Image::ARGB, size, size, true, SoftwareImageType());
  446. Graphics g (newIm);
  447. g.drawImageWithin (im, 0, 0, size, size,
  448. RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false);
  449. return newIm;
  450. }
  451. //==============================================================================
  452. ProjectExporter::ConfigIterator::ConfigIterator (ProjectExporter& exporter_)
  453. : index (-1), exporter (exporter_)
  454. {
  455. }
  456. bool ProjectExporter::ConfigIterator::next()
  457. {
  458. if (++index >= exporter.getNumConfigurations())
  459. return false;
  460. config = exporter.getConfiguration (index);
  461. return true;
  462. }
  463. ProjectExporter::ConstConfigIterator::ConstConfigIterator (const ProjectExporter& exporter_)
  464. : index (-1), exporter (exporter_)
  465. {
  466. }
  467. bool ProjectExporter::ConstConfigIterator::next()
  468. {
  469. if (++index >= exporter.getNumConfigurations())
  470. return false;
  471. config = exporter.getConfiguration (index);
  472. return true;
  473. }
  474. //==============================================================================
  475. ProjectExporter::BuildConfiguration::BuildConfiguration (Project& p, const ValueTree& configNode)
  476. : config (configNode), project (p)
  477. {
  478. }
  479. ProjectExporter::BuildConfiguration::~BuildConfiguration()
  480. {
  481. }
  482. String ProjectExporter::BuildConfiguration::getGCCOptimisationFlag() const
  483. {
  484. switch (getOptimisationLevelInt())
  485. {
  486. case optimiseMaxSpeed: return "3";
  487. case optimiseMinSize: return "s";
  488. default: return "0";
  489. }
  490. }
  491. void ProjectExporter::BuildConfiguration::createPropertyEditors (PropertyListBuilder& props)
  492. {
  493. props.add (new TextPropertyComponent (getNameValue(), "Name", 96, false),
  494. "The name of this configuration.");
  495. props.add (new BooleanPropertyComponent (isDebugValue(), "Debug mode", "Debugging enabled"),
  496. "If enabled, this means that the configuration should be built with debug synbols.");
  497. static const char* optimisationLevels[] = { "No optimisation", "Minimise size", "Maximise speed", 0 };
  498. const int optimisationLevelValues[] = { optimisationOff, optimiseMinSize, optimiseMaxSpeed, 0 };
  499. props.add (new ChoicePropertyComponent (getOptimisationLevel(), "Optimisation",
  500. StringArray (optimisationLevels), Array<var> (optimisationLevelValues)),
  501. "The optimisation level for this configuration");
  502. props.add (new TextPropertyComponent (getTargetBinaryName(), "Binary name", 256, false),
  503. "The filename to use for the destination binary executable file. If you don't add a suffix to this name, "
  504. "a suitable platform-specific suffix will be added automatically.");
  505. props.add (new TextPropertyComponent (getTargetBinaryRelativePath(), "Binary location", 1024, false),
  506. "The folder in which the finished binary should be placed. Leave this blank to cause the binary to be placed "
  507. "in its default location in the build folder.");
  508. props.addSearchPathProperty (getHeaderSearchPathValue(), "Header search paths", "Extra header search paths.");
  509. props.addSearchPathProperty (getLibrarySearchPathValue(), "Extra library search paths", "Extra library search paths.");
  510. props.add (new TextPropertyComponent (getBuildConfigPreprocessorDefs(), "Preprocessor definitions", 32768, true),
  511. "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace, commas, or "
  512. "new-lines to separate the items - to include a space or comma in a definition, precede it with a backslash.");
  513. createConfigProperties (props);
  514. props.add (new TextPropertyComponent (getUserNotes(), "Notes", 32768, true),
  515. "Extra comments: This field is not used for code or project generation, it's just a space where you can express your thoughts.");
  516. }
  517. StringPairArray ProjectExporter::BuildConfiguration::getAllPreprocessorDefs() const
  518. {
  519. return mergePreprocessorDefs (project.getPreprocessorDefs(),
  520. parsePreprocessorDefs (getBuildConfigPreprocessorDefsString()));
  521. }
  522. StringArray ProjectExporter::BuildConfiguration::getHeaderSearchPaths() const
  523. {
  524. return getSearchPathsFromString (getHeaderSearchPathString());
  525. }
  526. StringArray ProjectExporter::BuildConfiguration::getLibrarySearchPaths() const
  527. {
  528. return getSearchPathsFromString (getLibrarySearchPathString());
  529. }
  530. String ProjectExporter::BuildConfiguration::getGCCLibraryPathFlags() const
  531. {
  532. String s;
  533. const StringArray libraryPaths (getLibrarySearchPaths());
  534. for (int i = 0; i < libraryPaths.size(); ++i)
  535. s << " -L" << addQuotesIfContainsSpaces (libraryPaths[i]);
  536. return s;
  537. }
  538. String ProjectExporter::getExternalLibraryFlags (const BuildConfiguration& config) const
  539. {
  540. StringArray libraries;
  541. libraries.addTokens (getExternalLibrariesString(), ";\n", "\"'");
  542. libraries.removeEmptyStrings (true);
  543. if (libraries.size() != 0)
  544. return replacePreprocessorTokens (config, "-l" + libraries.joinIntoString (" -l")).trim();
  545. return String::empty;
  546. }