| 105 | } |
| 106 | |
| 107 | bool cmInstrumentationCommand(std::vector<std::string> const& args, |
| 108 | cmExecutionStatus& status) |
| 109 | { |
| 110 | if (args.empty()) { |
| 111 | status.SetError("must be called with arguments."); |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | if (status.GetMakefile().GetCMakeInstance()->GetInInitialCache()) { |
| 116 | status.GetMakefile().IssueMessage( |
| 117 | MessageType::FATAL_ERROR, |
| 118 | "Cannot invoke cmake_instrumentation() within an initial cache file."); |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | struct Arguments : public ArgumentParser::ParseResult |
| 123 | { |
| 124 | ArgumentParser::NonEmpty<std::string> ApiVersion; |
| 125 | ArgumentParser::NonEmpty<std::string> DataVersion; |
| 126 | ArgumentParser::NonEmpty<std::vector<std::string>> Options; |
| 127 | ArgumentParser::NonEmpty<std::vector<std::string>> Hooks; |
| 128 | ArgumentParser::NonEmpty<std::vector<std::vector<std::string>>> Callbacks; |
| 129 | ArgumentParser::NonEmpty<std::vector<std::vector<std::string>>> |
| 130 | CustomContent; |
| 131 | }; |
| 132 | |
| 133 | static auto const parser = |
| 134 | cmArgumentParser<Arguments>{} |
| 135 | .Bind("API_VERSION"_s, &Arguments::ApiVersion) |
| 136 | .Bind("DATA_VERSION"_s, &Arguments::DataVersion) |
| 137 | .Bind("OPTIONS"_s, &Arguments::Options) |
| 138 | .Bind("HOOKS"_s, &Arguments::Hooks) |
| 139 | .Bind("CALLBACK"_s, &Arguments::Callbacks) |
| 140 | .Bind("CUSTOM_CONTENT"_s, &Arguments::CustomContent); |
| 141 | |
| 142 | std::vector<std::string> unparsedArguments; |
| 143 | Arguments const arguments = parser.Parse(args, &unparsedArguments); |
| 144 | |
| 145 | if (arguments.MaybeReportError(status.GetMakefile())) { |
| 146 | return true; |
| 147 | } |
| 148 | if (!unparsedArguments.empty()) { |
| 149 | status.SetError("given unknown argument \"" + unparsedArguments.front() + |
| 150 | "\"."); |
| 151 | return false; |
| 152 | } |
| 153 | int apiVersion; |
| 154 | Version dataVersion; |
| 155 | if (!validateVersion("API_VERSION", arguments.ApiVersion, apiVersion, |
| 156 | status) || |
| 157 | !validateDataVersion(arguments.DataVersion, dataVersion, status)) { |
| 158 | return false; |
| 159 | } |
| 160 | |
| 161 | std::set<cmInstrumentationQuery::Option> options; |
| 162 | auto optionParser = EnumParser<cmInstrumentationQuery::Option>( |
| 163 | cmInstrumentationQuery::OptionString); |
| 164 | for (auto const& arg : arguments.Options) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…