cmGlobalGhsMultiGenerator.h 5.3 KB

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