summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-01-30 15:37:33 (GMT)
committerBrad King <brad.king@kitware.com>2023-02-01 14:32:42 (GMT)
commit0a48d8fe5ccf8a44bcada7b528f4cf4dd591b18e (patch)
tree70ea637df099d555b01e8e73c9935563d0ea5c22 /Source
parente86bebfd146c07d3a5eb34f9f35e133b6c3b805c (diff)
downloadCMake-0a48d8fe5ccf8a44bcada7b528f4cf4dd591b18e.zip
CMake-0a48d8fe5ccf8a44bcada7b528f4cf4dd591b18e.tar.gz
CMake-0a48d8fe5ccf8a44bcada7b528f4cf4dd591b18e.tar.bz2
ConfigureLog: De-duplicate event backtrace and check key generation
All event kinds have these fields, so centralize their implementation.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmConfigureLog.cxx4
-rw-r--r--Source/cmConfigureLog.h8
-rw-r--r--Source/cmMessageCommand.cxx4
-rw-r--r--Source/cmTryCompileCommand.cxx4
-rw-r--r--Source/cmTryRunCommand.cxx4
5 files changed, 10 insertions, 14 deletions
diff --git a/Source/cmConfigureLog.cxx b/Source/cmConfigureLog.cxx
index 1b00b4f..1cf785a 100644
--- a/Source/cmConfigureLog.cxx
+++ b/Source/cmConfigureLog.cxx
@@ -136,7 +136,7 @@ void cmConfigureLog::EndObject()
--this->Indent;
}
-void cmConfigureLog::BeginEvent(std::string const& kind)
+void cmConfigureLog::BeginEvent(std::string const& kind, cmMakefile const& mf)
{
this->EnsureInit();
@@ -146,6 +146,8 @@ void cmConfigureLog::BeginEvent(std::string const& kind)
++this->Indent;
this->WriteValue("kind"_s, kind);
+ this->WriteBacktrace(mf);
+ this->WriteChecks(mf);
}
void cmConfigureLog::EndEvent()
diff --git a/Source/cmConfigureLog.h b/Source/cmConfigureLog.h
index d672445..eb25702 100644
--- a/Source/cmConfigureLog.h
+++ b/Source/cmConfigureLog.h
@@ -28,12 +28,9 @@ public:
list is enabled. */
bool IsAnyLogVersionEnabled(std::vector<unsigned long> const& v) const;
- void WriteBacktrace(cmMakefile const& mf);
- void WriteChecks(cmMakefile const& mf);
-
void EnsureInit();
- void BeginEvent(std::string const& kind);
+ void BeginEvent(std::string const& kind, cmMakefile const& mf);
void EndEvent();
void BeginObject(cm::string_view key);
@@ -63,6 +60,9 @@ private:
std::unique_ptr<Json::StreamWriter> Encoder;
+ void WriteBacktrace(cmMakefile const& mf);
+ void WriteChecks(cmMakefile const& mf);
+
cmsys::ofstream& BeginLine();
void EndLine();
void WriteEscape(unsigned char c);
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index 205f01f..52373f3 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -74,9 +74,7 @@ void WriteMessageEvent(cmConfigureLog& log, cmMakefile const& mf,
static const std::vector<unsigned long> LogVersionsWithMessageV1{ 1 };
if (log.IsAnyLogVersionEnabled(LogVersionsWithMessageV1)) {
- log.BeginEvent("message-v1");
- log.WriteBacktrace(mf);
- log.WriteChecks(mf);
+ log.BeginEvent("message-v1", mf);
log.WriteLiteralTextBlock("message"_s, message);
log.EndEvent();
}
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx
index 789ffe9..d2cc75b 100644
--- a/Source/cmTryCompileCommand.cxx
+++ b/Source/cmTryCompileCommand.cxx
@@ -25,9 +25,7 @@ void WriteTryCompileEvent(cmConfigureLog& log, cmMakefile const& mf,
static const std::vector<unsigned long> LogVersionsWithTryCompileV1{ 1 };
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryCompileV1)) {
- log.BeginEvent("try_compile-v1");
- log.WriteBacktrace(mf);
- log.WriteChecks(mf);
+ log.BeginEvent("try_compile-v1", mf);
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
log.EndEvent();
}
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 21bd95a..b648d9b 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -44,9 +44,7 @@ void WriteTryRunEvent(cmConfigureLog& log, cmMakefile const& mf,
static const std::vector<unsigned long> LogVersionsWithTryRunV1{ 1 };
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryRunV1)) {
- log.BeginEvent("try_run-v1");
- log.WriteBacktrace(mf);
- log.WriteChecks(mf);
+ log.BeginEvent("try_run-v1", mf);
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
log.BeginObject("runResult"_s);