1
0

cmGlobalGhsMultiGenerator.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 "cmGlobalGenerator.h"
  11. #include "cmGlobalGeneratorFactory.h"
  12. #include "cmTargetDepend.h"
  13. class cmGeneratorTarget;
  14. class cmLocalGenerator;
  15. class cmMakefile;
  16. class cmake;
  17. struct cmDocumentationEntry;
  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 void GetDocumentation(cmDocumentationEntry& entry);
  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. const char* GetInstallTargetName() const override { return "install"; }
  67. protected:
  68. void Generate() override;
  69. std::vector<GeneratedMakeCommand> GenerateBuildCommand(
  70. const std::string& makeProgram, const std::string& projectName,
  71. const std::string& projectDir, std::vector<std::string> const& targetNames,
  72. const std::string& config, bool fast, int jobs, bool verbose,
  73. std::vector<std::string> const& makeOptions =
  74. std::vector<std::string>()) override;
  75. private:
  76. void GetToolset(cmMakefile* mf, std::string& tsd, const std::string& ts);
  77. /* top-level project */
  78. void OutputTopLevelProject(cmLocalGenerator* root,
  79. std::vector<cmLocalGenerator*>& generators);
  80. void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root);
  81. void WriteMacros(std::ostream& fout, cmLocalGenerator* root);
  82. void WriteHighLevelDirectives(cmLocalGenerator* root, std::ostream& fout);
  83. void WriteSubProjects(std::ostream& fout, std::string& all_target);
  84. void WriteTargets(cmLocalGenerator* root);
  85. void WriteProjectLine(std::ostream& fout, cmGeneratorTarget const* target,
  86. std::string& rootBinaryDir);
  87. void WriteCustomRuleBOD(std::ostream& fout);
  88. void WriteCustomTargetBOD(std::ostream& fout);
  89. void WriteAllTarget(cmLocalGenerator* root,
  90. std::vector<cmLocalGenerator*>& generators,
  91. std::string& all_target);
  92. static std::string TrimQuotes(std::string str);
  93. std::string OsDir;
  94. static const char* DEFAULT_BUILD_PROGRAM;
  95. static const char* DEFAULT_TOOLSET_ROOT;
  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. };