summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2019-12-27 15:52:47 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-12-27 15:53:13 (GMT)
commitbb811568cc099b19a98b146a4781bc27def5aef7 (patch)
tree0a1c17bd3c86cd6bd17c3eea5c2300b318bc21f2 /Source/cmMakefile.cxx
parente8776d6e3ad2575d647d4b53dab65100c05a547e (diff)
parente113ab11681fa8c7b7b4ab2d8f4a093ef4230d5d (diff)
downloadCMake-bb811568cc099b19a98b146a4781bc27def5aef7.zip
CMake-bb811568cc099b19a98b146a4781bc27def5aef7.tar.gz
CMake-bb811568cc099b19a98b146a4781bc27def5aef7.tar.bz2
Merge topic 'traceJSON'
e113ab1168 trace: Add test for the JSON-v1 trace 482497e0de trace: Add JSON output format Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4102
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx47
1 files changed, 40 insertions, 7 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 2caa266..13a6ed7 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -7,6 +7,7 @@
#include <algorithm>
#include <cassert>
#include <cctype>
+#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
@@ -20,6 +21,8 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
+#include "cm_jsoncpp_value.h"
+#include "cm_jsoncpp_writer.h"
#include "cm_sys_stat.h"
#include "cmAlgorithms.h"
@@ -315,21 +318,51 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
}
std::ostringstream msg;
- msg << full_path << "(" << lff.Line << "): ";
- msg << lff.Name.Original << "(";
- bool expand = this->GetCMakeInstance()->GetTraceExpand();
+ std::vector<std::string> args;
std::string temp;
+ bool expand = this->GetCMakeInstance()->GetTraceExpand();
+
+ args.reserve(lff.Arguments.size());
for (cmListFileArgument const& arg : lff.Arguments) {
if (expand) {
temp = arg.Value;
this->ExpandVariablesInString(temp);
- msg << temp;
+ args.push_back(temp);
} else {
- msg << arg.Value;
+ args.push_back(arg.Value);
+ }
+ }
+
+ switch (this->GetCMakeInstance()->GetTraceFormat()) {
+ case cmake::TraceFormat::TRACE_JSON_V1: {
+#ifndef CMAKE_BOOTSTRAP
+ Json::Value val;
+ Json::StreamWriterBuilder builder;
+ builder["indentation"] = "";
+ val["file"] = full_path;
+ val["line"] = static_cast<std::int64_t>(lff.Line);
+ val["cmd"] = lff.Name.Original;
+ val["args"] = Json::Value(Json::arrayValue);
+ for (std::string const& arg : args) {
+ val["args"].append(arg);
+ }
+ msg << Json::writeString(builder, val);
+#endif
+ break;
}
- msg << " ";
+ case cmake::TraceFormat::TRACE_HUMAN:
+ msg << full_path << "(" << lff.Line << "): ";
+ msg << lff.Name.Original << "(";
+
+ for (std::string const& arg : args) {
+ msg << arg << " ";
+ }
+ msg << ")";
+ break;
+ case cmake::TraceFormat::TRACE_UNDEFINED:
+ msg << "INTERNAL ERROR: Trace format is TRACE_UNDEFINED";
+ break;
}
- msg << ")";
auto& f = this->GetCMakeInstance()->GetTraceFile();
if (f) {