Coverage Report

Created: 2026-10-28 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmGeneratorRule.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 "cmConfigure.h" // IWYU pragma: keep
6
7
#include <memory>
8
#include <string>
9
#include <unordered_map>
10
11
#include "cmPlaceholderExpander.h"
12
#include "cmPropertyMap.h"
13
#include "cmRule.h"
14
#include "cmValue.h"
15
16
class cmMakefile;
17
class cmTarget;
18
class cmFileSet;
19
class cmSourceFile;
20
class cmCustomCommand;
21
22
class cmGeneratorRule
23
{
24
public:
25
  cmGeneratorRule(cmRule const* rule, cmTarget const* target,
26
                  cmFileSet const* fileSet, cmFileSet const* outputFileSet,
27
                  cmSourceFile const* source,
28
                  cmRule::PatternSet const& patterns);
29
30
  cmGeneratorRule(cmGeneratorRule const&) = delete;
31
  cmGeneratorRule& operator=(cmGeneratorRule const&) = delete;
32
33
0
  cmMakefile& GetMakefile() const { return this->Makefile; }
34
35
  /** Get the name of the rule */
36
0
  std::string const& GetName() const { return this->Name; }
37
38
0
  cmRule const* GetRule() const { return this->Rule; }
39
0
  cmTarget const* GetTarget() const { return this->Target; }
40
41
0
  bool IsGloballyVisible() const { return this->Rule->IsGloballyVisible(); }
42
43
  cmValue GetProperty(std::string const& property) const;
44
45
  std::unique_ptr<cmCustomCommand> Generate(cmFileSet* outFileSet) const;
46
47
private:
48
  void UpdateRuleExpander(cmRule::PatternSet const& patterns);
49
50
  std::unique_ptr<cmCustomCommand> CreateCustomCommand() const;
51
52
  std::string Name;
53
  cmRule const* Rule;
54
  cmTarget const* Target;
55
  cmFileSet const* FileSet;
56
  cmFileSet const* OutputFileSet;
57
  cmSourceFile const* Source;
58
  cmMakefile& Makefile;
59
  mutable cmPropertyMap Properties;
60
61
  class RulePlaceholderExpander : public cmPlaceholderExpander
62
  {
63
  public:
64
    using VariableMap = std::unordered_map<std::string, std::string>;
65
    VariableMap Values;
66
67
    std::string ExpandVariables(std::string const& string)
68
0
    {
69
0
      std::string value{ string };
70
0
      return cmPlaceholderExpander::ExpandVariables(
71
0
        value, cmPlaceholderExpander::HandleGenex::Yes);
72
0
    }
73
74
  private:
75
    std::string ExpandVariable(std::string const& variable) override;
76
  };
77
78
  static RulePlaceholderExpander::VariableMap const DefaultProperties;
79
80
  mutable RulePlaceholderExpander RuleExpander;
81
};