MCPcopy Create free account
hub / github.com/Kitware/CMake / EvaluateSplitConfigGenex

Function EvaluateSplitConfigGenex

Source/cmCustomCommandGenerator.cxx:30–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29namespace {
30std::string EvaluateSplitConfigGenex(
31 cm::string_view input, cmGeneratorExpression const& ge, cmLocalGenerator* lg,
32 bool useOutputConfig, std::string const& outputConfig,
33 std::string const& commandConfig, cmGeneratorTarget const* target,
34 std::set<BT<std::pair<std::string, bool>>>* utils = nullptr)
35{
36 std::string result;
37
38 while (!input.empty()) {
39 // Copy non-genex content directly to the result.
40 std::string::size_type pos = input.find("$<");
41 result += input.substr(0, pos);
42 if (pos == std::string::npos) {
43 break;
44 }
45 input = input.substr(pos);
46
47 // Find the balanced end of this regex.
48 size_t nestingLevel = 1;
49 for (pos = 2; pos < input.size(); ++pos) {
50 cm::string_view cur = input.substr(pos);
51 if (cmHasLiteralPrefix(cur, "$<")) {
52 ++nestingLevel;
53 ++pos;
54 continue;
55 }
56 if (cmHasPrefix(cur, '>')) {
57 --nestingLevel;
58 if (nestingLevel == 0) {
59 ++pos;
60 break;
61 }
62 }
63 }
64
65 // Split this genex from following input.
66 cm::string_view genex = input.substr(0, pos);
67 input = input.substr(pos);
68
69 // Convert an outer COMMAND_CONFIG or OUTPUT_CONFIG to the matching config.
70 std::string const* config =
71 useOutputConfig ? &outputConfig : &commandConfig;
72 if (nestingLevel == 0) {
73 static cm::string_view const COMMAND_CONFIG = "$<COMMAND_CONFIG:"_s;
74 static cm::string_view const OUTPUT_CONFIG = "$<OUTPUT_CONFIG:"_s;
75 if (cmHasPrefix(genex, COMMAND_CONFIG)) {
76 genex.remove_prefix(COMMAND_CONFIG.size());
77 genex.remove_suffix(1);
78 useOutputConfig = false;
79 config = &commandConfig;
80 } else if (cmHasPrefix(genex, OUTPUT_CONFIG)) {
81 genex.remove_prefix(OUTPUT_CONFIG.size());
82 genex.remove_suffix(1);
83 useOutputConfig = true;
84 config = &outputConfig;
85 }
86 }
87

Callers 2

EvaluateDependsFunction · 0.85

Calls 12

cmHasLiteralPrefixFunction · 0.85
cmHasPrefixFunction · 0.85
GetTargetsMethod · 0.80
emplaceMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
substrMethod · 0.45
sizeMethod · 0.45
ParseMethod · 0.45
EvaluateMethod · 0.45
GetNameMethod · 0.45
GetBacktraceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…