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.

663 lines
25KB

  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. break;
  317. }
  318. }
  319. }
  320. //==============================================================================
  321. ValueTree ProjectExporter::getConfigurations() const
  322. {
  323. return settings.getChildWithName (Ids::CONFIGURATIONS);
  324. }
  325. int ProjectExporter::getNumConfigurations() const
  326. {
  327. return getConfigurations().getNumChildren();
  328. }
  329. ProjectExporter::BuildConfiguration::Ptr ProjectExporter::getConfiguration (int index) const
  330. {
  331. return createBuildConfig (getConfigurations().getChild (index));
  332. }
  333. bool ProjectExporter::hasConfigurationNamed (const String& nameToFind) const
  334. {
  335. const ValueTree configs (getConfigurations());
  336. for (int i = configs.getNumChildren(); --i >= 0;)
  337. if (configs.getChild(i) [Ids::name].toString() == nameToFind)
  338. return true;
  339. return false;
  340. }
  341. String ProjectExporter::getUniqueConfigName (String nm) const
  342. {
  343. String nameRoot (nm);
  344. while (CharacterFunctions::isDigit (nameRoot.getLastCharacter()))
  345. nameRoot = nameRoot.dropLastCharacters (1);
  346. nameRoot = nameRoot.trim();
  347. int suffix = 2;
  348. while (hasConfigurationNamed (name))
  349. nm = nameRoot + " " + String (suffix++);
  350. return nm;
  351. }
  352. void ProjectExporter::addNewConfiguration (const BuildConfiguration* configToCopy)
  353. {
  354. const String configName (getUniqueConfigName (configToCopy != nullptr ? configToCopy->config [Ids::name].toString()
  355. : "New Build Configuration"));
  356. ValueTree configs (getConfigurations());
  357. if (! configs.isValid())
  358. {
  359. settings.addChild (ValueTree (Ids::CONFIGURATIONS), 0, project.getUndoManagerFor (settings));
  360. configs = getConfigurations();
  361. }
  362. ValueTree newConfig (Ids::CONFIGURATION);
  363. if (configToCopy != nullptr)
  364. newConfig = configToCopy->config.createCopy();
  365. newConfig.setProperty (Ids::name, configName, 0);
  366. configs.addChild (newConfig, -1, project.getUndoManagerFor (configs));
  367. }
  368. void ProjectExporter::BuildConfiguration::removeFromExporter()
  369. {
  370. ValueTree configs (config.getParent());
  371. configs.removeChild (config, project.getUndoManagerFor (configs));
  372. }
  373. void ProjectExporter::createDefaultConfigs()
  374. {
  375. settings.getOrCreateChildWithName (Ids::CONFIGURATIONS, nullptr);
  376. for (int i = 0; i < 2; ++i)
  377. {
  378. addNewConfiguration (nullptr);
  379. BuildConfiguration::Ptr config (getConfiguration (i));
  380. const bool debugConfig = i == 0;
  381. config->getNameValue() = debugConfig ? "Debug" : "Release";
  382. config->isDebugValue() = debugConfig;
  383. config->getOptimisationLevel() = debugConfig ? optimisationOff : optimiseMinSize;
  384. config->getTargetBinaryName() = project.getProjectFilenameRoot();
  385. }
  386. }
  387. Image ProjectExporter::getBigIcon() const
  388. {
  389. return project.getMainGroup().findItemWithID (settings [Ids::bigIcon]).loadAsImageFile();
  390. }
  391. Image ProjectExporter::getSmallIcon() const
  392. {
  393. return project.getMainGroup().findItemWithID (settings [Ids::smallIcon]).loadAsImageFile();
  394. }
  395. Image ProjectExporter::getBestIconForSize (int size, bool returnNullIfNothingBigEnough) const
  396. {
  397. Image im;
  398. const Image im1 (getSmallIcon());
  399. const Image im2 (getBigIcon());
  400. if (im1.isValid() && im2.isValid())
  401. {
  402. if (im1.getWidth() >= size && im2.getWidth() >= size)
  403. im = im1.getWidth() < im2.getWidth() ? im1 : im2;
  404. else if (im1.getWidth() >= size)
  405. im = im1;
  406. else if (im2.getWidth() >= size)
  407. im = im2;
  408. else
  409. return Image::null;
  410. }
  411. else
  412. {
  413. im = im1.isValid() ? im1 : im2;
  414. }
  415. if (returnNullIfNothingBigEnough && im.getWidth() < size && im.getHeight() < size)
  416. return Image::null;
  417. return rescaleImageForIcon (im, size);
  418. }
  419. Image ProjectExporter::rescaleImageForIcon (Image im, const int size)
  420. {
  421. im = SoftwareImageType().convert (im);
  422. if (size == im.getWidth() && size == im.getHeight())
  423. return im;
  424. // (scale it down in stages for better resampling)
  425. while (im.getWidth() > 2 * size && im.getHeight() > 2 * size)
  426. im = im.rescaled (im.getWidth() / 2,
  427. im.getHeight() / 2);
  428. Image newIm (Image::ARGB, size, size, true, SoftwareImageType());
  429. Graphics g (newIm);
  430. g.drawImageWithin (im, 0, 0, size, size,
  431. RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false);
  432. return newIm;
  433. }
  434. //==============================================================================
  435. ProjectExporter::ConfigIterator::ConfigIterator (ProjectExporter& exporter_)
  436. : index (-1), exporter (exporter_)
  437. {
  438. }
  439. bool ProjectExporter::ConfigIterator::next()
  440. {
  441. if (++index >= exporter.getNumConfigurations())
  442. return false;
  443. config = exporter.getConfiguration (index);
  444. return true;
  445. }
  446. ProjectExporter::ConstConfigIterator::ConstConfigIterator (const ProjectExporter& exporter_)
  447. : index (-1), exporter (exporter_)
  448. {
  449. }
  450. bool ProjectExporter::ConstConfigIterator::next()
  451. {
  452. if (++index >= exporter.getNumConfigurations())
  453. return false;
  454. config = exporter.getConfiguration (index);
  455. return true;
  456. }
  457. //==============================================================================
  458. ProjectExporter::BuildConfiguration::BuildConfiguration (Project& p, const ValueTree& configNode)
  459. : config (configNode), project (p)
  460. {
  461. }
  462. ProjectExporter::BuildConfiguration::~BuildConfiguration()
  463. {
  464. }
  465. String ProjectExporter::BuildConfiguration::getGCCOptimisationFlag() const
  466. {
  467. switch (getOptimisationLevelInt())
  468. {
  469. case optimiseMaxSpeed: return "3";
  470. case optimiseMinSize: return "s";
  471. default: return "0";
  472. }
  473. }
  474. void ProjectExporter::BuildConfiguration::createPropertyEditors (PropertyListBuilder& props)
  475. {
  476. props.add (new TextPropertyComponent (getNameValue(), "Name", 96, false),
  477. "The name of this configuration.");
  478. props.add (new BooleanPropertyComponent (isDebugValue(), "Debug mode", "Debugging enabled"),
  479. "If enabled, this means that the configuration should be built with debug synbols.");
  480. const char* optimisationLevels[] = { "No optimisation", "Minimise size", "Maximise speed", 0 };
  481. const int optimisationLevelValues[] = { optimisationOff, optimiseMinSize, optimiseMaxSpeed, 0 };
  482. props.add (new ChoicePropertyComponent (getOptimisationLevel(), "Optimisation",
  483. StringArray (optimisationLevels), Array<var> (optimisationLevelValues)),
  484. "The optimisation level for this configuration");
  485. props.add (new TextPropertyComponent (getTargetBinaryName(), "Binary name", 256, false),
  486. "The filename to use for the destination binary executable file. If you don't add a suffix to this name, "
  487. "a suitable platform-specific suffix will be added automatically.");
  488. props.add (new TextPropertyComponent (getTargetBinaryRelativePath(), "Binary location", 1024, false),
  489. "The folder in which the finished binary should be placed. Leave this blank to cause the binary to be placed "
  490. "in its default location in the build folder.");
  491. props.addSearchPathProperty (getHeaderSearchPathValue(), "Header search paths", "Extra header search paths.");
  492. props.addSearchPathProperty (getLibrarySearchPathValue(), "Extra library search paths", "Extra library search paths.");
  493. props.add (new TextPropertyComponent (getBuildConfigPreprocessorDefs(), "Preprocessor definitions", 32768, true),
  494. "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace, commas, or "
  495. "new-lines to separate the items - to include a space or comma in a definition, precede it with a backslash.");
  496. createConfigProperties (props);
  497. props.add (new TextPropertyComponent (getUserNotes(), "Notes", 32768, true),
  498. "Extra comments: This field is not used for code or project generation, it's just a space where you can express your thoughts.");
  499. }
  500. StringPairArray ProjectExporter::BuildConfiguration::getAllPreprocessorDefs() const
  501. {
  502. return mergePreprocessorDefs (project.getPreprocessorDefs(),
  503. parsePreprocessorDefs (getBuildConfigPreprocessorDefsString()));
  504. }
  505. StringArray ProjectExporter::BuildConfiguration::getHeaderSearchPaths() const
  506. {
  507. return getSearchPathsFromString (getHeaderSearchPathString());
  508. }
  509. StringArray ProjectExporter::BuildConfiguration::getLibrarySearchPaths() const
  510. {
  511. return getSearchPathsFromString (getLibrarySearchPathString());
  512. }
  513. String ProjectExporter::BuildConfiguration::getGCCLibraryPathFlags() const
  514. {
  515. String s;
  516. const StringArray libraryPaths (getLibrarySearchPaths());
  517. for (int i = 0; i < libraryPaths.size(); ++i)
  518. s << " -L" << addQuotesIfContainsSpaces (libraryPaths[i]);
  519. return s;
  520. }
  521. String ProjectExporter::getExternalLibraryFlags (const BuildConfiguration& config) const
  522. {
  523. StringArray libraries;
  524. libraries.addTokens (getExternalLibrariesString(), ";\n", "\"'");
  525. libraries.removeEmptyStrings (true);
  526. if (libraries.size() != 0)
  527. return replacePreprocessorTokens (config, "-l" + libraries.joinIntoString (" -l")).trim();
  528. return String::empty;
  529. }