| 28 | |
| 29 | namespace { |
| 30 | std::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 |
no test coverage detected
searching dependent graphs…