mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
cmInstrumentationCommand: Use cmJSONState to read content args
This approach will be more portable.
This commit is contained in:
@@ -10,7 +10,6 @@ file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include <cm3p/json/reader.h>
|
||||
#include <cm3p/json/value.h>
|
||||
|
||||
#include "cmsys/String.h"
|
||||
@@ -20,6 +19,7 @@ file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmInstrumentation.h"
|
||||
#include "cmInstrumentationQuery.h"
|
||||
#include "cmJSONState.h"
|
||||
#include "cmList.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
@@ -206,11 +206,11 @@ bool cmInstrumentationCommand(std::vector<std::string> const& args,
|
||||
value.append(item);
|
||||
}
|
||||
} else if (type == "JSON") {
|
||||
Json::CharReaderBuilder builder;
|
||||
std::istringstream iss(contentString);
|
||||
if (!Json::parseFromStream(builder, iss, &value, nullptr)) {
|
||||
status.SetError(
|
||||
cmStrCat("failed to parse custom content as JSON: ", contentString));
|
||||
cmJSONState parseState(iss, &value, cmJSONState::StrictMode::Relaxed);
|
||||
if (!parseState.errors.empty()) {
|
||||
status.SetError(cmStrCat("failed to parse custom content as JSON:\n ",
|
||||
parseState.GetErrorMessage()));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
CMake Error at [^
|
||||
]*:1 \(cmake_instrumentation\):
|
||||
cmake_instrumentation failed to parse custom content as JSON: Not valid
|
||||
JSON content
|
||||
cmake_instrumentation failed to parse custom content as JSON:
|
||||
(
|
||||
Syntax error: value, object or array expected\.
|
||||
|
||||
Not valid JSON content
|
||||
|
||||
\^|
|
||||
JSON Parse Error:
|
||||
\* Line 1, Column 1
|
||||
Syntax error: value, object or array expected\.
|
||||
)
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
Reference in New Issue
Block a user