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. #ifndef cmGhsMultiGenerator_h
  4. #define cmGhsMultiGenerator_h
  5. #include <iosfwd>
  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 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, bool build,
  49. cmMakefile* mf) override;
  50. bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
  51. /**
  52. * Try to determine system information such as shared library
  53. * extension, pthreads, byte order etc.
  54. */
  55. void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
  56. bool optional) override;
  57. /*
  58. * Determine what program to use for building the project.
  59. */
  60. bool FindMakeProgram(cmMakefile* mf) override;
  61. void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
  62. // Write the common disclaimer text at the top of each build file.
  63. void WriteFileHeader(std::ostream& fout);
  64. const char* GetInstallTargetName() const override { return "install"; }
  65. protected:
  66. void Generate() override;
  67. std::vector<GeneratedMakeCommand> GenerateBuildCommand(
  68. const std::string& makeProgram, const std::string& projectName,
  69. const std::string& projectDir, std::vector<std::string> const& targetNames,
  70. const std::string& config, bool fast, int jobs, bool verbose,
  71. std::vector<std::string> const& makeOptions =
  72. std::vector<std::string>()) override;
  73. private:
  74. void GetToolset(cmMakefile* mf, std::string& tsd, const std::string& ts);
  75. /* top-level project */
  76. void OutputTopLevelProject(cmLocalGenerator* root,
  77. std::vector<cmLocalGenerator*>& generators);
  78. void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root);
  79. void WriteMacros(std::ostream& fout, cmLocalGenerator* root);
  80. void WriteHighLevelDirectives(cmLocalGenerator* root, std::ostream& fout);
  81. void WriteSubProjects(std::ostream& fout, std::string& all_target);
  82. void WriteTargets(cmLocalGenerator* root);
  83. void WriteProjectLine(std::ostream& fout, cmGeneratorTarget const* target,
  84. cmLocalGenerator* root, std::string& rootBinaryDir);
  85. void WriteCustomRuleBOD(std::ostream& fout);
  86. void WriteCustomTargetBOD(std::ostream& fout);
  87. void WriteAllTarget(cmLocalGenerator* root,
  88. std::vector<cmLocalGenerator*>& generators,
  89. std::string& all_target);
  90. std::string TrimQuotes(std::string const& str);
  91. std::string OsDir;
  92. static const char* DEFAULT_BUILD_PROGRAM;
  93. static const char* DEFAULT_TOOLSET_ROOT;
  94. bool ComputeTargetBuildOrder(cmGeneratorTarget const* tgt,
  95. std::vector<cmGeneratorTarget const*>& build);
  96. bool ComputeTargetBuildOrder(std::vector<cmGeneratorTarget const*>& tgt,
  97. std::vector<cmGeneratorTarget const*>& build);
  98. bool VisitTarget(std::set<cmGeneratorTarget const*>& temp,
  99. std::set<cmGeneratorTarget const*>& perm,
  100. std::vector<cmGeneratorTarget const*>& order,
  101. cmGeneratorTarget const* ti);
  102. std::vector<cmGeneratorTarget const*> ProjectTargets;
  103. // Target sorting
  104. class TargetSet : public std::set<cmGeneratorTarget const*>
  105. {
  106. };
  107. class TargetCompare
  108. {
  109. std::string First;
  110. public:
  111. TargetCompare(std::string first)
  112. : First(std::move(first))
  113. {
  114. }
  115. bool operator()(cmGeneratorTarget const* l,
  116. cmGeneratorTarget const* r) const;
  117. };
  118. class OrderedTargetDependSet;
  119. };
  120. class cmGlobalGhsMultiGenerator::OrderedTargetDependSet
  121. : public std::multiset<cmTargetDepend,
  122. cmGlobalGhsMultiGenerator::TargetCompare>
  123. {
  124. using derived =
  125. std::multiset<cmTargetDepend, cmGlobalGhsMultiGenerator::TargetCompare>;
  126. public:
  127. using TargetDependSet = cmGlobalGenerator::TargetDependSet;
  128. OrderedTargetDependSet(TargetDependSet const&, std::string const& first);
  129. };
  130. #endif