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.

746 lines
28KB

  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. class CodeBlocksProjectExporter : public ProjectExporter
  20. {
  21. public:
  22. enum CodeBlocksOS
  23. {
  24. windowsTarget,
  25. linuxTarget
  26. };
  27. //==============================================================================
  28. static const char* getNameWindows() noexcept { return "Code::Blocks (Windows)"; }
  29. static const char* getNameLinux() noexcept { return "Code::Blocks (Linux)"; }
  30. static const char* getName (CodeBlocksOS os) noexcept
  31. {
  32. if (os == windowsTarget) return getNameWindows();
  33. if (os == linuxTarget) return getNameLinux();
  34. // currently no other OSes supported by Codeblocks exporter!
  35. jassertfalse;
  36. return "Code::Blocks (Unknown OS)";
  37. }
  38. //==============================================================================
  39. static const char* getValueTreeTypeName (CodeBlocksOS os)
  40. {
  41. if (os == windowsTarget) return "CODEBLOCKS_WINDOWS";
  42. if (os == linuxTarget) return "CODEBLOCKS_LINUX";
  43. // currently no other OSes supported by Codeblocks exporter!
  44. jassertfalse;
  45. return "CODEBLOCKS_UNKOWN_OS";
  46. }
  47. //==============================================================================
  48. static String getTargetFolderName (CodeBlocksOS os)
  49. {
  50. if (os == windowsTarget) return "CodeBlocksWindows";
  51. if (os == linuxTarget) return "CodeBlocksLinux";
  52. // currently no other OSes supported by Codeblocks exporter!
  53. jassertfalse;
  54. return "CodeBlocksUnknownOS";
  55. }
  56. //==============================================================================
  57. static CodeBlocksProjectExporter* createForSettings (Project& project, const ValueTree& settings)
  58. {
  59. // this will also import legacy jucer files where CodeBlocks only worked for Windows,
  60. // had valueTreetTypeName "CODEBLOCKS", and there was no OS distinction
  61. if (settings.hasType (getValueTreeTypeName (windowsTarget)) || settings.hasType ("CODEBLOCKS"))
  62. return new CodeBlocksProjectExporter (project, settings, windowsTarget);
  63. if (settings.hasType (getValueTreeTypeName (linuxTarget)))
  64. return new CodeBlocksProjectExporter (project, settings, linuxTarget);
  65. return nullptr;
  66. }
  67. //==============================================================================
  68. CodeBlocksProjectExporter (Project& p, const ValueTree& t, CodeBlocksOS codeBlocksOs)
  69. : ProjectExporter (p, t), os (codeBlocksOs)
  70. {
  71. name = getName (os);
  72. if (getTargetLocationString().isEmpty())
  73. getTargetLocationValue() = getDefaultBuildsRootFolder() + getTargetFolderName (os);
  74. initialiseDependencyPathValues();
  75. }
  76. //==============================================================================
  77. bool canLaunchProject() override { return false; }
  78. bool launchProject() override { return false; }
  79. bool usesMMFiles() const override { return false; }
  80. bool canCopeWithDuplicateFiles() override { return false; }
  81. bool supportsUserDefinedConfigurations() const override { return true; }
  82. bool isXcode() const override { return false; }
  83. bool isVisualStudio() const override { return false; }
  84. bool isCodeBlocks() const override { return true; }
  85. bool isMakefile() const override { return false; }
  86. bool isAndroidStudio() const override { return false; }
  87. bool isAndroid() const override { return false; }
  88. bool isWindows() const override { return os == windowsTarget; }
  89. bool isLinux() const override { return os == linuxTarget; }
  90. bool isOSX() const override { return false; }
  91. bool isiOS() const override { return false; }
  92. bool supportsTargetType (ProjectType::Target::Type type) const override
  93. {
  94. switch (type)
  95. {
  96. case ProjectType::Target::StandalonePlugIn:
  97. case ProjectType::Target::GUIApp:
  98. case ProjectType::Target::ConsoleApp:
  99. case ProjectType::Target::StaticLibrary:
  100. case ProjectType::Target::SharedCodeTarget:
  101. case ProjectType::Target::AggregateTarget:
  102. case ProjectType::Target::VSTPlugIn:
  103. case ProjectType::Target::DynamicLibrary:
  104. return true;
  105. default:
  106. break;
  107. }
  108. return false;
  109. }
  110. void createExporterProperties (PropertyListBuilder&) override
  111. {
  112. }
  113. //==============================================================================
  114. void create (const OwnedArray<LibraryModule>&) const override
  115. {
  116. const File cbpFile (getTargetFolder().getChildFile (project.getProjectFilenameRoot())
  117. .withFileExtension (".cbp"));
  118. XmlElement xml ("CodeBlocks_project_file");
  119. addVersion (xml);
  120. createProject (*xml.createNewChildElement ("Project"));
  121. writeXmlOrThrow (xml, cbpFile, "UTF-8", 10);
  122. }
  123. //==============================================================================
  124. void addPlatformSpecificSettingsForProjectType (const ProjectType&) override
  125. {
  126. // add shared code target first as order matters for Codeblocks
  127. if (shouldBuildTargetType (ProjectType::Target::SharedCodeTarget))
  128. targets.add (new CodeBlocksTarget (*this, ProjectType::Target::SharedCodeTarget));
  129. //ProjectType::Target::SharedCodeTarget
  130. callForAllSupportedTargets ([this] (ProjectType::Target::Type targetType)
  131. {
  132. if (targetType == ProjectType::Target::SharedCodeTarget)
  133. return;
  134. if (auto* target = new CodeBlocksTarget (*this, targetType))
  135. {
  136. if (targetType == ProjectType::Target::AggregateTarget)
  137. targets.insert (0, target);
  138. else
  139. targets.add (target);
  140. }
  141. });
  142. // If you hit this assert, you tried to generate a project for an exporter
  143. // that does not support any of your targets!
  144. jassert (targets.size() > 0);
  145. }
  146. private:
  147. //==============================================================================
  148. class CodeBlocksBuildConfiguration : public BuildConfiguration
  149. {
  150. public:
  151. CodeBlocksBuildConfiguration (Project& p, const ValueTree& settings, const ProjectExporter& e)
  152. : BuildConfiguration (p, settings, e)
  153. {
  154. if (getArchitectureType().toString().isEmpty())
  155. getArchitectureType() = static_cast<const char* const> ("-m64");
  156. }
  157. Value getArchitectureType()
  158. {
  159. const auto archID = exporter.isWindows() ? Ids::windowsCodeBlocksArchitecture
  160. : Ids::linuxCodeBlocksArchitecture;
  161. return getValue (archID);
  162. }
  163. var getArchitectureTypeVar() const
  164. {
  165. const auto archID = exporter.isWindows() ? Ids::windowsCodeBlocksArchitecture
  166. : Ids::linuxCodeBlocksArchitecture;
  167. return config [archID];
  168. }
  169. var getDefaultOptimisationLevel() const override { return var ((int) (isDebug() ? gccO0 : gccO3)); }
  170. void createConfigProperties (PropertyListBuilder& props) override
  171. {
  172. addGCCOptimisationProperty (props);
  173. static const char* const archNames[] = { "32-bit (-m32)", "64-bit (-m64)", "ARM v6", "ARM v7" };
  174. const var archFlags[] = { "-m32", "-m64", "-march=armv6", "-march=armv7" };
  175. props.add (new ChoicePropertyComponent (getArchitectureType(), "Architecture",
  176. StringArray (archNames, numElementsInArray (archNames)),
  177. Array<var> (archFlags, numElementsInArray (archFlags))));
  178. }
  179. String getModuleLibraryArchName() const override
  180. {
  181. const String archFlag = getArchitectureTypeVar();
  182. const auto prefix = String ("-march=");
  183. if (archFlag.startsWith (prefix))
  184. return String ("/") + archFlag.substring (prefix.length());
  185. else if (archFlag == "-m64")
  186. return "/x86_64";
  187. else if (archFlag == "-m32")
  188. return "/i386";
  189. jassertfalse;
  190. return {};
  191. }
  192. };
  193. BuildConfiguration::Ptr createBuildConfig (const ValueTree& tree) const override
  194. {
  195. return new CodeBlocksBuildConfiguration (project, tree, *this);
  196. }
  197. //==============================================================================
  198. class CodeBlocksTarget : public ProjectType::Target
  199. {
  200. public:
  201. CodeBlocksTarget (CodeBlocksProjectExporter&, ProjectType::Target::Type typeToUse)
  202. : ProjectType::Target (typeToUse)
  203. {}
  204. String getTargetNameForConfiguration (const BuildConfiguration& config) const
  205. {
  206. if (type == ProjectType::Target::AggregateTarget)
  207. return config.getName();
  208. return getName() + String (" | ") + config.getName();
  209. }
  210. String getTargetSuffix() const
  211. {
  212. auto fileType = getTargetFileType();
  213. switch (fileType)
  214. {
  215. case executable: return {};
  216. case staticLibrary: return ".a";
  217. case sharedLibraryOrDLL: return ".so";
  218. case pluginBundle:
  219. switch (type)
  220. {
  221. case VST3PlugIn: return ".vst3";
  222. case VSTPlugIn: return ".so";
  223. default: break;
  224. }
  225. return ".so";
  226. default:
  227. break;
  228. }
  229. return {};
  230. }
  231. bool isDynamicLibrary() const
  232. {
  233. return (type == DynamicLibrary || type == VST3PlugIn
  234. || type == VSTPlugIn || type == AAXPlugIn);
  235. }
  236. };
  237. //==============================================================================
  238. void addVersion (XmlElement& xml) const
  239. {
  240. XmlElement* fileVersion = xml.createNewChildElement ("FileVersion");
  241. fileVersion->setAttribute ("major", 1);
  242. fileVersion->setAttribute ("minor", 6);
  243. }
  244. void addOptions (XmlElement& xml) const
  245. {
  246. xml.createNewChildElement ("Option")->setAttribute ("title", project.getTitle());
  247. xml.createNewChildElement ("Option")->setAttribute ("pch_mode", 2);
  248. xml.createNewChildElement ("Option")->setAttribute ("compiler", "gcc");
  249. }
  250. StringArray getDefines (const BuildConfiguration& config, CodeBlocksTarget& target) const
  251. {
  252. StringPairArray defines;
  253. if (isCodeBlocks() && isWindows())
  254. {
  255. defines.set ("__MINGW__", "1");
  256. defines.set ("__MINGW_EXTENSION", String());
  257. }
  258. else
  259. {
  260. defines.set ("LINUX", "1");
  261. }
  262. if (config.isDebug())
  263. {
  264. defines.set ("DEBUG", "1");
  265. defines.set ("_DEBUG", "1");
  266. }
  267. else
  268. {
  269. defines.set ("NDEBUG", "1");
  270. }
  271. defines = mergePreprocessorDefs (defines, getAllPreprocessorDefs (config, target.type));
  272. StringArray defs;
  273. for (int i = 0; i < defines.size(); ++i)
  274. defs.add (defines.getAllKeys()[i] + "=" + defines.getAllValues()[i]);
  275. return getCleanedStringArray (defs);
  276. }
  277. StringArray getCompilerFlags (const BuildConfiguration& config, CodeBlocksTarget& target) const
  278. {
  279. StringArray flags;
  280. if (const auto codeBlocksConfig = dynamic_cast<const CodeBlocksBuildConfiguration*> (&config))
  281. flags.add (codeBlocksConfig->getArchitectureTypeVar());
  282. flags.add ("-O" + config.getGCCOptimisationFlag());
  283. {
  284. auto cppStandard = config.project.getCppStandardValue().toString();
  285. if (cppStandard == "latest")
  286. cppStandard = "1z";
  287. cppStandard = "-std=" + String (shouldUseGNUExtensions() ? "gnu++" : "c++") + cppStandard;
  288. flags.add (cppStandard);
  289. }
  290. flags.add ("-mstackrealign");
  291. if (config.isDebug())
  292. flags.add ("-g");
  293. flags.addTokens (replacePreprocessorTokens (config, getExtraCompilerFlagsString()).trim(),
  294. " \n", "\"'");
  295. {
  296. const StringArray defines (getDefines (config, target));
  297. for (int i = 0; i < defines.size(); ++i)
  298. {
  299. String def (defines[i]);
  300. if (! def.containsChar ('='))
  301. def << '=';
  302. flags.add ("-D" + def);
  303. }
  304. }
  305. if (config.exporter.isLinux())
  306. {
  307. if (target.isDynamicLibrary() || getProject().getProjectType().isAudioPlugin())
  308. flags.add ("-fPIC");
  309. if (linuxPackages.size() > 0)
  310. {
  311. auto pkgconfigFlags = String ("`pkg-config --cflags");
  312. for (auto p : linuxPackages)
  313. pkgconfigFlags << " " << p;
  314. pkgconfigFlags << "`";
  315. flags.add (pkgconfigFlags);
  316. }
  317. if (linuxLibs.contains("pthread"))
  318. flags.add ("-pthread");
  319. }
  320. return getCleanedStringArray (flags);
  321. }
  322. StringArray getLinkerFlags (const BuildConfiguration& config, CodeBlocksTarget& target) const
  323. {
  324. StringArray flags (makefileExtraLinkerFlags);
  325. if (const auto codeBlocksConfig = dynamic_cast<const CodeBlocksBuildConfiguration*> (&config))
  326. flags.add (codeBlocksConfig->getArchitectureTypeVar());
  327. if (! config.isDebug())
  328. flags.add ("-s");
  329. flags.addTokens (replacePreprocessorTokens (config, getExtraLinkerFlagsString()).trim(),
  330. " \n", "\"'");
  331. if (getProject().getProjectType().isAudioPlugin() && target.type != ProjectType::Target::SharedCodeTarget)
  332. flags.add ("-l" + config.getTargetBinaryNameString());
  333. if (config.exporter.isLinux() && linuxPackages.size() > 0)
  334. {
  335. if (target.isDynamicLibrary())
  336. flags.add ("-shared");
  337. auto pkgconfigLibs = String ("`pkg-config --libs");
  338. for (auto p : linuxPackages)
  339. pkgconfigLibs << " " << p;
  340. pkgconfigLibs << "`";
  341. flags.add (pkgconfigLibs);
  342. }
  343. return getCleanedStringArray (flags);
  344. }
  345. StringArray getIncludePaths (const BuildConfiguration& config) const
  346. {
  347. StringArray paths;
  348. paths.add (".");
  349. paths.addArray (extraSearchPaths);
  350. paths.addArray (config.getHeaderSearchPaths());
  351. if (! (isCodeBlocks() && isWindows()))
  352. paths.add ("/usr/include/freetype2");
  353. return getCleanedStringArray (paths);
  354. }
  355. static int getTypeIndex (const ProjectType::Target::Type& type)
  356. {
  357. switch (type)
  358. {
  359. case ProjectType::Target::GUIApp:
  360. case ProjectType::Target::StandalonePlugIn:
  361. return 0;
  362. case ProjectType::Target::ConsoleApp:
  363. return 1;
  364. case ProjectType::Target::StaticLibrary:
  365. case ProjectType::Target::SharedCodeTarget:
  366. return 2;
  367. case ProjectType::Target::DynamicLibrary:
  368. case ProjectType::Target::VSTPlugIn:
  369. case ProjectType::Target::VST3PlugIn:
  370. return 3;
  371. default:
  372. break;
  373. }
  374. return 0;
  375. }
  376. String getOutputPathForTarget (CodeBlocksTarget& target, const BuildConfiguration& config) const
  377. {
  378. String outputPath;
  379. if (config.getTargetBinaryRelativePathString().isNotEmpty())
  380. {
  381. RelativePath binaryPath (config.getTargetBinaryRelativePathString(), RelativePath::projectFolder);
  382. binaryPath = binaryPath.rebased (projectFolder, getTargetFolder(), RelativePath::buildTargetFolder);
  383. outputPath = config.getTargetBinaryRelativePathString();
  384. }
  385. else
  386. {
  387. outputPath ="bin/" + File::createLegalFileName (config.getName().trim());
  388. }
  389. return outputPath + "/" + replacePreprocessorTokens (config, config.getTargetBinaryNameString() + target.getTargetSuffix());
  390. }
  391. String getSharedCodePath (const BuildConfiguration& config) const
  392. {
  393. const String outputPath = getOutputPathForTarget (getTargetWithType (ProjectType::Target::SharedCodeTarget), config);
  394. RelativePath path (outputPath, RelativePath::buildTargetFolder);
  395. const String autoPrefixedFilename = "lib" + path.getFileName();
  396. return path.getParentDirectory().getChildFile (autoPrefixedFilename).toUnixStyle();
  397. }
  398. void createBuildTarget (XmlElement& xml, CodeBlocksTarget& target, const BuildConfiguration& config) const
  399. {
  400. xml.setAttribute ("title", target.getTargetNameForConfiguration (config));
  401. {
  402. XmlElement* output = xml.createNewChildElement ("Option");
  403. output->setAttribute ("output", getOutputPathForTarget (target, config));
  404. const bool keepPrefix = (target.type == ProjectType::Target::VSTPlugIn || target.type == ProjectType::Target::VST3PlugIn
  405. || target.type == ProjectType::Target::AAXPlugIn || target.type == ProjectType::Target::RTASPlugIn);
  406. output->setAttribute ("prefix_auto", keepPrefix ? 0 : 1);
  407. output->setAttribute ("extension_auto", 0);
  408. }
  409. xml.createNewChildElement ("Option")
  410. ->setAttribute ("object_output", "obj/" + File::createLegalFileName (config.getName().trim()));
  411. xml.createNewChildElement ("Option")->setAttribute ("type", getTypeIndex (target.type));
  412. xml.createNewChildElement ("Option")->setAttribute ("compiler", "gcc");
  413. if (getProject().getProjectType().isAudioPlugin() && target.type != ProjectType::Target::SharedCodeTarget)
  414. xml.createNewChildElement ("Option")->setAttribute ("external_deps", getSharedCodePath (config));
  415. {
  416. XmlElement* const compiler = xml.createNewChildElement ("Compiler");
  417. {
  418. const StringArray compilerFlags (getCompilerFlags (config, target));
  419. for (auto flag : compilerFlags)
  420. setAddOption (*compiler, "option", flag);
  421. }
  422. {
  423. const StringArray includePaths (getIncludePaths (config));
  424. for (auto path : includePaths)
  425. setAddOption (*compiler, "directory", path);
  426. }
  427. }
  428. {
  429. XmlElement* const linker = xml.createNewChildElement ("Linker");
  430. const StringArray linkerFlags (getLinkerFlags (config, target));
  431. for (auto flag : linkerFlags)
  432. setAddOption (*linker, "option", flag);
  433. const StringArray& libs = isWindows() ? mingwLibs : linuxLibs;
  434. for (auto lib : libs)
  435. setAddOption (*linker, "library", lib);
  436. StringArray librarySearchPaths (config.getLibrarySearchPaths());
  437. if (getProject().getProjectType().isAudioPlugin() && target.type != ProjectType::Target::SharedCodeTarget)
  438. librarySearchPaths.add (RelativePath (getSharedCodePath (config), RelativePath::buildTargetFolder).getParentDirectory().toUnixStyle());
  439. for (auto path : librarySearchPaths)
  440. {
  441. setAddOption (*linker, "directory", replacePreprocessorDefs (getAllPreprocessorDefs(), path));
  442. }
  443. }
  444. }
  445. void addBuild (XmlElement& xml) const
  446. {
  447. XmlElement* const build = xml.createNewChildElement ("Build");
  448. for (ConstConfigIterator config (*this); config.next();)
  449. {
  450. for (auto target : targets)
  451. if (target->type != ProjectType::Target::AggregateTarget)
  452. createBuildTarget (*build->createNewChildElement ("Target"), *target, *config);
  453. }
  454. }
  455. void addVirtualTargets (XmlElement& xml) const
  456. {
  457. XmlElement* const virtualTargets = xml.createNewChildElement ("VirtualTargets");
  458. for (ConstConfigIterator config (*this); config.next();)
  459. {
  460. StringArray allTargets;
  461. for (auto target : targets)
  462. if (target->type != ProjectType::Target::AggregateTarget)
  463. allTargets.add (target->getTargetNameForConfiguration (*config));
  464. for (auto target : targets)
  465. {
  466. if (target->type == ProjectType::Target::AggregateTarget)
  467. {
  468. auto* configTarget = virtualTargets->createNewChildElement ("Add");
  469. configTarget->setAttribute ("alias", config->getName());
  470. configTarget->setAttribute ("targets", allTargets.joinIntoString (";"));
  471. }
  472. }
  473. }
  474. }
  475. void addProjectCompilerOptions (XmlElement& xml) const
  476. {
  477. XmlElement* const compiler = xml.createNewChildElement ("Compiler");
  478. setAddOption (*compiler, "option", "-Wall");
  479. setAddOption (*compiler, "option", "-Wno-strict-aliasing");
  480. setAddOption (*compiler, "option", "-Wno-strict-overflow");
  481. }
  482. void addProjectLinkerOptions (XmlElement& xml) const
  483. {
  484. XmlElement* const linker = xml.createNewChildElement ("Linker");
  485. StringArray libs;
  486. if (isWindows())
  487. {
  488. static const char* defaultLibs[] = { "gdi32", "user32", "kernel32", "comctl32" };
  489. libs = StringArray (defaultLibs, numElementsInArray (defaultLibs));
  490. }
  491. libs.addTokens (getExternalLibrariesString(), ";\n", "\"'");
  492. libs = getCleanedStringArray (libs);
  493. for (int i = 0; i < libs.size(); ++i)
  494. setAddOption (*linker, "library", replacePreprocessorDefs (getAllPreprocessorDefs(), libs[i]));
  495. }
  496. CodeBlocksTarget& getTargetWithType (ProjectType::Target::Type type) const
  497. {
  498. CodeBlocksTarget* nonAggregrateTarget = nullptr;
  499. for (auto* target : targets)
  500. {
  501. if (target->type == type)
  502. return *target;
  503. if (target->type != ProjectType::Target::AggregateTarget)
  504. nonAggregrateTarget = target;
  505. }
  506. // this project has no valid targets
  507. jassert (nonAggregrateTarget != nullptr);
  508. return *nonAggregrateTarget;
  509. }
  510. // Returns SharedCode target for multi-target projects, otherwise it returns
  511. // the single target
  512. CodeBlocksTarget& getMainTarget() const
  513. {
  514. if (getProject().getProjectType().isAudioPlugin())
  515. return getTargetWithType (ProjectType::Target::SharedCodeTarget);
  516. for (auto* target : targets)
  517. if (target->type != ProjectType::Target::AggregateTarget)
  518. return *target;
  519. jassertfalse;
  520. return *targets[0];
  521. }
  522. CodeBlocksTarget& getTargetForProjectItem (const Project::Item& projectItem) const
  523. {
  524. if (getProject().getProjectType().isAudioPlugin())
  525. {
  526. if (! projectItem.shouldBeCompiled())
  527. return getTargetWithType (ProjectType::Target::SharedCodeTarget);
  528. return getTargetWithType (getProject().getTargetTypeFromFilePath (projectItem.getFile(), true));
  529. }
  530. return getMainTarget();
  531. }
  532. void addCompileUnits (const Project::Item& projectItem, XmlElement& xml) const
  533. {
  534. if (projectItem.isGroup())
  535. {
  536. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  537. addCompileUnits (projectItem.getChild(i), xml);
  538. }
  539. else if (projectItem.shouldBeAddedToTargetProject())
  540. {
  541. const RelativePath file (projectItem.getFile(), getTargetFolder(), RelativePath::buildTargetFolder);
  542. XmlElement* unit = xml.createNewChildElement ("Unit");
  543. unit->setAttribute ("filename", file.toUnixStyle());
  544. for (ConstConfigIterator config (*this); config.next();)
  545. {
  546. const String& targetName = getTargetForProjectItem (projectItem).getTargetNameForConfiguration (*config);
  547. unit->createNewChildElement ("Option")->setAttribute ("target", targetName);
  548. }
  549. if (! projectItem.shouldBeCompiled())
  550. {
  551. unit->createNewChildElement ("Option")->setAttribute ("compile", 0);
  552. unit->createNewChildElement ("Option")->setAttribute ("link", 0);
  553. }
  554. }
  555. }
  556. void addCompileUnits (XmlElement& xml) const
  557. {
  558. for (int i = 0; i < getAllGroups().size(); ++i)
  559. addCompileUnits (getAllGroups().getReference(i), xml);
  560. }
  561. void createProject (XmlElement& xml) const
  562. {
  563. addOptions (xml);
  564. addBuild (xml);
  565. addVirtualTargets (xml);
  566. addProjectCompilerOptions (xml);
  567. addProjectLinkerOptions (xml);
  568. addCompileUnits (xml);
  569. }
  570. void setAddOption (XmlElement& xml, const String& nm, const String& value) const
  571. {
  572. xml.createNewChildElement ("Add")->setAttribute (nm, value);
  573. }
  574. void initialiseDependencyPathValues()
  575. {
  576. DependencyPathOS pathOS = isLinux() ? TargetOS::linux
  577. : TargetOS::windows;
  578. vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder), Ids::vst3Path, pathOS)));
  579. if (! isLinux())
  580. {
  581. aaxPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::aaxFolder), Ids::aaxPath, pathOS)));
  582. rtasPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::rtasFolder), Ids::rtasPath, pathOS)));
  583. }
  584. }
  585. CodeBlocksOS os;
  586. OwnedArray<CodeBlocksTarget> targets;
  587. JUCE_DECLARE_NON_COPYABLE (CodeBlocksProjectExporter)
  588. };