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.

122 lines
4.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. #include "../Application/jucer_Headers.h"
  14. #include "jucer_ProjectSaver.h"
  15. #include "jucer_ProjectExport_CLion.h"
  16. //==============================================================================
  17. String ProjectSaver::getAudioPluginDefines() const
  18. {
  19. const auto flags = project.getAudioPluginFlags();
  20. if (flags.size() == 0)
  21. return {};
  22. MemoryOutputStream mem;
  23. mem.setNewLineString (projectLineFeed);
  24. mem << "//==============================================================================" << newLine
  25. << "// Audio plugin settings.." << newLine
  26. << newLine;
  27. for (int i = 0; i < flags.size(); ++i)
  28. {
  29. mem << "#ifndef " << flags.getAllKeys()[i] << newLine
  30. << " #define " << flags.getAllKeys()[i].paddedRight (' ', 32) << " "
  31. << flags.getAllValues()[i] << newLine
  32. << "#endif" << newLine;
  33. }
  34. return mem.toString().trim();
  35. }
  36. void ProjectSaver::writeProjects (const OwnedArray<LibraryModule>& modules, const String& specifiedExporterToSave, bool isCommandLineApp)
  37. {
  38. ThreadPool threadPool;
  39. // keep a copy of the basic generated files group, as each exporter may modify it.
  40. auto originalGeneratedGroup = generatedFilesGroup.state.createCopy();
  41. CLionProjectExporter* clionExporter = nullptr;
  42. OwnedArray<ProjectExporter> exporters;
  43. try
  44. {
  45. for (Project::ExporterIterator exp (project); exp.next();)
  46. {
  47. if (specifiedExporterToSave.isNotEmpty() && exp->getName() != specifiedExporterToSave)
  48. continue;
  49. auto exporter = exporters.add (std::move (exp.exporter));
  50. exporter->initialiseDependencyPathValues();
  51. if (exporter->getTargetFolder().createDirectory())
  52. {
  53. if (exporter->isCLion())
  54. {
  55. clionExporter = dynamic_cast<CLionProjectExporter*> (exporter);
  56. }
  57. else
  58. {
  59. exporter->copyMainGroupFromProject();
  60. exporter->settings = exporter->settings.createCopy();
  61. exporter->addToExtraSearchPaths (build_tools::RelativePath ("JuceLibraryCode", build_tools::RelativePath::projectFolder));
  62. generatedFilesGroup.state = originalGeneratedGroup.createCopy();
  63. exporter->addSettingsForProjectType (project.getProjectType());
  64. for (auto& module: modules)
  65. module->addSettingsForModuleToExporter (*exporter, *this);
  66. generatedFilesGroup.sortAlphabetically (true, true);
  67. exporter->getAllGroups().add (generatedFilesGroup);
  68. }
  69. if (isCommandLineApp)
  70. saveExporter (exporter, modules);
  71. else
  72. threadPool.addJob (new ExporterJob (*this, exporter, modules), true);
  73. }
  74. else
  75. {
  76. addError ("Can't create folder: " + exporter->getTargetFolder().getFullPathName());
  77. }
  78. }
  79. }
  80. catch (build_tools::SaveError& saveError)
  81. {
  82. addError (saveError.message);
  83. }
  84. if (! isCommandLineApp)
  85. while (threadPool.getNumJobs() > 0)
  86. Thread::sleep (10);
  87. if (clionExporter != nullptr)
  88. {
  89. for (auto* exporter : exporters)
  90. clionExporter->writeCMakeListsExporterSection (exporter);
  91. std::cout << "Finished saving: " << clionExporter->getName() << std::endl;
  92. }
  93. }