mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-21 13:48:33 -05:00
message: Add CONFIGURE_LOG mode to record a message in the configure log
Provide a replacement for `file(APPEND .../CMake{Output,Error}.log)`
that records messages in the configure log.
Issue: #23200
This commit is contained in:
@@ -52,6 +52,7 @@ Json::Value ConfigureLog::DumpEventKindNames()
|
||||
// major version of the configureLog object kind is needed.
|
||||
Json::Value eventKindNames = Json::arrayValue;
|
||||
if (this->Version == 1) {
|
||||
eventKindNames.append("message-v1"); // WriteMessageEvent
|
||||
eventKindNames.append("try_compile-v1"); // WriteTryCompileEvent
|
||||
eventKindNames.append("try_run-v1"); // WriteTryRunEvent
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <cm/string_view>
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include "cmConfigureLog.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
@@ -64,6 +65,25 @@ void ReportCheckResult(cm::string_view what, std::string result,
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
void WriteMessageEvent(cmConfigureLog& log, cmMakefile const& mf,
|
||||
std::string const& message)
|
||||
{
|
||||
// Keep in sync with cmFileAPIConfigureLog's DumpEventKindNames.
|
||||
static const std::vector<unsigned long> LogVersionsWithMessageV1{ 1 };
|
||||
|
||||
if (log.IsAnyLogVersionEnabled(LogVersionsWithMessageV1)) {
|
||||
log.BeginEvent("message-v1");
|
||||
log.WriteBacktrace(mf);
|
||||
log.WriteChecks(mf);
|
||||
log.WriteLiteralTextBlock("message"_s, message);
|
||||
log.EndEvent();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// cmLibraryCommand
|
||||
@@ -121,6 +141,14 @@ bool cmMessageCommand(std::vector<std::string> const& args,
|
||||
level = Message::LogLevel::LOG_STATUS;
|
||||
checkingType = CheckingType::CHECK_FAIL;
|
||||
++i;
|
||||
} else if (*i == "CONFIGURE_LOG") {
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
if (cmConfigureLog* log = mf.GetCMakeInstance()->GetConfigureLog()) {
|
||||
++i;
|
||||
WriteMessageEvent(*log, mf, cmJoin(cmMakeRange(i, args.cend()), ""_s));
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
} else if (*i == "STATUS") {
|
||||
level = Message::LogLevel::LOG_STATUS;
|
||||
++i;
|
||||
|
||||
Reference in New Issue
Block a user