summaryrefslogtreecommitdiffstats
path: root/Source/cmTryRunCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-12-08 17:16:08 (GMT)
committerBrad King <brad.king@kitware.com>2022-12-16 15:12:25 (GMT)
commit6c40e0b25ec8475d73779ffbaa63a4230aa5e28d (patch)
treef79f163ec0573ee870b2c01eb1a547be3d0324bb /Source/cmTryRunCommand.cxx
parent048a02d5bb842c783fad03105bb60e44227765ad (diff)
downloadCMake-6c40e0b25ec8475d73779ffbaa63a4230aa5e28d.zip
CMake-6c40e0b25ec8475d73779ffbaa63a4230aa5e28d.tar.gz
CMake-6c40e0b25ec8475d73779ffbaa63a4230aa5e28d.tar.bz2
ConfigureLog: Version individual events instead of the whole log
In order to support multiple log versions without buffering the entire log, move versioning to the level of individual events. Multiple versions of an event may then be logged consecutively. Issue: #23200
Diffstat (limited to 'Source/cmTryRunCommand.cxx')
-rw-r--r--Source/cmTryRunCommand.cxx44
1 files changed, 24 insertions, 20 deletions
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 794f2c6..63e4478 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -40,28 +40,32 @@ void WriteTryRunEvent(cmConfigureLog& log, cmMakefile const& mf,
cmTryCompileResult const& compileResult,
cmTryRunResult const& runResult)
{
- log.BeginEvent("try_run");
- log.WriteBacktrace(mf);
- cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
-
- log.BeginObject("runResult"_s);
- log.WriteValue("variable"_s, runResult.Variable);
- log.WriteValue("cached"_s, runResult.VariableCached);
- if (runResult.Stdout) {
- log.WriteLiteralTextBlock("stdout"_s, *runResult.Stdout);
- }
- if (runResult.Stderr) {
- log.WriteLiteralTextBlock("stderr"_s, *runResult.Stderr);
- }
- if (runResult.ExitCode) {
- try {
- log.WriteValue("exitCode"_s, std::stoi(*runResult.ExitCode));
- } catch (std::invalid_argument const&) {
- log.WriteValue("exitCode"_s, *runResult.ExitCode);
+ static const std::vector<unsigned long> LogVersionsWithTryRunV1{ 1 };
+
+ if (log.IsAnyLogVersionEnabled(LogVersionsWithTryRunV1)) {
+ log.BeginEvent("try_run-v1");
+ log.WriteBacktrace(mf);
+ cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
+
+ log.BeginObject("runResult"_s);
+ log.WriteValue("variable"_s, runResult.Variable);
+ log.WriteValue("cached"_s, runResult.VariableCached);
+ if (runResult.Stdout) {
+ log.WriteLiteralTextBlock("stdout"_s, *runResult.Stdout);
+ }
+ if (runResult.Stderr) {
+ log.WriteLiteralTextBlock("stderr"_s, *runResult.Stderr);
+ }
+ if (runResult.ExitCode) {
+ try {
+ log.WriteValue("exitCode"_s, std::stoi(*runResult.ExitCode));
+ } catch (std::invalid_argument const&) {
+ log.WriteValue("exitCode"_s, *runResult.ExitCode);
+ }
}
+ log.EndObject();
+ log.EndEvent();
}
- log.EndObject();
- log.EndEvent();
}
#endif