cmGlobalGhsMultiGenerator.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include <iosfwd>
  5. #include <memory>
  6. #include <set>
  7. #include <string>
  8. #include <utility>
  9. #include <vector>
  10. #include "cmBuildOptions.h"
  11. #include "cmGlobalGenerator.h"
  12. #include "cmGlobalGeneratorFactory.h"
  13. #include "cmTargetDepend.h"
  14. class cmGeneratorTarget;
  15. class cmLocalGenerator;
  16. class cmMakefile;
  17. class cmake;
  18. class cmGlobalGhsMultiGenerator : public cmGlobalGenerator
  19. {
  20. public:
  21. // The default filename extension of GHS MULTI's build files.
  22. static const char* FILE_EXTENSION;
  23. cmGlobalGhsMultiGenerator(cmake* cm);
  24. ~cmGlobalGhsMultiGenerator() override;
  25. static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory()
  26. {
  27. return std::unique_ptr<cmGlobalGeneratorFactory>(
  28. new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>());
  29. }
  30. //! create the correct local generator
  31. std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
  32. cmMakefile* mf) override;
  33. /// @return the name of this generator.
  34. static std::string GetActualName() { return "Green Hills MULTI"; }
  35. //! Get the name for this generator
  36. std::string GetName() const override { return GetActualName(); }
  37. /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
  38. static cmDocumentationEntry GetDocumentation();
  39. /**
  40. * Utilized by the generator factory to determine if this generator
  41. * supports toolsets.
  42. */
  43. static bool SupportsToolset() { return true; }
  44. /**
  45. * Utilized by the generator factory to determine if this generator
  46. * supports platforms.
  47. */
  48. static bool SupportsPlatform() { return true; }
  49. // Toolset / Platform Support
  50. bool SetGeneratorToolset(std::string const& ts, bool build,
  51. cmMakefile* mf) override;
  52. bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
  53. /**
  54. * Try to determine system information such as shared library
  55. * extension, pthreads, byte order etc.
  56. */
  57. void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
  58. bool optional) override;
  59. /*
  60. * Determine what program to use for building the project.
  61. */
  62. bool FindMakeProgram(cmMakefile* mf) override;
  63. void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
  64. // Write the common disclaimer text at the top of each build file.
  65. void WriteFileHeader(std::ostream& fout);
  66. protected:
  67. void Generate() override;
  68. std::vector<GeneratedMakeCommand> GenerateBuildCommand(
  69. const std::string& makeProgram, const std::string& projectName,
  70. const std::string& projectDir, std::vector<std::string> const& targetNames,
  71. const std::string& config, int jobs, bool verbose,
  72. const cmBuildOptions& buildOptions = cmBuildOptions(),
  73. std::vector<std::string> const& makeOptions =
  74. std::vector<std::string>()) override;
  75. void AddExtraIDETargets() override;
  76. private:
  77. void GetToolset(cmMakefile* mf, std::string& tsd, const std::string& ts);
  78. /* top-level project */
  79. void OutputTopLevelProject(cmLocalGenerator* root,
  80. std::vector<cmLocalGenerator*>& generators);
  81. void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root);
  82. void WriteMacros(std::ostream& fout, cmLocalGenerator* root);
  83. void WriteHighLevelDirectives(std::ostream& fout, cmLocalGenerator* root);
  84. void WriteSubProjects(std::ostream& fout, bool filterPredefined);
  85. void WriteTargets(cmLocalGenerator* root);
  86. void WriteProjectLine(std::ostream& fout, cmGeneratorTarget const* target,
  87. std::string& rootBinaryDir);
  88. void WriteCustomRuleBOD(std::ostream& fout);
  89. void WriteCustomTargetBOD(std::ostream& fout);
  90. bool AddCheckTarget();
  91. void AddAllTarget();
  92. std::string StampFile;
  93. static std::string TrimQuotes(std::string str);
  94. static const char* DEFAULT_BUILD_PROGRAM;
  95. static const char* CHECK_BUILD_SYSTEM_TARGET;
  96. bool ComputeTargetBuildOrder(cmGeneratorTarget const* tgt,
  97. std::vector<cmGeneratorTarget const*>& build);
  98. bool ComputeTargetBuildOrder(std::vector<cmGeneratorTarget const*>& tgt,
  99. std::vector<cmGeneratorTarget const*>& build);
  100. bool VisitTarget(std::set<cmGeneratorTarget const*>& temp,
  101. std::set<cmGeneratorTarget const*>& perm,
  102. std::vector<cmGeneratorTarget const*>& order,
  103. cmGeneratorTarget const* ti);
  104. std::vector<cmGeneratorTarget const*> ProjectTargets;
  105. // Target sorting
  106. class TargetSet : public std::set<cmGeneratorTarget const*>
  107. {
  108. };
  109. class TargetCompare
  110. {
  111. std::string First;
  112. public:
  113. TargetCompare(std::string first)
  114. : First(std::move(first))
  115. {
  116. }
  117. bool operator()(cmGeneratorTarget const* l,
  118. cmGeneratorTarget const* r) const;
  119. };
  120. class OrderedTargetDependSet;
  121. };
  122. class cmGlobalGhsMultiGenerator::OrderedTargetDependSet
  123. : public std::multiset<cmTargetDepend,
  124. cmGlobalGhsMultiGenerator::TargetCompare>
  125. {
  126. using derived =
  127. std::multiset<cmTargetDepend, cmGlobalGhsMultiGenerator::TargetCompare>;
  128. public:
  129. using TargetDependSet = cmGlobalGenerator::TargetDependSet;
  130. OrderedTargetDependSet(TargetDependSet const&, std::string const& first);
  131. };