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.

735 lines
27KB

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