Coverage Report

Created: 2026-02-09 06:05

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