1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt or https://cmake.org/licensing for details.  */
3 
4 #pragma once
5 
6 #include "cmConfigure.h" // IWYU pragma: keep
7 
8 #include <map>
9 #include <string>
10 
11 class cmOutputConverter;
12 
13 class cmRulePlaceholderExpander
14 {
15 public:
16   cmRulePlaceholderExpander(
17     std::map<std::string, std::string> compilers,
18     std::map<std::string, std::string> variableMappings,
19     std::string compilerSysroot, std::string linkerSysroot);
20 
SetTargetImpLib(std::string const & targetImpLib)21   void SetTargetImpLib(std::string const& targetImpLib)
22   {
23     this->TargetImpLib = targetImpLib;
24   }
25 
26   // Create a struct to hold the variables passed into
27   // ExpandRuleVariables
28   struct RuleVariables
29   {
30     const char* CMTargetName = nullptr;
31     const char* CMTargetType = nullptr;
32     const char* TargetPDB = nullptr;
33     const char* TargetCompilePDB = nullptr;
34     const char* TargetVersionMajor = nullptr;
35     const char* TargetVersionMinor = nullptr;
36     const char* Language = nullptr;
37     const char* AIXExports = nullptr;
38     const char* Objects = nullptr;
39     const char* Target = nullptr;
40     const char* LinkLibraries = nullptr;
41     const char* Source = nullptr;
42     const char* AssemblySource = nullptr;
43     const char* PreprocessedSource = nullptr;
44     const char* DynDepFile = nullptr;
45     const char* Output = nullptr;
46     const char* Object = nullptr;
47     const char* ObjectDir = nullptr;
48     const char* ObjectFileDir = nullptr;
49     const char* Flags = nullptr;
50     const char* ObjectsQuoted = nullptr;
51     const char* SONameFlag = nullptr;
52     const char* TargetSOName = nullptr;
53     const char* TargetInstallNameDir = nullptr;
54     const char* LinkFlags = nullptr;
55     const char* Manifests = nullptr;
56     const char* LanguageCompileFlags = nullptr;
57     const char* Defines = nullptr;
58     const char* Includes = nullptr;
59     const char* DependencyFile = nullptr;
60     const char* DependencyTarget = nullptr;
61     const char* FilterPrefix = nullptr;
62     const char* SwiftLibraryName = nullptr;
63     const char* SwiftModule = nullptr;
64     const char* SwiftModuleName = nullptr;
65     const char* SwiftOutputFileMap = nullptr;
66     const char* SwiftSources = nullptr;
67     const char* ISPCHeader = nullptr;
68     const char* Fatbinary = nullptr;
69     const char* RegisterFile = nullptr;
70     const char* Launcher = nullptr;
71   };
72 
73   // Expand rule variables in CMake of the type found in language rules
74   void ExpandRuleVariables(cmOutputConverter* outputConverter,
75                            std::string& string,
76                            const RuleVariables& replaceValues);
77 
78   // Expand rule variables in a single string
79   std::string ExpandRuleVariable(cmOutputConverter* outputConverter,
80                                  std::string const& variable,
81                                  const RuleVariables& replaceValues);
82 
83 private:
84   std::string TargetImpLib;
85 
86   std::map<std::string, std::string> Compilers;
87   std::map<std::string, std::string> VariableMappings;
88   std::string CompilerSysroot;
89   std::string LinkerSysroot;
90 };
91