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.

736 lines
28KB

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