summaryrefslogtreecommitdiffstats
path: root/Source/cmRulePlaceholderExpander.h
blob: 83291664a22a6784886d81fb76dcbb4a894762a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */

#ifndef cmRulePlaceholderExpander_h
#define cmRulePlaceholderExpander_h

#include <cmConfigure.h> // IWYU pragma: keep

#include <map>
#include <string>

class cmOutputConverter;

class cmRulePlaceholderExpander
{
public:
  cmRulePlaceholderExpander(
    std::map<std::string, std::string> const& compilers,
    std::map<std::string, std::string> const& variableMappings,
    std::string const& compilerSysroot);

  void SetTargetImpLib(std::string const& targetImpLib)
  {
    this->TargetImpLib = targetImpLib;
  }

  // Create a struct to hold the varibles passed into
  // ExpandRuleVariables
  struct RuleVariables
  {
    RuleVariables();
    const char* CMTargetName;
    const char* CMTargetType;
    const char* TargetPDB;
    const char* TargetCompilePDB;
    const char* TargetVersionMajor;
    const char* TargetVersionMinor;
    const char* Language;
    const char* Objects;
    const char* Target;
    const char* LinkLibraries;
    const char* Source;
    const char* AssemblySource;
    const char* PreprocessedSource;
    const char* Output;
    const char* Object;
    const char* ObjectDir;
    const char* ObjectFileDir;
    const char* Flags;
    const char* ObjectsQuoted;
    const char* SONameFlag;
    const char* TargetSOName;
    const char* TargetInstallNameDir;
    const char* LinkFlags;
    const char* Manifests;
    const char* LanguageCompileFlags;
    const char* Defines;
    const char* Includes;
    const char* DependencyFile;
    const char* FilterPrefix;
  };

  // Expand rule variables in CMake of the type found in language rules
  void ExpandRuleVariables(cmOutputConverter* outputConverter,
                           std::string& string,
                           const RuleVariables& replaceValues);

  // Expand rule variables in a single string
  std::string ExpandRuleVariable(cmOutputConverter* outputConverter,
                                 std::string const& variable,
                                 const RuleVariables& replaceValues);

private:
  std::string TargetImpLib;

  std::map<std::string, std::string> Compilers;
  std::map<std::string, std::string> VariableMappings;
  std::string CompilerSysroot;
};

#endif