/src/CMake/Source/cmCMakePresetsGraph.cxx
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 | | #include "cmCMakePresetsGraph.h" |
4 | | |
5 | | #include <algorithm> |
6 | | #include <cassert> |
7 | | #include <cstddef> |
8 | | #include <functional> |
9 | | #include <iostream> |
10 | | #include <iterator> |
11 | | #include <utility> |
12 | | |
13 | | #include <cm/memory> |
14 | | |
15 | | #include "cmsys/RegularExpression.hxx" |
16 | | |
17 | | #include "cmCMakePresetsErrors.h" |
18 | | #include "cmCMakePresetsGraphInternal.h" |
19 | | #include "cmStringAlgorithms.h" |
20 | | #include "cmSystemTools.h" |
21 | | |
22 | | #define CHECK_EXPAND(out, field, expanders, version) \ |
23 | 0 | do { \ |
24 | 0 | switch (ExpandMacros(field, expanders, version)) { \ |
25 | 0 | case ExpandMacroResult::Error: \ |
26 | 0 | return false; \ |
27 | 0 | case ExpandMacroResult::Ignore: \ |
28 | 0 | out.reset(); \ |
29 | 0 | return true; \ |
30 | 0 | case ExpandMacroResult::Ok: \ |
31 | 0 | break; \ |
32 | 0 | } \ |
33 | 0 | } while (false) |
34 | | |
35 | | namespace { |
36 | | enum class CycleStatus |
37 | | { |
38 | | Unvisited, |
39 | | InProgress, |
40 | | Verified, |
41 | | }; |
42 | | |
43 | | using ConfigurePreset = cmCMakePresetsGraph::ConfigurePreset; |
44 | | using BuildPreset = cmCMakePresetsGraph::BuildPreset; |
45 | | using TestPreset = cmCMakePresetsGraph::TestPreset; |
46 | | using PackagePreset = cmCMakePresetsGraph::PackagePreset; |
47 | | using WorkflowPreset = cmCMakePresetsGraph::WorkflowPreset; |
48 | | template <typename T> |
49 | | using PresetPair = cmCMakePresetsGraph::PresetPair<T>; |
50 | | using ExpandMacroResult = cmCMakePresetsGraphInternal::ExpandMacroResult; |
51 | | using MacroExpander = cmCMakePresetsGraphInternal::MacroExpander; |
52 | | using MacroExpanderVector = cmCMakePresetsGraphInternal::MacroExpanderVector; |
53 | | using BaseMacroExpander = cmCMakePresetsGraphInternal::BaseMacroExpander; |
54 | | template <typename T> |
55 | | using PresetMacroExpander = |
56 | | cmCMakePresetsGraphInternal::PresetMacroExpander<T>; |
57 | | using cmCMakePresetsGraphInternal::ExpandMacros; |
58 | | |
59 | | void InheritString(std::string& child, std::string const& parent) |
60 | 0 | { |
61 | 0 | if (child.empty()) { |
62 | 0 | child = parent; |
63 | 0 | } |
64 | 0 | } |
65 | | |
66 | | template <typename T> |
67 | | void InheritOptionalValue(cm::optional<T>& child, |
68 | | cm::optional<T> const& parent) |
69 | 0 | { |
70 | 0 | if (!child) { |
71 | 0 | child = parent; |
72 | 0 | } |
73 | 0 | } Unexecuted instantiation: cmCMakePresetsGraph.cxx:void (anonymous namespace)::InheritOptionalValue<bool>(std::__1::optional<bool>&, std::__1::optional<bool> const&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:void (anonymous namespace)::InheritOptionalValue<unsigned int>(std::__1::optional<unsigned int>&, std::__1::optional<unsigned int> const&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:void (anonymous namespace)::InheritOptionalValue<cmCMakePresetsGraph::TestPreset::OutputOptions::VerbosityEnum>(std::__1::optional<cmCMakePresetsGraph::TestPreset::OutputOptions::VerbosityEnum>&, std::__1::optional<cmCMakePresetsGraph::TestPreset::OutputOptions::VerbosityEnum> const&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:void (anonymous namespace)::InheritOptionalValue<int>(std::__1::optional<int>&, std::__1::optional<int> const&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:void (anonymous namespace)::InheritOptionalValue<cmCTestTypes::TruncationMode>(std::__1::optional<cmCTestTypes::TruncationMode>&, std::__1::optional<cmCTestTypes::TruncationMode> const&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:void (anonymous namespace)::InheritOptionalValue<cmCMakePresetsGraph::TestPreset::IncludeOptions::IndexOptions>(std::__1::optional<cmCMakePresetsGraph::TestPreset::IncludeOptions::IndexOptions>&, std::__1::optional<cmCMakePresetsGraph::TestPreset::IncludeOptions::IndexOptions> const&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:void (anonymous namespace)::InheritOptionalValue<cmCMakePresetsGraph::TestPreset::ExcludeOptions::FixturesOptions>(std::__1::optional<cmCMakePresetsGraph::TestPreset::ExcludeOptions::FixturesOptions>&, std::__1::optional<cmCMakePresetsGraph::TestPreset::ExcludeOptions::FixturesOptions> const&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:void (anonymous namespace)::InheritOptionalValue<std::__1::optional<unsigned int> >(std::__1::optional<std::__1::optional<unsigned int> >&, std::__1::optional<std::__1::optional<unsigned int> > const&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:void (anonymous namespace)::InheritOptionalValue<cmCMakePresetsGraph::TestPreset::ExecutionOptions::ShowOnlyEnum>(std::__1::optional<cmCMakePresetsGraph::TestPreset::ExecutionOptions::ShowOnlyEnum>&, std::__1::optional<cmCMakePresetsGraph::TestPreset::ExecutionOptions::ShowOnlyEnum> const&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:void (anonymous namespace)::InheritOptionalValue<cmCMakePresetsGraph::TestPreset::ExecutionOptions::RepeatOptions>(std::__1::optional<cmCMakePresetsGraph::TestPreset::ExecutionOptions::RepeatOptions>&, std::__1::optional<cmCMakePresetsGraph::TestPreset::ExecutionOptions::RepeatOptions> const&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:void (anonymous namespace)::InheritOptionalValue<cmCMakePresetsGraph::TestPreset::ExecutionOptions::NoTestsActionEnum>(std::__1::optional<cmCMakePresetsGraph::TestPreset::ExecutionOptions::NoTestsActionEnum>&, std::__1::optional<cmCMakePresetsGraph::TestPreset::ExecutionOptions::NoTestsActionEnum> const&) |
74 | | |
75 | | template <typename T> |
76 | | void InheritVector(std::vector<T>& child, std::vector<T> const& parent) |
77 | 0 | { |
78 | 0 | if (child.empty()) { |
79 | 0 | child = parent; |
80 | 0 | } |
81 | 0 | } |
82 | | |
83 | | /** |
84 | | * Check preset inheritance for cycles (using a DAG check algorithm) while |
85 | | * also bubbling up fields through the inheritance hierarchy, then verify |
86 | | * that each preset has the required fields, either directly or through |
87 | | * inheritance. |
88 | | */ |
89 | | template <class T> |
90 | | bool VisitPreset( |
91 | | T& preset, |
92 | | std::map<std::string, cmCMakePresetsGraph::PresetPair<T>>& presets, |
93 | | std::map<std::string, CycleStatus> cycleStatus, cmCMakePresetsGraph& graph) |
94 | 0 | { |
95 | 0 | switch (cycleStatus[preset.Name]) { |
96 | 0 | case CycleStatus::InProgress: |
97 | 0 | cmCMakePresetsErrors::CYCLIC_PRESET_INHERITANCE(preset.Name, |
98 | 0 | &graph.parseState); |
99 | 0 | return false; |
100 | 0 | case CycleStatus::Verified: |
101 | 0 | return true; |
102 | 0 | default: |
103 | 0 | break; |
104 | 0 | } |
105 | | |
106 | 0 | cycleStatus[preset.Name] = CycleStatus::InProgress; |
107 | |
|
108 | 0 | if (preset.Environment.count("") != 0) { |
109 | 0 | cmCMakePresetsErrors::INVALID_PRESET_NAMED(preset.Name, &graph.parseState); |
110 | 0 | return false; |
111 | 0 | } |
112 | | |
113 | 0 | bool result = preset.VisitPresetBeforeInherit(); |
114 | 0 | if (!result) { |
115 | 0 | cmCMakePresetsErrors::INVALID_PRESET_NAMED(preset.Name, &graph.parseState); |
116 | 0 | return false; |
117 | 0 | } |
118 | | |
119 | 0 | for (auto const& i : preset.Inherits) { |
120 | 0 | auto parent = presets.find(i); |
121 | 0 | if (parent == presets.end()) { |
122 | 0 | cmCMakePresetsErrors::INVALID_PRESET_NAMED(preset.Name, |
123 | 0 | &graph.parseState); |
124 | 0 | return false; |
125 | 0 | } |
126 | | |
127 | 0 | auto& parentPreset = parent->second.Unexpanded; |
128 | 0 | if (!preset.OriginFile->ReachableFiles.count(parentPreset.OriginFile)) { |
129 | 0 | cmCMakePresetsErrors::INHERITED_PRESET_UNREACHABLE_FROM_FILE( |
130 | 0 | preset.Name, &graph.parseState); |
131 | 0 | return false; |
132 | 0 | } |
133 | | |
134 | 0 | if (!VisitPreset(parentPreset, presets, cycleStatus, graph)) { |
135 | 0 | return false; |
136 | 0 | } |
137 | | |
138 | 0 | result = preset.VisitPresetInherit(parentPreset); |
139 | 0 | if (!result) { |
140 | 0 | cmCMakePresetsErrors::INVALID_PRESET_NAMED(preset.Name, |
141 | 0 | &graph.parseState); |
142 | 0 | return false; |
143 | 0 | } |
144 | | |
145 | 0 | for (auto const& v : parentPreset.Environment) { |
146 | 0 | preset.Environment.insert(v); |
147 | 0 | } |
148 | |
|
149 | 0 | if (!preset.ConditionEvaluator) { |
150 | 0 | preset.ConditionEvaluator = parentPreset.ConditionEvaluator; |
151 | 0 | } |
152 | 0 | } |
153 | | |
154 | 0 | if (preset.ConditionEvaluator && preset.ConditionEvaluator->IsNull()) { |
155 | 0 | preset.ConditionEvaluator.reset(); |
156 | 0 | } |
157 | |
|
158 | 0 | result = preset.VisitPresetAfterInherit(graph.GetVersion(preset), |
159 | 0 | &graph.parseState); |
160 | 0 | if (!result) { |
161 | 0 | cmCMakePresetsErrors::INVALID_PRESET_NAMED(preset.Name, &graph.parseState); |
162 | 0 | return false; |
163 | 0 | } |
164 | | |
165 | 0 | cycleStatus[preset.Name] = CycleStatus::Verified; |
166 | 0 | return true; |
167 | 0 | } Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::VisitPreset<cmCMakePresetsGraph::ConfigurePreset>(cmCMakePresetsGraph::ConfigurePreset&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::ConfigurePreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::ConfigurePreset> > > >&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::CycleStatus, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, (anonymous namespace)::CycleStatus> > >, cmCMakePresetsGraph&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::VisitPreset<cmCMakePresetsGraph::BuildPreset>(cmCMakePresetsGraph::BuildPreset&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::BuildPreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::BuildPreset> > > >&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::CycleStatus, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, (anonymous namespace)::CycleStatus> > >, cmCMakePresetsGraph&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::VisitPreset<cmCMakePresetsGraph::TestPreset>(cmCMakePresetsGraph::TestPreset&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::TestPreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::TestPreset> > > >&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::CycleStatus, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, (anonymous namespace)::CycleStatus> > >, cmCMakePresetsGraph&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::VisitPreset<cmCMakePresetsGraph::PackagePreset>(cmCMakePresetsGraph::PackagePreset&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::PackagePreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::PackagePreset> > > >&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::CycleStatus, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, (anonymous namespace)::CycleStatus> > >, cmCMakePresetsGraph&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::VisitPreset<cmCMakePresetsGraph::WorkflowPreset>(cmCMakePresetsGraph::WorkflowPreset&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::WorkflowPreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::WorkflowPreset> > > >&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::CycleStatus, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, (anonymous namespace)::CycleStatus> > >, cmCMakePresetsGraph&) |
168 | | |
169 | | template <class T> |
170 | | bool ComputePresetInheritance( |
171 | | std::map<std::string, cmCMakePresetsGraph::PresetPair<T>>& presets, |
172 | | cmCMakePresetsGraph& graph) |
173 | 0 | { |
174 | 0 | std::map<std::string, CycleStatus> cycleStatus; |
175 | 0 | for (auto const& it : presets) { |
176 | 0 | cycleStatus[it.first] = CycleStatus::Unvisited; |
177 | 0 | } |
178 | |
|
179 | 0 | for (auto& it : presets) { |
180 | 0 | auto& preset = it.second.Unexpanded; |
181 | 0 | if (!VisitPreset<T>(preset, presets, cycleStatus, graph)) { |
182 | 0 | return false; |
183 | 0 | } |
184 | 0 | } |
185 | | |
186 | 0 | return true; |
187 | 0 | } Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::ComputePresetInheritance<cmCMakePresetsGraph::ConfigurePreset>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::ConfigurePreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::ConfigurePreset> > > >&, cmCMakePresetsGraph&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::ComputePresetInheritance<cmCMakePresetsGraph::BuildPreset>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::BuildPreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::BuildPreset> > > >&, cmCMakePresetsGraph&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::ComputePresetInheritance<cmCMakePresetsGraph::TestPreset>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::TestPreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::TestPreset> > > >&, cmCMakePresetsGraph&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::ComputePresetInheritance<cmCMakePresetsGraph::PackagePreset>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::PackagePreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::PackagePreset> > > >&, cmCMakePresetsGraph&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::ComputePresetInheritance<cmCMakePresetsGraph::WorkflowPreset>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::WorkflowPreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::WorkflowPreset> > > >&, cmCMakePresetsGraph&) |
188 | | |
189 | | constexpr char const* ValidPrefixes[] = { |
190 | | "", |
191 | | "env", |
192 | | "penv", |
193 | | "vendor", |
194 | | }; |
195 | | |
196 | | bool PrefixesValidMacroNamespace(std::string const& str) |
197 | 0 | { |
198 | 0 | return std::any_of( |
199 | 0 | std::begin(ValidPrefixes), std::end(ValidPrefixes), |
200 | 0 | [&str](char const* prefix) -> bool { return cmHasPrefix(prefix, str); }); |
201 | 0 | } |
202 | | |
203 | | bool IsValidMacroNamespace(std::string const& str) |
204 | 0 | { |
205 | 0 | return std::any_of( |
206 | 0 | std::begin(ValidPrefixes), std::end(ValidPrefixes), |
207 | 0 | [&str](char const* prefix) -> bool { return str == prefix; }); |
208 | 0 | } |
209 | | |
210 | | ExpandMacroResult VisitEnv(std::string& value, CycleStatus& status, |
211 | | MacroExpanderVector const& macroExpanders, |
212 | | int version); |
213 | | template <class T> |
214 | | class EnvironmentMacroExpander : public MacroExpander |
215 | | { |
216 | | std::map<std::string, CycleStatus>& EnvCycles; |
217 | | cm::optional<T>& Out; |
218 | | MacroExpanderVector& MacroExpanders; |
219 | | |
220 | | public: |
221 | | EnvironmentMacroExpander(MacroExpanderVector& macroExpanders, |
222 | | cm::optional<T>& out, |
223 | | std::map<std::string, CycleStatus>& envCycles) |
224 | 0 | : EnvCycles(envCycles) |
225 | 0 | , Out(out) |
226 | 0 | , MacroExpanders(macroExpanders) |
227 | 0 | { |
228 | 0 | } Unexecuted instantiation: cmCMakePresetsGraph.cxx:(anonymous namespace)::EnvironmentMacroExpander<cmCMakePresetsGraph::ConfigurePreset>::EnvironmentMacroExpander(std::__1::vector<std::__1::unique_ptr<cmCMakePresetsGraphInternal::MacroExpander, std::__1::default_delete<cmCMakePresetsGraphInternal::MacroExpander> >, std::__1::allocator<std::__1::unique_ptr<cmCMakePresetsGraphInternal::MacroExpander, std::__1::default_delete<cmCMakePresetsGraphInternal::MacroExpander> > > >&, std::__1::optional<cmCMakePresetsGraph::ConfigurePreset>&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::CycleStatus, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, (anonymous namespace)::CycleStatus> > >&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:(anonymous namespace)::EnvironmentMacroExpander<cmCMakePresetsGraph::BuildPreset>::EnvironmentMacroExpander(std::__1::vector<std::__1::unique_ptr<cmCMakePresetsGraphInternal::MacroExpander, std::__1::default_delete<cmCMakePresetsGraphInternal::MacroExpander> >, std::__1::allocator<std::__1::unique_ptr<cmCMakePresetsGraphInternal::MacroExpander, std::__1::default_delete<cmCMakePresetsGraphInternal::MacroExpander> > > >&, std::__1::optional<cmCMakePresetsGraph::BuildPreset>&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::CycleStatus, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, (anonymous namespace)::CycleStatus> > >&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:(anonymous namespace)::EnvironmentMacroExpander<cmCMakePresetsGraph::TestPreset>::EnvironmentMacroExpander(std::__1::vector<std::__1::unique_ptr<cmCMakePresetsGraphInternal::MacroExpander, std::__1::default_delete<cmCMakePresetsGraphInternal::MacroExpander> >, std::__1::allocator<std::__1::unique_ptr<cmCMakePresetsGraphInternal::MacroExpander, std::__1::default_delete<cmCMakePresetsGraphInternal::MacroExpander> > > >&, std::__1::optional<cmCMakePresetsGraph::TestPreset>&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::CycleStatus, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, (anonymous namespace)::CycleStatus> > >&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:(anonymous namespace)::EnvironmentMacroExpander<cmCMakePresetsGraph::PackagePreset>::EnvironmentMacroExpander(std::__1::vector<std::__1::unique_ptr<cmCMakePresetsGraphInternal::MacroExpander, std::__1::default_delete<cmCMakePresetsGraphInternal::MacroExpander> >, std::__1::allocator<std::__1::unique_ptr<cmCMakePresetsGraphInternal::MacroExpander, std::__1::default_delete<cmCMakePresetsGraphInternal::MacroExpander> > > >&, std::__1::optional<cmCMakePresetsGraph::PackagePreset>&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::CycleStatus, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, (anonymous namespace)::CycleStatus> > >&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:(anonymous namespace)::EnvironmentMacroExpander<cmCMakePresetsGraph::WorkflowPreset>::EnvironmentMacroExpander(std::__1::vector<std::__1::unique_ptr<cmCMakePresetsGraphInternal::MacroExpander, std::__1::default_delete<cmCMakePresetsGraphInternal::MacroExpander> >, std::__1::allocator<std::__1::unique_ptr<cmCMakePresetsGraphInternal::MacroExpander, std::__1::default_delete<cmCMakePresetsGraphInternal::MacroExpander> > > >&, std::__1::optional<cmCMakePresetsGraph::WorkflowPreset>&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::CycleStatus, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, (anonymous namespace)::CycleStatus> > >&) |
229 | | ExpandMacroResult operator()(std::string const& macroNamespace, |
230 | | std::string const& macroName, |
231 | | std::string& macroOut, |
232 | | int version) const override |
233 | 0 | { |
234 | 0 | if (macroNamespace == "env" && !macroName.empty() && Out) { |
235 | 0 | auto v = Out->Environment.find(macroName); |
236 | 0 | if (v != Out->Environment.end() && v->second) { |
237 | 0 | auto e = |
238 | 0 | VisitEnv(*v->second, EnvCycles[macroName], MacroExpanders, version); |
239 | 0 | if (e != ExpandMacroResult::Ok) { |
240 | 0 | return e; |
241 | 0 | } |
242 | 0 | macroOut += *v->second; |
243 | 0 | return ExpandMacroResult::Ok; |
244 | 0 | } |
245 | 0 | } |
246 | | |
247 | 0 | if (macroNamespace == "env" || macroNamespace == "penv") { |
248 | 0 | if (macroName.empty()) { |
249 | 0 | return ExpandMacroResult::Error; |
250 | 0 | } |
251 | 0 | if (cm::optional<std::string> value = |
252 | 0 | cmSystemTools::GetEnvVar(macroName)) { |
253 | 0 | macroOut += *value; |
254 | 0 | } |
255 | 0 | return ExpandMacroResult::Ok; |
256 | 0 | } |
257 | | |
258 | 0 | return ExpandMacroResult::Ignore; |
259 | 0 | } Unexecuted instantiation: cmCMakePresetsGraph.cxx:(anonymous namespace)::EnvironmentMacroExpander<cmCMakePresetsGraph::ConfigurePreset>::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, int) const Unexecuted instantiation: cmCMakePresetsGraph.cxx:(anonymous namespace)::EnvironmentMacroExpander<cmCMakePresetsGraph::BuildPreset>::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, int) const Unexecuted instantiation: cmCMakePresetsGraph.cxx:(anonymous namespace)::EnvironmentMacroExpander<cmCMakePresetsGraph::TestPreset>::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, int) const Unexecuted instantiation: cmCMakePresetsGraph.cxx:(anonymous namespace)::EnvironmentMacroExpander<cmCMakePresetsGraph::PackagePreset>::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, int) const Unexecuted instantiation: cmCMakePresetsGraph.cxx:(anonymous namespace)::EnvironmentMacroExpander<cmCMakePresetsGraph::WorkflowPreset>::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, int) const |
260 | | }; |
261 | | |
262 | | bool ExpandMacros(cmCMakePresetsGraph const& graph, |
263 | | ConfigurePreset const& preset, |
264 | | cm::optional<ConfigurePreset>& out, |
265 | | MacroExpanderVector const& macroExpanders) |
266 | 0 | { |
267 | 0 | std::string binaryDir = preset.BinaryDir; |
268 | 0 | CHECK_EXPAND(out, binaryDir, macroExpanders, graph.GetVersion(preset)); |
269 | | |
270 | 0 | if (!binaryDir.empty()) { |
271 | 0 | if (!cmSystemTools::FileIsFullPath(binaryDir)) { |
272 | 0 | binaryDir = cmStrCat(graph.SourceDir, '/', binaryDir); |
273 | 0 | } |
274 | 0 | out->BinaryDir = cmSystemTools::CollapseFullPath(binaryDir); |
275 | 0 | cmSystemTools::ConvertToUnixSlashes(out->BinaryDir); |
276 | 0 | } |
277 | |
|
278 | 0 | if (!preset.InstallDir.empty()) { |
279 | 0 | std::string installDir = preset.InstallDir; |
280 | 0 | CHECK_EXPAND(out, installDir, macroExpanders, graph.GetVersion(preset)); |
281 | | |
282 | 0 | if (!cmSystemTools::FileIsFullPath(installDir)) { |
283 | 0 | installDir = cmStrCat(graph.SourceDir, '/', installDir); |
284 | 0 | } |
285 | 0 | out->InstallDir = cmSystemTools::CollapseFullPath(installDir); |
286 | 0 | cmSystemTools::ConvertToUnixSlashes(out->InstallDir); |
287 | 0 | } |
288 | | |
289 | 0 | if (!preset.ToolchainFile.empty()) { |
290 | 0 | std::string toolchain = preset.ToolchainFile; |
291 | 0 | CHECK_EXPAND(out, toolchain, macroExpanders, graph.GetVersion(preset)); |
292 | 0 | out->ToolchainFile = toolchain; |
293 | 0 | } |
294 | | |
295 | 0 | if (!preset.GraphVizFile.empty()) { |
296 | 0 | std::string graphVizFile = preset.GraphVizFile; |
297 | 0 | CHECK_EXPAND(out, graphVizFile, macroExpanders, graph.GetVersion(preset)); |
298 | 0 | out->GraphVizFile = graphVizFile; |
299 | 0 | } |
300 | | |
301 | 0 | for (auto& variable : out->CacheVariables) { |
302 | 0 | if (variable.second) { |
303 | 0 | CHECK_EXPAND(out, variable.second->Value, macroExpanders, |
304 | 0 | graph.GetVersion(preset)); |
305 | 0 | } |
306 | 0 | } |
307 | | |
308 | 0 | return true; |
309 | 0 | } |
310 | | |
311 | | bool ExpandMacros(cmCMakePresetsGraph const& graph, BuildPreset const& preset, |
312 | | cm::optional<BuildPreset>& out, |
313 | | MacroExpanderVector const& macroExpanders) |
314 | 0 | { |
315 | 0 | for (auto& target : out->Targets) { |
316 | 0 | CHECK_EXPAND(out, target, macroExpanders, graph.GetVersion(preset)); |
317 | 0 | } |
318 | | |
319 | 0 | for (auto& nativeToolOption : out->NativeToolOptions) { |
320 | 0 | CHECK_EXPAND(out, nativeToolOption, macroExpanders, |
321 | 0 | graph.GetVersion(preset)); |
322 | 0 | } |
323 | | |
324 | 0 | return true; |
325 | 0 | } |
326 | | |
327 | | bool ExpandMacros(cmCMakePresetsGraph const& graph, TestPreset const& preset, |
328 | | cm::optional<TestPreset>& out, |
329 | | MacroExpanderVector const& macroExpanders) |
330 | 0 | { |
331 | 0 | for (auto& overwrite : out->OverwriteConfigurationFile) { |
332 | 0 | CHECK_EXPAND(out, overwrite, macroExpanders, graph.GetVersion(preset)); |
333 | 0 | } |
334 | | |
335 | 0 | if (out->Output) { |
336 | 0 | CHECK_EXPAND(out, out->Output->OutputLogFile, macroExpanders, |
337 | 0 | graph.GetVersion(preset)); |
338 | 0 | CHECK_EXPAND(out, out->Output->OutputJUnitFile, macroExpanders, |
339 | 0 | graph.GetVersion(preset)); |
340 | 0 | } |
341 | | |
342 | 0 | if (out->Filter) { |
343 | 0 | if (out->Filter->Include) { |
344 | 0 | CHECK_EXPAND(out, out->Filter->Include->Name, macroExpanders, |
345 | 0 | graph.GetVersion(preset)); |
346 | 0 | CHECK_EXPAND(out, out->Filter->Include->Label, macroExpanders, |
347 | 0 | graph.GetVersion(preset)); |
348 | | |
349 | 0 | if (out->Filter->Include->Index) { |
350 | 0 | CHECK_EXPAND(out, out->Filter->Include->Index->IndexFile, |
351 | 0 | macroExpanders, graph.GetVersion(preset)); |
352 | 0 | } |
353 | 0 | } |
354 | | |
355 | 0 | if (out->Filter->Exclude) { |
356 | 0 | CHECK_EXPAND(out, out->Filter->Exclude->Name, macroExpanders, |
357 | 0 | graph.GetVersion(preset)); |
358 | 0 | CHECK_EXPAND(out, out->Filter->Exclude->Label, macroExpanders, |
359 | 0 | graph.GetVersion(preset)); |
360 | | |
361 | 0 | if (out->Filter->Exclude->Fixtures) { |
362 | 0 | CHECK_EXPAND(out, out->Filter->Exclude->Fixtures->Any, macroExpanders, |
363 | 0 | graph.GetVersion(preset)); |
364 | 0 | CHECK_EXPAND(out, out->Filter->Exclude->Fixtures->Setup, |
365 | 0 | macroExpanders, graph.GetVersion(preset)); |
366 | 0 | CHECK_EXPAND(out, out->Filter->Exclude->Fixtures->Cleanup, |
367 | 0 | macroExpanders, graph.GetVersion(preset)); |
368 | 0 | } |
369 | 0 | } |
370 | 0 | } |
371 | | |
372 | 0 | if (out->Execution) { |
373 | 0 | CHECK_EXPAND(out, out->Execution->ResourceSpecFile, macroExpanders, |
374 | 0 | graph.GetVersion(preset)); |
375 | 0 | } |
376 | | |
377 | 0 | return true; |
378 | 0 | } |
379 | | |
380 | | bool ExpandMacros(cmCMakePresetsGraph const& graph, |
381 | | PackagePreset const& preset, |
382 | | cm::optional<PackagePreset>& out, |
383 | | MacroExpanderVector const& macroExpanders) |
384 | 0 | { |
385 | 0 | for (auto& variable : out->Variables) { |
386 | 0 | CHECK_EXPAND(out, variable.second, macroExpanders, |
387 | 0 | graph.GetVersion(preset)); |
388 | 0 | } |
389 | | |
390 | 0 | CHECK_EXPAND(out, out->ConfigFile, macroExpanders, graph.GetVersion(preset)); |
391 | 0 | CHECK_EXPAND(out, out->PackageName, macroExpanders, |
392 | 0 | graph.GetVersion(preset)); |
393 | 0 | CHECK_EXPAND(out, out->PackageVersion, macroExpanders, |
394 | 0 | graph.GetVersion(preset)); |
395 | 0 | CHECK_EXPAND(out, out->PackageDirectory, macroExpanders, |
396 | 0 | graph.GetVersion(preset)); |
397 | 0 | CHECK_EXPAND(out, out->VendorName, macroExpanders, graph.GetVersion(preset)); |
398 | | |
399 | 0 | return true; |
400 | 0 | } |
401 | | |
402 | | bool ExpandMacros(cmCMakePresetsGraph const& /*graph*/, |
403 | | WorkflowPreset const& /*preset*/, |
404 | | cm::optional<WorkflowPreset>& /*out*/, |
405 | | MacroExpanderVector const& /*macroExpanders*/) |
406 | 0 | { |
407 | 0 | return true; |
408 | 0 | } |
409 | | |
410 | | template <class T> |
411 | | bool ExpandMacros(cmCMakePresetsGraph& graph, T const& preset, |
412 | | cm::optional<T>& out) |
413 | 0 | { |
414 | 0 | out.emplace(preset); |
415 | |
|
416 | 0 | std::map<std::string, CycleStatus> envCycles; |
417 | 0 | for (auto const& v : out->Environment) { |
418 | 0 | envCycles[v.first] = CycleStatus::Unvisited; |
419 | 0 | } |
420 | |
|
421 | 0 | MacroExpanderVector macroExpanders{}; |
422 | |
|
423 | 0 | macroExpanders.push_back(cm::make_unique<BaseMacroExpander>(graph)); |
424 | 0 | macroExpanders.push_back( |
425 | 0 | cm::make_unique<PresetMacroExpander<T>>(graph, preset)); |
426 | 0 | macroExpanders.push_back(cm::make_unique<EnvironmentMacroExpander<T>>( |
427 | 0 | macroExpanders, out, envCycles)); |
428 | |
|
429 | 0 | for (auto& v : out->Environment) { |
430 | 0 | if (v.second) { |
431 | 0 | switch (VisitEnv(*v.second, envCycles[v.first], macroExpanders, |
432 | 0 | graph.GetVersion(preset))) { |
433 | 0 | case ExpandMacroResult::Error: |
434 | 0 | cmCMakePresetsErrors::INVALID_PRESET_NAMED(preset.Name, |
435 | 0 | &graph.parseState); |
436 | 0 | return false; |
437 | 0 | case ExpandMacroResult::Ignore: |
438 | 0 | out.reset(); |
439 | 0 | return true; |
440 | 0 | case ExpandMacroResult::Ok: |
441 | 0 | break; |
442 | 0 | } |
443 | 0 | } |
444 | 0 | } |
445 | | |
446 | 0 | if (preset.ConditionEvaluator) { |
447 | 0 | cm::optional<bool> result; |
448 | 0 | if (!preset.ConditionEvaluator->Evaluate( |
449 | 0 | macroExpanders, graph.GetVersion(preset), result)) { |
450 | 0 | cmCMakePresetsErrors::INVALID_PRESET_NAMED(preset.Name, |
451 | 0 | &graph.parseState); |
452 | 0 | return false; |
453 | 0 | } |
454 | 0 | if (!result) { |
455 | 0 | out.reset(); |
456 | 0 | return true; |
457 | 0 | } |
458 | 0 | out->ConditionResult = *result; |
459 | 0 | } |
460 | | |
461 | 0 | return ExpandMacros(graph, preset, out, macroExpanders); |
462 | 0 | } Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::ExpandMacros<cmCMakePresetsGraph::ConfigurePreset>(cmCMakePresetsGraph&, cmCMakePresetsGraph::ConfigurePreset const&, std::__1::optional<cmCMakePresetsGraph::ConfigurePreset>&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::ExpandMacros<cmCMakePresetsGraph::BuildPreset>(cmCMakePresetsGraph&, cmCMakePresetsGraph::BuildPreset const&, std::__1::optional<cmCMakePresetsGraph::BuildPreset>&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::ExpandMacros<cmCMakePresetsGraph::TestPreset>(cmCMakePresetsGraph&, cmCMakePresetsGraph::TestPreset const&, std::__1::optional<cmCMakePresetsGraph::TestPreset>&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::ExpandMacros<cmCMakePresetsGraph::PackagePreset>(cmCMakePresetsGraph&, cmCMakePresetsGraph::PackagePreset const&, std::__1::optional<cmCMakePresetsGraph::PackagePreset>&) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::ExpandMacros<cmCMakePresetsGraph::WorkflowPreset>(cmCMakePresetsGraph&, cmCMakePresetsGraph::WorkflowPreset const&, std::__1::optional<cmCMakePresetsGraph::WorkflowPreset>&) |
463 | | |
464 | | ExpandMacroResult VisitEnv(std::string& value, CycleStatus& status, |
465 | | MacroExpanderVector const& macroExpanders, |
466 | | int version) |
467 | 0 | { |
468 | 0 | if (status == CycleStatus::Verified) { |
469 | 0 | return ExpandMacroResult::Ok; |
470 | 0 | } |
471 | 0 | if (status == CycleStatus::InProgress) { |
472 | 0 | return ExpandMacroResult::Error; |
473 | 0 | } |
474 | | |
475 | 0 | status = CycleStatus::InProgress; |
476 | 0 | auto e = ExpandMacros(value, macroExpanders, version); |
477 | 0 | if (e != ExpandMacroResult::Ok) { |
478 | 0 | return e; |
479 | 0 | } |
480 | 0 | status = CycleStatus::Verified; |
481 | 0 | return ExpandMacroResult::Ok; |
482 | 0 | } |
483 | | } |
484 | | |
485 | | ExpandMacroResult cmCMakePresetsGraphInternal::ExpandMacros( |
486 | | std::string& out, MacroExpanderVector const& macroExpanders, int version) |
487 | 0 | { |
488 | 0 | std::string result; |
489 | 0 | std::string macroNamespace; |
490 | 0 | std::string macroName; |
491 | |
|
492 | 0 | enum class State |
493 | 0 | { |
494 | 0 | Default, |
495 | 0 | MacroNamespace, |
496 | 0 | MacroName, |
497 | 0 | } state = State::Default; |
498 | |
|
499 | 0 | for (auto c : out) { |
500 | 0 | switch (state) { |
501 | 0 | case State::Default: |
502 | 0 | if (c == '$') { |
503 | 0 | state = State::MacroNamespace; |
504 | 0 | } else { |
505 | 0 | result += c; |
506 | 0 | } |
507 | 0 | break; |
508 | | |
509 | 0 | case State::MacroNamespace: |
510 | 0 | if (c == '{') { |
511 | 0 | if (IsValidMacroNamespace(macroNamespace)) { |
512 | 0 | state = State::MacroName; |
513 | 0 | } else { |
514 | 0 | result += '$'; |
515 | 0 | result += macroNamespace; |
516 | 0 | result += '{'; |
517 | 0 | macroNamespace.clear(); |
518 | 0 | state = State::Default; |
519 | 0 | } |
520 | 0 | } else { |
521 | 0 | macroNamespace += c; |
522 | 0 | if (!PrefixesValidMacroNamespace(macroNamespace)) { |
523 | 0 | result += '$'; |
524 | 0 | result += macroNamespace; |
525 | 0 | macroNamespace.clear(); |
526 | 0 | state = State::Default; |
527 | 0 | } |
528 | 0 | } |
529 | 0 | break; |
530 | | |
531 | 0 | case State::MacroName: |
532 | 0 | if (c == '}') { |
533 | 0 | auto e = ExpandMacro(result, macroNamespace, macroName, |
534 | 0 | macroExpanders, version); |
535 | 0 | if (e != ExpandMacroResult::Ok) { |
536 | 0 | return e; |
537 | 0 | } |
538 | 0 | macroNamespace.clear(); |
539 | 0 | macroName.clear(); |
540 | 0 | state = State::Default; |
541 | 0 | } else { |
542 | 0 | macroName += c; |
543 | 0 | } |
544 | 0 | break; |
545 | 0 | } |
546 | 0 | } |
547 | | |
548 | 0 | switch (state) { |
549 | 0 | case State::Default: |
550 | 0 | break; |
551 | 0 | case State::MacroNamespace: |
552 | 0 | result += '$'; |
553 | 0 | result += macroNamespace; |
554 | 0 | break; |
555 | 0 | case State::MacroName: |
556 | 0 | return ExpandMacroResult::Error; |
557 | 0 | } |
558 | | |
559 | 0 | out = std::move(result); |
560 | 0 | return ExpandMacroResult::Ok; |
561 | 0 | } |
562 | | |
563 | | ExpandMacroResult cmCMakePresetsGraphInternal::ExpandMacro( |
564 | | std::string& out, std::string const& macroNamespace, |
565 | | std::string const& macroName, MacroExpanderVector const& macroExpanders, |
566 | | int version) |
567 | 0 | { |
568 | 0 | for (auto const& macroExpander : macroExpanders) { |
569 | 0 | auto result = (*macroExpander)(macroNamespace, macroName, out, version); |
570 | 0 | if (result != ExpandMacroResult::Ignore) { |
571 | 0 | return result; |
572 | 0 | } |
573 | 0 | } |
574 | | |
575 | 0 | if (macroNamespace == "vendor") { |
576 | 0 | return ExpandMacroResult::Ignore; |
577 | 0 | } |
578 | | |
579 | 0 | return ExpandMacroResult::Error; |
580 | 0 | } |
581 | | |
582 | | namespace { |
583 | | template <typename T> |
584 | | bool SetupWorkflowConfigurePreset(T const& preset, |
585 | | ConfigurePreset const*& configurePreset, |
586 | | cmJSONState* state) |
587 | 0 | { |
588 | 0 | if (preset.ConfigurePreset != configurePreset->Name) { |
589 | 0 | cmCMakePresetsErrors::INVALID_WORKFLOW_STEPS(configurePreset->Name, state); |
590 | 0 | return false; |
591 | 0 | } |
592 | 0 | return true; |
593 | 0 | } Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::SetupWorkflowConfigurePreset<cmCMakePresetsGraph::BuildPreset>(cmCMakePresetsGraph::BuildPreset const&, cmCMakePresetsGraph::ConfigurePreset const*&, cmJSONState*) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::SetupWorkflowConfigurePreset<cmCMakePresetsGraph::TestPreset>(cmCMakePresetsGraph::TestPreset const&, cmCMakePresetsGraph::ConfigurePreset const*&, cmJSONState*) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::SetupWorkflowConfigurePreset<cmCMakePresetsGraph::PackagePreset>(cmCMakePresetsGraph::PackagePreset const&, cmCMakePresetsGraph::ConfigurePreset const*&, cmJSONState*) |
594 | | |
595 | | template <> |
596 | | bool SetupWorkflowConfigurePreset<ConfigurePreset>( |
597 | | ConfigurePreset const& preset, ConfigurePreset const*& configurePreset, |
598 | | cmJSONState*) |
599 | 0 | { |
600 | 0 | configurePreset = &preset; |
601 | 0 | return true; |
602 | 0 | } |
603 | | |
604 | | template <typename T> |
605 | | bool TryReachPresetFromWorkflow( |
606 | | WorkflowPreset const& origin, |
607 | | std::map<std::string, PresetPair<T>> const& presets, std::string const& name, |
608 | | ConfigurePreset const*& configurePreset, cmJSONState* state) |
609 | 0 | { |
610 | 0 | auto it = presets.find(name); |
611 | 0 | if (it == presets.end()) { |
612 | 0 | cmCMakePresetsErrors::INVALID_WORKFLOW_STEPS(name, state); |
613 | 0 | return false; |
614 | 0 | } |
615 | 0 | if (!origin.OriginFile->ReachableFiles.count( |
616 | 0 | it->second.Unexpanded.OriginFile)) { |
617 | 0 | cmCMakePresetsErrors::WORKFLOW_STEP_UNREACHABLE_FROM_FILE(name, state); |
618 | 0 | return false; |
619 | 0 | } |
620 | 0 | return SetupWorkflowConfigurePreset<T>(it->second.Unexpanded, |
621 | 0 | configurePreset, state); |
622 | 0 | } Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::TryReachPresetFromWorkflow<cmCMakePresetsGraph::ConfigurePreset>(cmCMakePresetsGraph::WorkflowPreset const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::ConfigurePreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::ConfigurePreset> > > > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cmCMakePresetsGraph::ConfigurePreset const*&, cmJSONState*) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::TryReachPresetFromWorkflow<cmCMakePresetsGraph::BuildPreset>(cmCMakePresetsGraph::WorkflowPreset const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::BuildPreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::BuildPreset> > > > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cmCMakePresetsGraph::ConfigurePreset const*&, cmJSONState*) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::TryReachPresetFromWorkflow<cmCMakePresetsGraph::TestPreset>(cmCMakePresetsGraph::WorkflowPreset const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::TestPreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::TestPreset> > > > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cmCMakePresetsGraph::ConfigurePreset const*&, cmJSONState*) Unexecuted instantiation: cmCMakePresetsGraph.cxx:bool (anonymous namespace)::TryReachPresetFromWorkflow<cmCMakePresetsGraph::PackagePreset>(cmCMakePresetsGraph::WorkflowPreset const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::PackagePreset>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, cmCMakePresetsGraph::PresetPair<cmCMakePresetsGraph::PackagePreset> > > > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cmCMakePresetsGraph::ConfigurePreset const*&, cmJSONState*) |
623 | | } |
624 | | |
625 | | ExpandMacroResult BaseMacroExpander::operator()( |
626 | | std::string const& macroNamespace, std::string const& macroName, |
627 | | std::string& macroOut, int version) const |
628 | 0 | { |
629 | 0 | if (macroNamespace.empty()) { |
630 | 0 | if (macroName == "sourceDir") { |
631 | 0 | macroOut += Graph.SourceDir; |
632 | 0 | return ExpandMacroResult::Ok; |
633 | 0 | } |
634 | 0 | if (macroName == "sourceParentDir") { |
635 | 0 | macroOut += cmSystemTools::GetParentDirectory(Graph.SourceDir); |
636 | 0 | return ExpandMacroResult::Ok; |
637 | 0 | } |
638 | 0 | if (macroName == "sourceDirName") { |
639 | 0 | macroOut += cmSystemTools::GetFilenameName(Graph.SourceDir); |
640 | 0 | return ExpandMacroResult::Ok; |
641 | 0 | } |
642 | 0 | if (macroName == "dollar") { |
643 | 0 | macroOut += '$'; |
644 | 0 | return ExpandMacroResult::Ok; |
645 | 0 | } |
646 | 0 | if (macroName == "hostSystemName") { |
647 | 0 | if (version < 3) { |
648 | 0 | return ExpandMacroResult::Error; |
649 | 0 | } |
650 | 0 | macroOut += cmSystemTools::GetSystemName(); |
651 | 0 | return ExpandMacroResult::Ok; |
652 | 0 | } |
653 | | // Enable fileDir macro expansion for non-preset expanders |
654 | 0 | if (macroName == "fileDir" && File) { |
655 | 0 | if (version < 4) { |
656 | 0 | return ExpandMacroResult::Error; |
657 | 0 | } |
658 | 0 | macroOut += cmSystemTools::GetParentDirectory(File.value()); |
659 | 0 | return ExpandMacroResult::Ok; |
660 | 0 | } |
661 | 0 | if (macroName == "pathListSep") { |
662 | 0 | if (version < 5) { |
663 | 0 | return ExpandMacroResult::Error; |
664 | 0 | } |
665 | 0 | macroOut += cmSystemTools::GetSystemPathlistSeparator(); |
666 | 0 | return ExpandMacroResult::Ok; |
667 | 0 | } |
668 | 0 | } |
669 | | |
670 | 0 | return ExpandMacroResult::Ignore; |
671 | 0 | } |
672 | | |
673 | | bool cmCMakePresetsGraphInternal::EqualsCondition::Evaluate( |
674 | | MacroExpanderVector const& expanders, int version, |
675 | | cm::optional<bool>& out) const |
676 | 0 | { |
677 | 0 | std::string lhs = this->Lhs; |
678 | 0 | CHECK_EXPAND(out, lhs, expanders, version); |
679 | | |
680 | 0 | std::string rhs = this->Rhs; |
681 | 0 | CHECK_EXPAND(out, rhs, expanders, version); |
682 | | |
683 | 0 | out = (lhs == rhs); |
684 | 0 | return true; |
685 | 0 | } |
686 | | |
687 | | bool cmCMakePresetsGraphInternal::InListCondition::Evaluate( |
688 | | MacroExpanderVector const& expanders, int version, |
689 | | cm::optional<bool>& out) const |
690 | 0 | { |
691 | 0 | std::string str = this->String; |
692 | 0 | CHECK_EXPAND(out, str, expanders, version); |
693 | | |
694 | 0 | for (auto item : this->List) { |
695 | 0 | CHECK_EXPAND(out, item, expanders, version); |
696 | 0 | if (str == item) { |
697 | 0 | out = true; |
698 | 0 | return true; |
699 | 0 | } |
700 | 0 | } |
701 | | |
702 | 0 | out = false; |
703 | 0 | return true; |
704 | 0 | } |
705 | | |
706 | | bool cmCMakePresetsGraphInternal::MatchesCondition::Evaluate( |
707 | | MacroExpanderVector const& expanders, int version, |
708 | | cm::optional<bool>& out) const |
709 | 0 | { |
710 | 0 | std::string str = this->String; |
711 | 0 | CHECK_EXPAND(out, str, expanders, version); |
712 | 0 | std::string regexStr = this->Regex; |
713 | 0 | CHECK_EXPAND(out, regexStr, expanders, version); |
714 | | |
715 | 0 | cmsys::RegularExpression regex; |
716 | 0 | if (!regex.compile(regexStr)) { |
717 | 0 | return false; |
718 | 0 | } |
719 | | |
720 | 0 | out = regex.find(str); |
721 | 0 | return true; |
722 | 0 | } |
723 | | |
724 | | bool cmCMakePresetsGraphInternal::AnyAllOfCondition::Evaluate( |
725 | | MacroExpanderVector const& expanders, int version, |
726 | | cm::optional<bool>& out) const |
727 | 0 | { |
728 | 0 | for (auto const& condition : this->Conditions) { |
729 | 0 | cm::optional<bool> result; |
730 | 0 | if (!condition->Evaluate(expanders, version, result)) { |
731 | 0 | out.reset(); |
732 | 0 | return false; |
733 | 0 | } |
734 | | |
735 | 0 | if (!result) { |
736 | 0 | out.reset(); |
737 | 0 | return true; |
738 | 0 | } |
739 | | |
740 | 0 | if (result == this->StopValue) { |
741 | 0 | out = result; |
742 | 0 | return true; |
743 | 0 | } |
744 | 0 | } |
745 | | |
746 | 0 | out = !this->StopValue; |
747 | 0 | return true; |
748 | 0 | } |
749 | | |
750 | | bool cmCMakePresetsGraphInternal::NotCondition::Evaluate( |
751 | | MacroExpanderVector const& expanders, int version, |
752 | | cm::optional<bool>& out) const |
753 | 0 | { |
754 | 0 | out.reset(); |
755 | 0 | if (!this->SubCondition->Evaluate(expanders, version, out)) { |
756 | 0 | out.reset(); |
757 | 0 | return false; |
758 | 0 | } |
759 | 0 | if (out) { |
760 | 0 | *out = !*out; |
761 | 0 | } |
762 | 0 | return true; |
763 | 0 | } |
764 | | |
765 | | bool cmCMakePresetsGraph::ConfigurePreset::VisitPresetInherit( |
766 | | cmCMakePresetsGraph::Preset const& parentPreset) |
767 | 0 | { |
768 | 0 | auto& preset = *this; |
769 | 0 | ConfigurePreset const& parent = |
770 | 0 | static_cast<ConfigurePreset const&>(parentPreset); |
771 | 0 | InheritString(preset.Generator, parent.Generator); |
772 | 0 | InheritString(preset.Architecture, parent.Architecture); |
773 | 0 | InheritString(preset.Toolset, parent.Toolset); |
774 | 0 | if (!preset.ArchitectureStrategy) { |
775 | 0 | preset.ArchitectureStrategy = parent.ArchitectureStrategy; |
776 | 0 | } |
777 | 0 | if (!preset.ToolsetStrategy) { |
778 | 0 | preset.ToolsetStrategy = parent.ToolsetStrategy; |
779 | 0 | } |
780 | 0 | InheritString(preset.BinaryDir, parent.BinaryDir); |
781 | 0 | InheritString(preset.InstallDir, parent.InstallDir); |
782 | 0 | InheritString(preset.ToolchainFile, parent.ToolchainFile); |
783 | 0 | InheritString(preset.GraphVizFile, parent.GraphVizFile); |
784 | 0 | InheritOptionalValue(preset.WarnDev, parent.WarnDev); |
785 | 0 | InheritOptionalValue(preset.ErrorDev, parent.ErrorDev); |
786 | 0 | InheritOptionalValue(preset.WarnDeprecated, parent.WarnDeprecated); |
787 | 0 | InheritOptionalValue(preset.ErrorDeprecated, parent.ErrorDeprecated); |
788 | 0 | InheritOptionalValue(preset.WarnUninitialized, parent.WarnUninitialized); |
789 | 0 | InheritOptionalValue(preset.WarnUnusedCli, parent.WarnUnusedCli); |
790 | 0 | InheritOptionalValue(preset.WarnSystemVars, parent.WarnSystemVars); |
791 | |
|
792 | 0 | for (auto const& v : parent.CacheVariables) { |
793 | 0 | preset.CacheVariables.insert(v); |
794 | 0 | } |
795 | |
|
796 | 0 | return true; |
797 | 0 | } |
798 | | |
799 | | bool cmCMakePresetsGraph::ConfigurePreset::VisitPresetBeforeInherit() |
800 | 0 | { |
801 | 0 | auto& preset = *this; |
802 | 0 | if (preset.Environment.count("") != 0) { |
803 | 0 | return false; |
804 | 0 | } |
805 | | |
806 | 0 | return true; |
807 | 0 | } |
808 | | |
809 | | bool cmCMakePresetsGraph::ConfigurePreset::VisitPresetAfterInherit( |
810 | | int version, cmJSONState* state) |
811 | 0 | { |
812 | 0 | auto& preset = *this; |
813 | 0 | if (!preset.Hidden) { |
814 | 0 | if (version < 3) { |
815 | 0 | if (preset.Generator.empty()) { |
816 | 0 | cmCMakePresetsErrors::PRESET_MISSING_FIELD(preset.Name, "generator", |
817 | 0 | state); |
818 | 0 | return false; |
819 | 0 | } |
820 | 0 | if (preset.BinaryDir.empty()) { |
821 | 0 | cmCMakePresetsErrors::PRESET_MISSING_FIELD(preset.Name, "binaryDir", |
822 | 0 | state); |
823 | 0 | return false; |
824 | 0 | } |
825 | 0 | } |
826 | | |
827 | 0 | if (preset.WarnDev == false && preset.ErrorDev == true) { |
828 | 0 | return false; |
829 | 0 | } |
830 | 0 | if (preset.WarnDeprecated == false && preset.ErrorDeprecated == true) { |
831 | 0 | return false; |
832 | 0 | } |
833 | 0 | if (preset.CacheVariables.count("") != 0) { |
834 | 0 | return false; |
835 | 0 | } |
836 | 0 | } |
837 | | |
838 | 0 | return true; |
839 | 0 | } |
840 | | |
841 | | bool cmCMakePresetsGraph::BuildPreset::VisitPresetInherit( |
842 | | cmCMakePresetsGraph::Preset const& parentPreset) |
843 | 0 | { |
844 | 0 | auto& preset = *this; |
845 | 0 | BuildPreset const& parent = static_cast<BuildPreset const&>(parentPreset); |
846 | |
|
847 | 0 | InheritString(preset.ConfigurePreset, parent.ConfigurePreset); |
848 | 0 | InheritOptionalValue(preset.InheritConfigureEnvironment, |
849 | 0 | parent.InheritConfigureEnvironment); |
850 | 0 | InheritOptionalValue(preset.Jobs, parent.Jobs); |
851 | 0 | InheritVector(preset.Targets, parent.Targets); |
852 | 0 | InheritString(preset.Configuration, parent.Configuration); |
853 | 0 | InheritOptionalValue(preset.CleanFirst, parent.CleanFirst); |
854 | 0 | InheritOptionalValue(preset.Verbose, parent.Verbose); |
855 | 0 | InheritVector(preset.NativeToolOptions, parent.NativeToolOptions); |
856 | 0 | if (!preset.ResolvePackageReferences) { |
857 | 0 | preset.ResolvePackageReferences = parent.ResolvePackageReferences; |
858 | 0 | } |
859 | |
|
860 | 0 | return true; |
861 | 0 | } |
862 | | |
863 | | bool cmCMakePresetsGraph::BuildPreset::VisitPresetAfterInherit( |
864 | | int /* version */, cmJSONState* /*stat*/) |
865 | 0 | { |
866 | 0 | auto& preset = *this; |
867 | 0 | if (!preset.Hidden && preset.ConfigurePreset.empty()) { |
868 | 0 | return false; |
869 | 0 | } |
870 | 0 | return true; |
871 | 0 | } |
872 | | |
873 | | bool cmCMakePresetsGraph::TestPreset::VisitPresetInherit( |
874 | | cmCMakePresetsGraph::Preset const& parentPreset) |
875 | 0 | { |
876 | 0 | auto& preset = *this; |
877 | 0 | TestPreset const& parent = static_cast<TestPreset const&>(parentPreset); |
878 | |
|
879 | 0 | InheritString(preset.ConfigurePreset, parent.ConfigurePreset); |
880 | 0 | InheritOptionalValue(preset.InheritConfigureEnvironment, |
881 | 0 | parent.InheritConfigureEnvironment); |
882 | 0 | InheritString(preset.Configuration, parent.Configuration); |
883 | 0 | InheritVector(preset.OverwriteConfigurationFile, |
884 | 0 | parent.OverwriteConfigurationFile); |
885 | |
|
886 | 0 | if (parent.Output) { |
887 | 0 | if (preset.Output) { |
888 | 0 | auto& output = preset.Output.value(); |
889 | 0 | auto const& parentOutput = parent.Output.value(); |
890 | 0 | InheritOptionalValue(output.ShortProgress, parentOutput.ShortProgress); |
891 | 0 | InheritOptionalValue(output.Verbosity, parentOutput.Verbosity); |
892 | 0 | InheritOptionalValue(output.Debug, parentOutput.Debug); |
893 | 0 | InheritOptionalValue(output.OutputOnFailure, |
894 | 0 | parentOutput.OutputOnFailure); |
895 | 0 | InheritOptionalValue(output.Quiet, parentOutput.Quiet); |
896 | 0 | InheritString(output.OutputLogFile, parentOutput.OutputLogFile); |
897 | 0 | InheritString(output.OutputJUnitFile, parentOutput.OutputJUnitFile); |
898 | 0 | InheritOptionalValue(output.LabelSummary, parentOutput.LabelSummary); |
899 | 0 | InheritOptionalValue(output.SubprojectSummary, |
900 | 0 | parentOutput.SubprojectSummary); |
901 | 0 | InheritOptionalValue(output.MaxPassedTestOutputSize, |
902 | 0 | parentOutput.MaxPassedTestOutputSize); |
903 | 0 | InheritOptionalValue(output.MaxFailedTestOutputSize, |
904 | 0 | parentOutput.MaxFailedTestOutputSize); |
905 | 0 | InheritOptionalValue(output.TestOutputTruncation, |
906 | 0 | parentOutput.TestOutputTruncation); |
907 | 0 | InheritOptionalValue(output.MaxTestNameWidth, |
908 | 0 | parentOutput.MaxTestNameWidth); |
909 | 0 | } else { |
910 | 0 | preset.Output = parent.Output; |
911 | 0 | } |
912 | 0 | } |
913 | |
|
914 | 0 | if (parent.Filter) { |
915 | 0 | if (parent.Filter->Include) { |
916 | 0 | if (preset.Filter && preset.Filter->Include) { |
917 | 0 | auto& include = *preset.Filter->Include; |
918 | 0 | auto const& parentInclude = *parent.Filter->Include; |
919 | 0 | InheritString(include.Name, parentInclude.Name); |
920 | 0 | InheritString(include.Label, parentInclude.Label); |
921 | 0 | InheritOptionalValue(include.Index, parentInclude.Index); |
922 | 0 | } else { |
923 | 0 | if (!preset.Filter) { |
924 | 0 | preset.Filter.emplace(); |
925 | 0 | } |
926 | 0 | preset.Filter->Include = parent.Filter->Include; |
927 | 0 | } |
928 | 0 | } |
929 | |
|
930 | 0 | if (parent.Filter->Exclude) { |
931 | 0 | if (preset.Filter && preset.Filter->Exclude) { |
932 | 0 | auto& exclude = *preset.Filter->Exclude; |
933 | 0 | auto const& parentExclude = *parent.Filter->Exclude; |
934 | 0 | InheritString(exclude.Name, parentExclude.Name); |
935 | 0 | InheritString(exclude.Label, parentExclude.Label); |
936 | 0 | InheritOptionalValue(exclude.Fixtures, parentExclude.Fixtures); |
937 | 0 | } else { |
938 | 0 | if (!preset.Filter) { |
939 | 0 | preset.Filter.emplace(); |
940 | 0 | } |
941 | 0 | preset.Filter->Exclude = parent.Filter->Exclude; |
942 | 0 | } |
943 | 0 | } |
944 | 0 | } |
945 | |
|
946 | 0 | if (parent.Execution) { |
947 | 0 | if (preset.Execution) { |
948 | 0 | auto& execution = *preset.Execution; |
949 | 0 | auto const& parentExecution = *parent.Execution; |
950 | 0 | InheritOptionalValue(execution.StopOnFailure, |
951 | 0 | parentExecution.StopOnFailure); |
952 | 0 | InheritOptionalValue(execution.EnableFailover, |
953 | 0 | parentExecution.EnableFailover); |
954 | 0 | InheritOptionalValue(execution.Jobs, parentExecution.Jobs); |
955 | 0 | InheritString(execution.ResourceSpecFile, |
956 | 0 | parentExecution.ResourceSpecFile); |
957 | 0 | InheritOptionalValue(execution.TestLoad, parentExecution.TestLoad); |
958 | 0 | InheritOptionalValue(execution.ShowOnly, parentExecution.ShowOnly); |
959 | 0 | InheritOptionalValue(execution.Repeat, parentExecution.Repeat); |
960 | 0 | InheritOptionalValue(execution.InteractiveDebugging, |
961 | 0 | parentExecution.InteractiveDebugging); |
962 | 0 | InheritOptionalValue(execution.ScheduleRandom, |
963 | 0 | parentExecution.ScheduleRandom); |
964 | 0 | InheritOptionalValue(execution.Timeout, parentExecution.Timeout); |
965 | 0 | InheritOptionalValue(execution.NoTestsAction, |
966 | 0 | parentExecution.NoTestsAction); |
967 | 0 | } else { |
968 | 0 | preset.Execution = parent.Execution; |
969 | 0 | } |
970 | 0 | } |
971 | |
|
972 | 0 | return true; |
973 | 0 | } |
974 | | |
975 | | bool cmCMakePresetsGraph::TestPreset::VisitPresetAfterInherit( |
976 | | int /* version */, cmJSONState* /*state*/) |
977 | 0 | { |
978 | 0 | auto& preset = *this; |
979 | 0 | if (!preset.Hidden && preset.ConfigurePreset.empty()) { |
980 | 0 | return false; |
981 | 0 | } |
982 | 0 | return true; |
983 | 0 | } |
984 | | |
985 | | bool cmCMakePresetsGraph::PackagePreset::VisitPresetInherit( |
986 | | cmCMakePresetsGraph::Preset const& parentPreset) |
987 | 0 | { |
988 | 0 | auto& preset = *this; |
989 | 0 | PackagePreset const& parent = |
990 | 0 | static_cast<PackagePreset const&>(parentPreset); |
991 | |
|
992 | 0 | InheritString(preset.ConfigurePreset, parent.ConfigurePreset); |
993 | 0 | InheritOptionalValue(preset.InheritConfigureEnvironment, |
994 | 0 | parent.InheritConfigureEnvironment); |
995 | 0 | InheritVector(preset.Generators, parent.Generators); |
996 | 0 | InheritVector(preset.Configurations, parent.Configurations); |
997 | |
|
998 | 0 | for (auto const& v : parent.Variables) { |
999 | 0 | preset.Variables.insert(v); |
1000 | 0 | } |
1001 | |
|
1002 | 0 | InheritOptionalValue(preset.DebugOutput, parent.DebugOutput); |
1003 | 0 | InheritOptionalValue(preset.VerboseOutput, parent.VerboseOutput); |
1004 | 0 | InheritString(preset.PackageName, parent.PackageName); |
1005 | 0 | InheritString(preset.PackageVersion, parent.PackageVersion); |
1006 | 0 | InheritString(preset.PackageDirectory, parent.PackageDirectory); |
1007 | 0 | InheritString(preset.VendorName, parent.VendorName); |
1008 | |
|
1009 | 0 | return true; |
1010 | 0 | } |
1011 | | |
1012 | | bool cmCMakePresetsGraph::PackagePreset::VisitPresetAfterInherit( |
1013 | | int /* version */, cmJSONState* /*state*/) |
1014 | 0 | { |
1015 | 0 | auto& preset = *this; |
1016 | 0 | if (!preset.Hidden && preset.ConfigurePreset.empty()) { |
1017 | 0 | return false; |
1018 | 0 | } |
1019 | 0 | return true; |
1020 | 0 | } |
1021 | | |
1022 | | bool cmCMakePresetsGraph::WorkflowPreset::VisitPresetInherit( |
1023 | | cmCMakePresetsGraph::Preset const& /*parentPreset*/) |
1024 | 0 | { |
1025 | 0 | return true; |
1026 | 0 | } |
1027 | | |
1028 | | bool cmCMakePresetsGraph::WorkflowPreset::VisitPresetAfterInherit( |
1029 | | int /* version */, cmJSONState* /*state*/) |
1030 | 0 | { |
1031 | 0 | return true; |
1032 | 0 | } |
1033 | | |
1034 | | std::string cmCMakePresetsGraph::GetFilename(std::string const& sourceDir) |
1035 | 0 | { |
1036 | 0 | return cmStrCat(sourceDir, "/CMakePresets.json"); |
1037 | 0 | } |
1038 | | |
1039 | | std::string cmCMakePresetsGraph::GetUserFilename(std::string const& sourceDir) |
1040 | 0 | { |
1041 | 0 | return cmStrCat(sourceDir, "/CMakeUserPresets.json"); |
1042 | 0 | } |
1043 | | |
1044 | | bool cmCMakePresetsGraph::ReadProjectPresets(std::string const& sourceDir, |
1045 | | bool allowNoFiles) |
1046 | 0 | { |
1047 | 0 | this->SourceDir = sourceDir; |
1048 | 0 | this->ClearPresets(); |
1049 | |
|
1050 | 0 | if (!this->ReadProjectPresetsInternal(allowNoFiles)) { |
1051 | 0 | this->ClearPresets(); |
1052 | 0 | return false; |
1053 | 0 | } |
1054 | | |
1055 | 0 | return true; |
1056 | 0 | } |
1057 | | |
1058 | | bool cmCMakePresetsGraph::ReadProjectPresetsInternal(bool allowNoFiles) |
1059 | 0 | { |
1060 | 0 | bool haveOneFile = false; |
1061 | |
|
1062 | 0 | File* file; |
1063 | 0 | std::string filename = GetUserFilename(this->SourceDir); |
1064 | 0 | std::vector<File*> inProgressFiles; |
1065 | 0 | if (cmSystemTools::FileExists(filename)) { |
1066 | 0 | if (!this->ReadJSONFile(filename, RootType::User, ReadReason::Root, |
1067 | 0 | inProgressFiles, file, this->errors)) { |
1068 | 0 | return false; |
1069 | 0 | } |
1070 | 0 | haveOneFile = true; |
1071 | 0 | } else { |
1072 | 0 | filename = GetFilename(this->SourceDir); |
1073 | 0 | if (cmSystemTools::FileExists(filename)) { |
1074 | 0 | if (!this->ReadJSONFile(filename, RootType::Project, ReadReason::Root, |
1075 | 0 | inProgressFiles, file, this->errors)) { |
1076 | 0 | return false; |
1077 | 0 | } |
1078 | 0 | haveOneFile = true; |
1079 | 0 | } |
1080 | 0 | } |
1081 | 0 | assert(inProgressFiles.empty()); |
1082 | |
|
1083 | 0 | if (!haveOneFile) { |
1084 | 0 | if (allowNoFiles) { |
1085 | 0 | return true; |
1086 | 0 | } |
1087 | 0 | cmCMakePresetsErrors::FILE_NOT_FOUND(filename, &this->parseState); |
1088 | 0 | return false; |
1089 | 0 | } |
1090 | | |
1091 | 0 | bool result = ComputePresetInheritance(this->ConfigurePresets, *this) && |
1092 | 0 | ComputePresetInheritance(this->BuildPresets, *this) && |
1093 | 0 | ComputePresetInheritance(this->TestPresets, *this) && |
1094 | 0 | ComputePresetInheritance(this->PackagePresets, *this) && |
1095 | 0 | ComputePresetInheritance(this->WorkflowPresets, *this); |
1096 | 0 | if (!result) { |
1097 | 0 | return false; |
1098 | 0 | } |
1099 | | |
1100 | 0 | for (auto& it : this->ConfigurePresets) { |
1101 | 0 | if (!ExpandMacros(*this, it.second.Unexpanded, it.second.Expanded)) { |
1102 | 0 | cmCMakePresetsErrors::INVALID_MACRO_EXPANSION(it.first, |
1103 | 0 | &this->parseState); |
1104 | 0 | return false; |
1105 | 0 | } |
1106 | 0 | } |
1107 | | |
1108 | 0 | for (auto& it : this->BuildPresets) { |
1109 | 0 | if (!it.second.Unexpanded.Hidden) { |
1110 | 0 | auto const configurePreset = |
1111 | 0 | this->ConfigurePresets.find(it.second.Unexpanded.ConfigurePreset); |
1112 | 0 | if (configurePreset == this->ConfigurePresets.end()) { |
1113 | 0 | cmCMakePresetsErrors::INVALID_CONFIGURE_PRESET(it.first, |
1114 | 0 | &this->parseState); |
1115 | 0 | return false; |
1116 | 0 | } |
1117 | 0 | if (!it.second.Unexpanded.OriginFile->ReachableFiles.count( |
1118 | 0 | configurePreset->second.Unexpanded.OriginFile)) { |
1119 | 0 | cmCMakePresetsErrors::CONFIGURE_PRESET_UNREACHABLE_FROM_FILE( |
1120 | 0 | it.first, &this->parseState); |
1121 | 0 | return false; |
1122 | 0 | } |
1123 | | |
1124 | 0 | if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true)) { |
1125 | 0 | it.second.Unexpanded.Environment.insert( |
1126 | 0 | configurePreset->second.Unexpanded.Environment.begin(), |
1127 | 0 | configurePreset->second.Unexpanded.Environment.end()); |
1128 | 0 | } |
1129 | 0 | } |
1130 | | |
1131 | 0 | if (!ExpandMacros(*this, it.second.Unexpanded, it.second.Expanded)) { |
1132 | 0 | cmCMakePresetsErrors::INVALID_MACRO_EXPANSION(it.first, |
1133 | 0 | &this->parseState); |
1134 | 0 | return false; |
1135 | 0 | } |
1136 | 0 | } |
1137 | | |
1138 | 0 | for (auto& it : this->TestPresets) { |
1139 | 0 | if (!it.second.Unexpanded.Hidden) { |
1140 | 0 | auto const configurePreset = |
1141 | 0 | this->ConfigurePresets.find(it.second.Unexpanded.ConfigurePreset); |
1142 | 0 | if (configurePreset == this->ConfigurePresets.end()) { |
1143 | 0 | cmCMakePresetsErrors::INVALID_CONFIGURE_PRESET(it.first, |
1144 | 0 | &this->parseState); |
1145 | 0 | return false; |
1146 | 0 | } |
1147 | 0 | if (!it.second.Unexpanded.OriginFile->ReachableFiles.count( |
1148 | 0 | configurePreset->second.Unexpanded.OriginFile)) { |
1149 | 0 | cmCMakePresetsErrors::CONFIGURE_PRESET_UNREACHABLE_FROM_FILE( |
1150 | 0 | it.first, &this->parseState); |
1151 | 0 | return false; |
1152 | 0 | } |
1153 | | |
1154 | 0 | if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true)) { |
1155 | 0 | it.second.Unexpanded.Environment.insert( |
1156 | 0 | configurePreset->second.Unexpanded.Environment.begin(), |
1157 | 0 | configurePreset->second.Unexpanded.Environment.end()); |
1158 | 0 | } |
1159 | 0 | } |
1160 | | |
1161 | 0 | if (!ExpandMacros(*this, it.second.Unexpanded, it.second.Expanded)) { |
1162 | 0 | cmCMakePresetsErrors::INVALID_MACRO_EXPANSION(it.first, |
1163 | 0 | &this->parseState); |
1164 | 0 | return false; |
1165 | 0 | } |
1166 | 0 | } |
1167 | | |
1168 | 0 | for (auto& it : this->PackagePresets) { |
1169 | 0 | if (!it.second.Unexpanded.Hidden) { |
1170 | 0 | auto const configurePreset = |
1171 | 0 | this->ConfigurePresets.find(it.second.Unexpanded.ConfigurePreset); |
1172 | 0 | if (configurePreset == this->ConfigurePresets.end()) { |
1173 | 0 | cmCMakePresetsErrors::INVALID_CONFIGURE_PRESET(it.first, |
1174 | 0 | &this->parseState); |
1175 | 0 | return false; |
1176 | 0 | } |
1177 | 0 | if (!it.second.Unexpanded.OriginFile->ReachableFiles.count( |
1178 | 0 | configurePreset->second.Unexpanded.OriginFile)) { |
1179 | 0 | cmCMakePresetsErrors::CONFIGURE_PRESET_UNREACHABLE_FROM_FILE( |
1180 | 0 | it.first, &this->parseState); |
1181 | 0 | return false; |
1182 | 0 | } |
1183 | | |
1184 | 0 | if (it.second.Unexpanded.InheritConfigureEnvironment.value_or(true)) { |
1185 | 0 | it.second.Unexpanded.Environment.insert( |
1186 | 0 | configurePreset->second.Unexpanded.Environment.begin(), |
1187 | 0 | configurePreset->second.Unexpanded.Environment.end()); |
1188 | 0 | } |
1189 | 0 | } |
1190 | | |
1191 | 0 | if (!ExpandMacros(*this, it.second.Unexpanded, it.second.Expanded)) { |
1192 | 0 | cmCMakePresetsErrors::INVALID_MACRO_EXPANSION(it.first, |
1193 | 0 | &this->parseState); |
1194 | 0 | return false; |
1195 | 0 | } |
1196 | 0 | } |
1197 | | |
1198 | 0 | for (auto& it : this->WorkflowPresets) { |
1199 | 0 | using Type = WorkflowPreset::WorkflowStep::Type; |
1200 | |
|
1201 | 0 | ConfigurePreset const* configurePreset = nullptr; |
1202 | 0 | for (auto const& step : it.second.Unexpanded.Steps) { |
1203 | 0 | if (!configurePreset && step.PresetType != Type::Configure) { |
1204 | 0 | cmCMakePresetsErrors::FIRST_WORKFLOW_STEP_NOT_CONFIGURE( |
1205 | 0 | step.PresetName, &this->parseState); |
1206 | 0 | return false; |
1207 | 0 | } |
1208 | 0 | if (configurePreset && step.PresetType == Type::Configure) { |
1209 | 0 | cmCMakePresetsErrors::CONFIGURE_WORKFLOW_STEP_NOT_FIRST( |
1210 | 0 | step.PresetName, &this->parseState); |
1211 | 0 | return false; |
1212 | 0 | } |
1213 | | |
1214 | 0 | switch (step.PresetType) { |
1215 | 0 | case Type::Configure: |
1216 | 0 | result = TryReachPresetFromWorkflow( |
1217 | 0 | it.second.Unexpanded, this->ConfigurePresets, step.PresetName, |
1218 | 0 | configurePreset, &this->parseState); |
1219 | 0 | break; |
1220 | 0 | case Type::Build: |
1221 | 0 | result = TryReachPresetFromWorkflow( |
1222 | 0 | it.second.Unexpanded, this->BuildPresets, step.PresetName, |
1223 | 0 | configurePreset, &this->parseState); |
1224 | 0 | break; |
1225 | 0 | case Type::Test: |
1226 | 0 | result = TryReachPresetFromWorkflow( |
1227 | 0 | it.second.Unexpanded, this->TestPresets, step.PresetName, |
1228 | 0 | configurePreset, &this->parseState); |
1229 | 0 | break; |
1230 | 0 | case Type::Package: |
1231 | 0 | result = TryReachPresetFromWorkflow( |
1232 | 0 | it.second.Unexpanded, this->PackagePresets, step.PresetName, |
1233 | 0 | configurePreset, &this->parseState); |
1234 | 0 | break; |
1235 | 0 | } |
1236 | 0 | if (!result) { |
1237 | 0 | return false; |
1238 | 0 | } |
1239 | 0 | } |
1240 | | |
1241 | 0 | if (!configurePreset) { |
1242 | 0 | cmCMakePresetsErrors::NO_WORKFLOW_STEPS(it.first, &this->parseState); |
1243 | 0 | return false; |
1244 | 0 | } |
1245 | | |
1246 | 0 | if (!ExpandMacros(*this, it.second.Unexpanded, it.second.Expanded)) { |
1247 | 0 | cmCMakePresetsErrors::INVALID_MACRO_EXPANSION(it.first, |
1248 | 0 | &this->parseState); |
1249 | 0 | return false; |
1250 | 0 | } |
1251 | 0 | } |
1252 | | |
1253 | 0 | return true; |
1254 | 0 | } |
1255 | | |
1256 | | void cmCMakePresetsGraph::ClearPresets() |
1257 | 0 | { |
1258 | 0 | this->ConfigurePresets.clear(); |
1259 | 0 | this->BuildPresets.clear(); |
1260 | 0 | this->TestPresets.clear(); |
1261 | 0 | this->PackagePresets.clear(); |
1262 | 0 | this->WorkflowPresets.clear(); |
1263 | |
|
1264 | 0 | this->ConfigurePresetOrder.clear(); |
1265 | 0 | this->BuildPresetOrder.clear(); |
1266 | 0 | this->TestPresetOrder.clear(); |
1267 | 0 | this->PackagePresetOrder.clear(); |
1268 | 0 | this->WorkflowPresetOrder.clear(); |
1269 | |
|
1270 | 0 | this->Files.clear(); |
1271 | 0 | } |
1272 | | |
1273 | | void cmCMakePresetsGraph::printPrecedingNewline(PrintPrecedingNewline* newline) |
1274 | 0 | { |
1275 | 0 | if (newline) { |
1276 | 0 | if (*newline == PrintPrecedingNewline::True) { |
1277 | 0 | std::cout << std::endl; |
1278 | 0 | } |
1279 | 0 | *newline = PrintPrecedingNewline::True; |
1280 | 0 | } |
1281 | 0 | } |
1282 | | |
1283 | | void cmCMakePresetsGraph::PrintPresets( |
1284 | | std::vector<cmCMakePresetsGraph::Preset const*> const& presets) |
1285 | 0 | { |
1286 | 0 | if (presets.empty()) { |
1287 | 0 | return; |
1288 | 0 | } |
1289 | | |
1290 | 0 | auto longestPresetName = |
1291 | 0 | std::max_element(presets.begin(), presets.end(), |
1292 | 0 | [](cmCMakePresetsGraph::Preset const* a, |
1293 | 0 | cmCMakePresetsGraph::Preset const* b) { |
1294 | 0 | return a->Name.length() < b->Name.length(); |
1295 | 0 | }); |
1296 | 0 | auto longestLength = (*longestPresetName)->Name.length(); |
1297 | |
|
1298 | 0 | for (auto const* preset : presets) { |
1299 | 0 | std::cout << " \"" << preset->Name << '"'; |
1300 | 0 | auto const& description = preset->DisplayName; |
1301 | 0 | if (!description.empty()) { |
1302 | 0 | for (std::size_t i = 0; i < longestLength - preset->Name.length(); ++i) { |
1303 | 0 | std::cout << ' '; |
1304 | 0 | } |
1305 | 0 | std::cout << " - " << description; |
1306 | 0 | } |
1307 | 0 | std::cout << '\n'; |
1308 | 0 | } |
1309 | 0 | } |
1310 | | |
1311 | | void cmCMakePresetsGraph::PrintConfigurePresetList( |
1312 | | PrintPrecedingNewline* newline) const |
1313 | 0 | { |
1314 | 0 | PrintConfigurePresetList([](ConfigurePreset const&) { return true; }, |
1315 | 0 | newline); |
1316 | 0 | } |
1317 | | |
1318 | | void cmCMakePresetsGraph::PrintConfigurePresetList( |
1319 | | std::function<bool(ConfigurePreset const&)> const& filter, |
1320 | | PrintPrecedingNewline* newline) const |
1321 | 0 | { |
1322 | 0 | std::vector<cmCMakePresetsGraph::Preset const*> presets; |
1323 | 0 | for (auto const& p : this->ConfigurePresetOrder) { |
1324 | 0 | auto const& preset = this->ConfigurePresets.at(p); |
1325 | 0 | if (!preset.Unexpanded.Hidden && preset.Expanded && |
1326 | 0 | preset.Expanded->ConditionResult && filter(preset.Unexpanded)) { |
1327 | 0 | presets.push_back( |
1328 | 0 | static_cast<cmCMakePresetsGraph::Preset const*>(&preset.Unexpanded)); |
1329 | 0 | } |
1330 | 0 | } |
1331 | |
|
1332 | 0 | if (!presets.empty()) { |
1333 | 0 | printPrecedingNewline(newline); |
1334 | 0 | std::cout << "Available configure presets:\n\n"; |
1335 | 0 | cmCMakePresetsGraph::PrintPresets(presets); |
1336 | 0 | } |
1337 | 0 | } |
1338 | | |
1339 | | void cmCMakePresetsGraph::PrintBuildPresetList( |
1340 | | PrintPrecedingNewline* newline) const |
1341 | 0 | { |
1342 | 0 | std::vector<cmCMakePresetsGraph::Preset const*> presets; |
1343 | 0 | for (auto const& p : this->BuildPresetOrder) { |
1344 | 0 | auto const& preset = this->BuildPresets.at(p); |
1345 | 0 | if (!preset.Unexpanded.Hidden && preset.Expanded && |
1346 | 0 | preset.Expanded->ConditionResult) { |
1347 | 0 | presets.push_back( |
1348 | 0 | static_cast<cmCMakePresetsGraph::Preset const*>(&preset.Unexpanded)); |
1349 | 0 | } |
1350 | 0 | } |
1351 | |
|
1352 | 0 | if (!presets.empty()) { |
1353 | 0 | printPrecedingNewline(newline); |
1354 | 0 | std::cout << "Available build presets:\n\n"; |
1355 | 0 | cmCMakePresetsGraph::PrintPresets(presets); |
1356 | 0 | } |
1357 | 0 | } |
1358 | | |
1359 | | void cmCMakePresetsGraph::PrintTestPresetList( |
1360 | | PrintPrecedingNewline* newline) const |
1361 | 0 | { |
1362 | 0 | std::vector<cmCMakePresetsGraph::Preset const*> presets; |
1363 | 0 | for (auto const& p : this->TestPresetOrder) { |
1364 | 0 | auto const& preset = this->TestPresets.at(p); |
1365 | 0 | if (!preset.Unexpanded.Hidden && preset.Expanded && |
1366 | 0 | preset.Expanded->ConditionResult) { |
1367 | 0 | presets.push_back( |
1368 | 0 | static_cast<cmCMakePresetsGraph::Preset const*>(&preset.Unexpanded)); |
1369 | 0 | } |
1370 | 0 | } |
1371 | |
|
1372 | 0 | if (!presets.empty()) { |
1373 | 0 | printPrecedingNewline(newline); |
1374 | 0 | std::cout << "Available test presets:\n\n"; |
1375 | 0 | cmCMakePresetsGraph::PrintPresets(presets); |
1376 | 0 | } |
1377 | 0 | } |
1378 | | |
1379 | | void cmCMakePresetsGraph::PrintPackagePresetList( |
1380 | | PrintPrecedingNewline* newline) const |
1381 | 0 | { |
1382 | 0 | this->PrintPackagePresetList([](PackagePreset const&) { return true; }, |
1383 | 0 | newline); |
1384 | 0 | } |
1385 | | |
1386 | | void cmCMakePresetsGraph::PrintPackagePresetList( |
1387 | | std::function<bool(PackagePreset const&)> const& filter, |
1388 | | PrintPrecedingNewline* newline) const |
1389 | 0 | { |
1390 | 0 | std::vector<cmCMakePresetsGraph::Preset const*> presets; |
1391 | 0 | for (auto const& p : this->PackagePresetOrder) { |
1392 | 0 | auto const& preset = this->PackagePresets.at(p); |
1393 | 0 | if (!preset.Unexpanded.Hidden && preset.Expanded && |
1394 | 0 | preset.Expanded->ConditionResult && filter(preset.Unexpanded)) { |
1395 | 0 | presets.push_back( |
1396 | 0 | static_cast<cmCMakePresetsGraph::Preset const*>(&preset.Unexpanded)); |
1397 | 0 | } |
1398 | 0 | } |
1399 | |
|
1400 | 0 | if (!presets.empty()) { |
1401 | 0 | printPrecedingNewline(newline); |
1402 | 0 | std::cout << "Available package presets:\n\n"; |
1403 | 0 | cmCMakePresetsGraph::PrintPresets(presets); |
1404 | 0 | } |
1405 | 0 | } |
1406 | | |
1407 | | void cmCMakePresetsGraph::PrintWorkflowPresetList( |
1408 | | PrintPrecedingNewline* newline) const |
1409 | 0 | { |
1410 | 0 | std::vector<cmCMakePresetsGraph::Preset const*> presets; |
1411 | 0 | for (auto const& p : this->WorkflowPresetOrder) { |
1412 | 0 | auto const& preset = this->WorkflowPresets.at(p); |
1413 | 0 | if (!preset.Unexpanded.Hidden && preset.Expanded && |
1414 | 0 | preset.Expanded->ConditionResult) { |
1415 | 0 | presets.push_back( |
1416 | 0 | static_cast<cmCMakePresetsGraph::Preset const*>(&preset.Unexpanded)); |
1417 | 0 | } |
1418 | 0 | } |
1419 | |
|
1420 | 0 | if (!presets.empty()) { |
1421 | 0 | printPrecedingNewline(newline); |
1422 | 0 | std::cout << "Available workflow presets:\n\n"; |
1423 | 0 | cmCMakePresetsGraph::PrintPresets(presets); |
1424 | 0 | } |
1425 | 0 | } |
1426 | | |
1427 | | void cmCMakePresetsGraph::PrintAllPresets() const |
1428 | 0 | { |
1429 | 0 | PrintPrecedingNewline newline = PrintPrecedingNewline::False; |
1430 | 0 | this->PrintConfigurePresetList(&newline); |
1431 | 0 | this->PrintBuildPresetList(&newline); |
1432 | 0 | this->PrintTestPresetList(&newline); |
1433 | 0 | this->PrintPackagePresetList(&newline); |
1434 | 0 | this->PrintWorkflowPresetList(&newline); |
1435 | 0 | } |