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.

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