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.

733 lines
27KB

  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 {};
  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. auto fileType = getTargetFileType();
  211. switch (fileType)
  212. {
  213. case executable: return {};
  214. case staticLibrary: return ".a";
  215. case sharedLibraryOrDLL: return ".so";
  216. case pluginBundle:
  217. switch (type)
  218. {
  219. case VST3PlugIn: return ".vst3";
  220. case VSTPlugIn: return ".so";
  221. default: break;
  222. }
  223. return ".so";
  224. default:
  225. break;
  226. }
  227. return {};
  228. }
  229. bool isDynamicLibrary() const
  230. {
  231. return (type == DynamicLibrary || type == VST3PlugIn
  232. || type == VSTPlugIn || type == AAXPlugIn);
  233. }
  234. };
  235. //==============================================================================
  236. void addVersion (XmlElement& xml) const
  237. {
  238. XmlElement* fileVersion = xml.createNewChildElement ("FileVersion");
  239. fileVersion->setAttribute ("major", 1);
  240. fileVersion->setAttribute ("minor", 6);
  241. }
  242. void addOptions (XmlElement& xml) const
  243. {
  244. xml.createNewChildElement ("Option")->setAttribute ("title", project.getTitle());
  245. xml.createNewChildElement ("Option")->setAttribute ("pch_mode", 2);
  246. xml.createNewChildElement ("Option")->setAttribute ("compiler", "gcc");
  247. }
  248. StringArray getDefines (const BuildConfiguration& config, CodeBlocksTarget& target) const
  249. {
  250. StringPairArray defines;
  251. if (isCodeBlocks() && isWindows())
  252. {
  253. defines.set ("__MINGW__", "1");
  254. defines.set ("__MINGW_EXTENSION", String());
  255. }
  256. else
  257. {
  258. defines.set ("LINUX", "1");
  259. }
  260. if (config.isDebug())
  261. {
  262. defines.set ("DEBUG", "1");
  263. defines.set ("_DEBUG", "1");
  264. }
  265. else
  266. {
  267. defines.set ("NDEBUG", "1");
  268. }
  269. defines = mergePreprocessorDefs (defines, getAllPreprocessorDefs (config, target.type));
  270. StringArray defs;
  271. for (int i = 0; i < defines.size(); ++i)
  272. defs.add (defines.getAllKeys()[i] + "=" + defines.getAllValues()[i]);
  273. return getCleanedStringArray (defs);
  274. }
  275. StringArray getCompilerFlags (const BuildConfiguration& config, CodeBlocksTarget& target) const
  276. {
  277. StringArray flags;
  278. if (const auto codeBlocksConfig = dynamic_cast<const CodeBlocksBuildConfiguration*> (&config))
  279. flags.add (codeBlocksConfig->getArchitectureTypeVar());
  280. flags.add ("-O" + config.getGCCOptimisationFlag());
  281. flags.add ("-std=c++11");
  282. flags.add ("-mstackrealign");
  283. if (config.isDebug())
  284. flags.add ("-g");
  285. flags.addTokens (replacePreprocessorTokens (config, getExtraCompilerFlagsString()).trim(),
  286. " \n", "\"'");
  287. {
  288. const StringArray defines (getDefines (config, target));
  289. for (int i = 0; i < defines.size(); ++i)
  290. {
  291. String def (defines[i]);
  292. if (! def.containsChar ('='))
  293. def << '=';
  294. flags.add ("-D" + def);
  295. }
  296. }
  297. if (config.exporter.isLinux())
  298. {
  299. if (target.isDynamicLibrary() || getProject().getProjectType().isAudioPlugin())
  300. flags.add ("-fPIC");
  301. if (linuxPackages.size() > 0)
  302. {
  303. auto pkgconfigFlags = String ("`pkg-config --cflags");
  304. for (auto p : linuxPackages)
  305. pkgconfigFlags << " " << p;
  306. pkgconfigFlags << "`";
  307. flags.add (pkgconfigFlags);
  308. }
  309. if (linuxLibs.contains("pthread"))
  310. flags.add ("-pthread");
  311. }
  312. return getCleanedStringArray (flags);
  313. }
  314. StringArray getLinkerFlags (const BuildConfiguration& config, CodeBlocksTarget& target) const
  315. {
  316. StringArray flags (makefileExtraLinkerFlags);
  317. if (const auto codeBlocksConfig = dynamic_cast<const CodeBlocksBuildConfiguration*> (&config))
  318. flags.add (codeBlocksConfig->getArchitectureTypeVar());
  319. if (! config.isDebug())
  320. flags.add ("-s");
  321. flags.addTokens (replacePreprocessorTokens (config, getExtraLinkerFlagsString()).trim(),
  322. " \n", "\"'");
  323. if (getProject().getProjectType().isAudioPlugin() && target.type != ProjectType::Target::SharedCodeTarget)
  324. flags.add ("-l" + config.getTargetBinaryNameString());
  325. if (config.exporter.isLinux() && linuxPackages.size() > 0)
  326. {
  327. if (target.isDynamicLibrary())
  328. flags.add ("-shared");
  329. auto pkgconfigLibs = String ("`pkg-config --libs");
  330. for (auto p : linuxPackages)
  331. pkgconfigLibs << " " << p;
  332. pkgconfigLibs << "`";
  333. flags.add (pkgconfigLibs);
  334. }
  335. return getCleanedStringArray (flags);
  336. }
  337. StringArray getIncludePaths (const BuildConfiguration& config) const
  338. {
  339. StringArray paths;
  340. paths.add (".");
  341. paths.addArray (extraSearchPaths);
  342. paths.addArray (config.getHeaderSearchPaths());
  343. if (! (isCodeBlocks() && isWindows()))
  344. paths.add ("/usr/include/freetype2");
  345. return getCleanedStringArray (paths);
  346. }
  347. static int getTypeIndex (const ProjectType::Target::Type& type)
  348. {
  349. switch (type)
  350. {
  351. case ProjectType::Target::GUIApp:
  352. case ProjectType::Target::StandalonePlugIn:
  353. return 0;
  354. case ProjectType::Target::ConsoleApp:
  355. return 1;
  356. case ProjectType::Target::StaticLibrary:
  357. case ProjectType::Target::SharedCodeTarget:
  358. return 2;
  359. case ProjectType::Target::DynamicLibrary:
  360. case ProjectType::Target::VSTPlugIn:
  361. case ProjectType::Target::VST3PlugIn:
  362. return 3;
  363. default:
  364. break;
  365. }
  366. return 0;
  367. }
  368. String getOutputPathForTarget (CodeBlocksTarget& target, const BuildConfiguration& config) const
  369. {
  370. String outputPath;
  371. if (config.getTargetBinaryRelativePathString().isNotEmpty())
  372. {
  373. RelativePath binaryPath (config.getTargetBinaryRelativePathString(), RelativePath::projectFolder);
  374. binaryPath = binaryPath.rebased (projectFolder, getTargetFolder(), RelativePath::buildTargetFolder);
  375. outputPath = config.getTargetBinaryRelativePathString();
  376. }
  377. else
  378. {
  379. outputPath ="bin/" + File::createLegalFileName (config.getName().trim());
  380. }
  381. return outputPath + "/" + replacePreprocessorTokens (config, config.getTargetBinaryNameString() + target.getTargetSuffix());
  382. }
  383. String getSharedCodePath (const BuildConfiguration& config) const
  384. {
  385. const String outputPath = getOutputPathForTarget (getTargetWithType (ProjectType::Target::SharedCodeTarget), config);
  386. RelativePath path (outputPath, RelativePath::buildTargetFolder);
  387. const String autoPrefixedFilename = "lib" + path.getFileName();
  388. return path.getParentDirectory().getChildFile (autoPrefixedFilename).toUnixStyle();
  389. }
  390. void createBuildTarget (XmlElement& xml, CodeBlocksTarget& target, const BuildConfiguration& config) const
  391. {
  392. xml.setAttribute ("title", target.getTargetNameForConfiguration (config));
  393. {
  394. XmlElement* output = xml.createNewChildElement ("Option");
  395. output->setAttribute ("output", getOutputPathForTarget (target, config));
  396. const bool keepPrefix = (target.type == ProjectType::Target::VSTPlugIn || target.type == ProjectType::Target::VST3PlugIn
  397. || target.type == ProjectType::Target::AAXPlugIn || target.type == ProjectType::Target::RTASPlugIn);
  398. output->setAttribute ("prefix_auto", keepPrefix ? 0 : 1);
  399. output->setAttribute ("extension_auto", 0);
  400. }
  401. xml.createNewChildElement ("Option")
  402. ->setAttribute ("object_output", "obj/" + File::createLegalFileName (config.getName().trim()));
  403. xml.createNewChildElement ("Option")->setAttribute ("type", getTypeIndex (target.type));
  404. xml.createNewChildElement ("Option")->setAttribute ("compiler", "gcc");
  405. if (getProject().getProjectType().isAudioPlugin() && target.type != ProjectType::Target::SharedCodeTarget)
  406. xml.createNewChildElement ("Option")->setAttribute ("external_deps", getSharedCodePath (config));
  407. {
  408. XmlElement* const compiler = xml.createNewChildElement ("Compiler");
  409. {
  410. const StringArray compilerFlags (getCompilerFlags (config, target));
  411. for (auto flag : compilerFlags)
  412. setAddOption (*compiler, "option", flag);
  413. }
  414. {
  415. const StringArray includePaths (getIncludePaths (config));
  416. for (auto path : includePaths)
  417. setAddOption (*compiler, "directory", path);
  418. }
  419. }
  420. {
  421. XmlElement* const linker = xml.createNewChildElement ("Linker");
  422. const StringArray linkerFlags (getLinkerFlags (config, target));
  423. for (auto flag : linkerFlags)
  424. setAddOption (*linker, "option", flag);
  425. const StringArray& libs = isWindows() ? mingwLibs : linuxLibs;
  426. for (auto lib : libs)
  427. setAddOption (*linker, "library", lib);
  428. StringArray librarySearchPaths (config.getLibrarySearchPaths());
  429. if (getProject().getProjectType().isAudioPlugin() && target.type != ProjectType::Target::SharedCodeTarget)
  430. librarySearchPaths.add (RelativePath (getSharedCodePath (config), RelativePath::buildTargetFolder).getParentDirectory().toUnixStyle());
  431. for (auto path : librarySearchPaths)
  432. {
  433. setAddOption (*linker, "directory", replacePreprocessorDefs (getAllPreprocessorDefs(), path));
  434. }
  435. }
  436. }
  437. void addBuild (XmlElement& xml) const
  438. {
  439. XmlElement* const build = xml.createNewChildElement ("Build");
  440. for (ConstConfigIterator config (*this); config.next();)
  441. {
  442. for (auto target : targets)
  443. if (target->type != ProjectType::Target::AggregateTarget)
  444. createBuildTarget (*build->createNewChildElement ("Target"), *target, *config);
  445. }
  446. }
  447. void addVirtualTargets (XmlElement& xml) const
  448. {
  449. XmlElement* const virtualTargets = xml.createNewChildElement ("VirtualTargets");
  450. for (ConstConfigIterator config (*this); config.next();)
  451. {
  452. StringArray allTargets;
  453. for (auto target : targets)
  454. if (target->type != ProjectType::Target::AggregateTarget)
  455. allTargets.add (target->getTargetNameForConfiguration (*config));
  456. for (auto target : targets)
  457. {
  458. if (target->type == ProjectType::Target::AggregateTarget)
  459. {
  460. auto* configTarget = virtualTargets->createNewChildElement ("Add");
  461. configTarget->setAttribute ("alias", config->getName());
  462. configTarget->setAttribute ("targets", allTargets.joinIntoString (";"));
  463. }
  464. }
  465. }
  466. }
  467. void addProjectCompilerOptions (XmlElement& xml) const
  468. {
  469. XmlElement* const compiler = xml.createNewChildElement ("Compiler");
  470. setAddOption (*compiler, "option", "-Wall");
  471. setAddOption (*compiler, "option", "-Wno-strict-aliasing");
  472. setAddOption (*compiler, "option", "-Wno-strict-overflow");
  473. }
  474. void addProjectLinkerOptions (XmlElement& xml) const
  475. {
  476. XmlElement* const linker = xml.createNewChildElement ("Linker");
  477. StringArray libs;
  478. if (isWindows())
  479. {
  480. static const char* defaultLibs[] = { "gdi32", "user32", "kernel32", "comctl32" };
  481. libs = StringArray (defaultLibs, numElementsInArray (defaultLibs));
  482. }
  483. libs.addTokens (getExternalLibrariesString(), ";\n", "\"'");
  484. libs = getCleanedStringArray (libs);
  485. for (int i = 0; i < libs.size(); ++i)
  486. setAddOption (*linker, "library", replacePreprocessorDefs (getAllPreprocessorDefs(), libs[i]));
  487. }
  488. CodeBlocksTarget& getTargetWithType (ProjectType::Target::Type type) const
  489. {
  490. CodeBlocksTarget* nonAggregrateTarget = nullptr;
  491. for (auto* target : targets)
  492. {
  493. if (target->type == type)
  494. return *target;
  495. if (target->type != ProjectType::Target::AggregateTarget)
  496. nonAggregrateTarget = target;
  497. }
  498. // this project has no valid targets
  499. jassert (nonAggregrateTarget != nullptr);
  500. return *nonAggregrateTarget;
  501. }
  502. // Returns SharedCode target for multi-target projects, otherwise it returns
  503. // the single target
  504. CodeBlocksTarget& getMainTarget() const
  505. {
  506. if (getProject().getProjectType().isAudioPlugin())
  507. return getTargetWithType (ProjectType::Target::SharedCodeTarget);
  508. for (auto* target : targets)
  509. if (target->type != ProjectType::Target::AggregateTarget)
  510. return *target;
  511. jassertfalse;
  512. return *targets[0];
  513. }
  514. CodeBlocksTarget& getTargetForProjectItem (const Project::Item& projectItem) const
  515. {
  516. if (getProject().getProjectType().isAudioPlugin())
  517. {
  518. if (! projectItem.shouldBeCompiled())
  519. return getTargetWithType (ProjectType::Target::SharedCodeTarget);
  520. return getTargetWithType (getProject().getTargetTypeFromFilePath (projectItem.getFile(), true));
  521. }
  522. return getMainTarget();
  523. }
  524. void addCompileUnits (const Project::Item& projectItem, XmlElement& xml) const
  525. {
  526. if (projectItem.isGroup())
  527. {
  528. for (int i = 0; i < projectItem.getNumChildren(); ++i)
  529. addCompileUnits (projectItem.getChild(i), xml);
  530. }
  531. else if (projectItem.shouldBeAddedToTargetProject())
  532. {
  533. const RelativePath file (projectItem.getFile(), getTargetFolder(), RelativePath::buildTargetFolder);
  534. XmlElement* unit = xml.createNewChildElement ("Unit");
  535. unit->setAttribute ("filename", file.toUnixStyle());
  536. for (ConstConfigIterator config (*this); config.next();)
  537. {
  538. const String& targetName = getTargetForProjectItem (projectItem).getTargetNameForConfiguration (*config);
  539. unit->createNewChildElement ("Option")->setAttribute ("target", targetName);
  540. }
  541. if (! projectItem.shouldBeCompiled())
  542. {
  543. unit->createNewChildElement ("Option")->setAttribute ("compile", 0);
  544. unit->createNewChildElement ("Option")->setAttribute ("link", 0);
  545. }
  546. }
  547. }
  548. void addCompileUnits (XmlElement& xml) const
  549. {
  550. for (int i = 0; i < getAllGroups().size(); ++i)
  551. addCompileUnits (getAllGroups().getReference(i), xml);
  552. }
  553. void createProject (XmlElement& xml) const
  554. {
  555. addOptions (xml);
  556. addBuild (xml);
  557. addVirtualTargets (xml);
  558. addProjectCompilerOptions (xml);
  559. addProjectLinkerOptions (xml);
  560. addCompileUnits (xml);
  561. }
  562. void setAddOption (XmlElement& xml, const String& nm, const String& value) const
  563. {
  564. xml.createNewChildElement ("Add")->setAttribute (nm, value);
  565. }
  566. void initialiseDependencyPathValues()
  567. {
  568. DependencyPathOS pathOS = isLinux() ? TargetOS::linux
  569. : TargetOS::windows;
  570. vst3Path.referTo (Value (new DependencyPathValueSource (getSetting (Ids::vst3Folder), Ids::vst3Path, pathOS)));
  571. if (! isLinux())
  572. {
  573. aaxPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::aaxFolder), Ids::aaxPath, pathOS)));
  574. rtasPath.referTo (Value (new DependencyPathValueSource (getSetting (Ids::rtasFolder), Ids::rtasPath, pathOS)));
  575. }
  576. }
  577. CodeBlocksOS os;
  578. OwnedArray<CodeBlocksTarget> targets;
  579. JUCE_DECLARE_NON_COPYABLE (CodeBlocksProjectExporter)
  580. };