/src/CMake/Source/cmRulePlaceholderExpander.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 | | |
4 | | #pragma once |
5 | | |
6 | | #include "cmConfigure.h" // IWYU pragma: keep |
7 | | |
8 | | #include <functional> |
9 | | #include <map> |
10 | | #include <string> |
11 | | |
12 | | #include <cm/string_view> |
13 | | |
14 | | #include "cmGeneratorOptions.h" |
15 | | #include "cmPlaceholderExpander.h" |
16 | | |
17 | | class cmOutputConverter; |
18 | | |
19 | | class cmRulePlaceholderExpander : public cmPlaceholderExpander |
20 | | { |
21 | | public: |
22 | | enum class UseShortPaths |
23 | | { |
24 | | No, |
25 | | Yes, |
26 | | }; |
27 | | |
28 | | cmRulePlaceholderExpander( |
29 | | cmBuildStep buildStep, std::map<std::string, std::string> compilers, |
30 | | std::map<std::string, std::string> variableMappings, |
31 | | std::string compilerSysroot, std::string linkerSysroot, |
32 | | UseShortPaths useShortPaths); |
33 | | |
34 | | void SetTargetImpLib(std::string const& targetImpLib) |
35 | 0 | { |
36 | 0 | this->TargetImpLib = targetImpLib; |
37 | 0 | } |
38 | | |
39 | | // Create a struct to hold the variables passed into |
40 | | // ExpandRuleVariables |
41 | | struct RuleVariables |
42 | | { |
43 | | char const* CMTargetName = nullptr; |
44 | | char const* CMTargetType = nullptr; |
45 | | char const* TargetPDB = nullptr; |
46 | | char const* TargetCompilePDB = nullptr; |
47 | | char const* TargetVersionMajor = nullptr; |
48 | | char const* TargetVersionMinor = nullptr; |
49 | | char const* Language = nullptr; |
50 | | char const* AIXExports = nullptr; |
51 | | char const* Objects = nullptr; |
52 | | char const* Target = nullptr; |
53 | | char const* LinkLibraries = nullptr; |
54 | | char const* Source = nullptr; |
55 | | char const* AssemblySource = nullptr; |
56 | | char const* PreprocessedSource = nullptr; |
57 | | char const* DynDepFile = nullptr; |
58 | | char const* Output = nullptr; |
59 | | char const* Object = nullptr; |
60 | | char const* TargetSupportDir = nullptr; |
61 | | char const* ObjectDir = nullptr; |
62 | | char const* ObjectFileDir = nullptr; |
63 | | char const* Flags = nullptr; |
64 | | char const* ObjectsQuoted = nullptr; |
65 | | char const* SONameFlag = nullptr; |
66 | | char const* TargetSOName = nullptr; |
67 | | char const* TargetInstallNameDir = nullptr; |
68 | | char const* Linker = nullptr; |
69 | | char const* LinkFlags = nullptr; |
70 | | char const* Manifests = nullptr; |
71 | | char const* LanguageCompileFlags = nullptr; |
72 | | char const* Defines = nullptr; |
73 | | char const* Includes = nullptr; |
74 | | char const* DependencyFile = nullptr; |
75 | | char const* DependencyTarget = nullptr; |
76 | | char const* FilterPrefix = nullptr; |
77 | | char const* SwiftLibraryName = nullptr; |
78 | | char const* SwiftModule = nullptr; |
79 | | char const* SwiftModuleName = nullptr; |
80 | | char const* SwiftOutputFileMapOption = nullptr; |
81 | | char const* SwiftSources = nullptr; |
82 | | char const* RustSources = nullptr; |
83 | | char const* RustObjectDeps = nullptr; |
84 | | char const* ISPCHeader = nullptr; |
85 | | char const* CudaCompileMode = nullptr; |
86 | | char const* Fatbinary = nullptr; |
87 | | char const* RegisterFile = nullptr; |
88 | | char const* Launcher = nullptr; |
89 | | char const* Role = nullptr; |
90 | | char const* Config = nullptr; |
91 | | }; |
92 | | |
93 | | // Expand rule variables in CMake of the type found in language rules |
94 | | void ExpandRuleVariables(cmOutputConverter* outputConverter, |
95 | | std::string& string, |
96 | | RuleVariables const& replaceValues); |
97 | | |
98 | | private: |
99 | | std::string ExpandVariable(std::string const& variable) override; |
100 | | |
101 | | std::string TargetImpLib; |
102 | | |
103 | | cmBuildStep BuildStep = cmBuildStep::Compile; |
104 | | std::map<std::string, std::string> Compilers; |
105 | | std::map<std::string, std::string> VariableMappings; |
106 | | std::string CompilerSysroot; |
107 | | std::string LinkerSysroot; |
108 | | std::function<std::string(cm::string_view)> ConvertToOutputForExisting; |
109 | | |
110 | | cmOutputConverter* OutputConverter = nullptr; |
111 | | RuleVariables const* ReplaceValues = nullptr; |
112 | | }; |