try_compile: Record stack of in-progess checks in configure log
Many `try_compile` and `try_run` calls occur inside check modules between `message(CHECK_START)` and `message(CHECK_{PASS,FAIL})` pairs. Add a field to configure log entries to report this context. Issue: #23200
This commit is contained in:
parent
d4bf7d80c6
commit
48292c8624
@ -106,6 +106,8 @@ Every event kind is represented by a YAML mapping of the form:
|
||||
kind: "<kind>-v<major>"
|
||||
backtrace:
|
||||
- "<file>:<line> (<function>)"
|
||||
checks:
|
||||
- "Checking for something"
|
||||
#...event-specific keys...
|
||||
|
||||
The keys common to all events are:
|
||||
@ -119,6 +121,13 @@ The keys common to all events are:
|
||||
least-recent. Each node is a string specifying one location
|
||||
formatted as ``<file>:<line> (<function>)``.
|
||||
|
||||
``checks``
|
||||
An optional key that is present when the event occurred with
|
||||
at least one pending :command:`message(CHECK_START)`. Its value
|
||||
is a YAML block sequence reporting the stack of pending checks,
|
||||
from most-recent to least-recent. Each node is a string containing
|
||||
a pending check message.
|
||||
|
||||
Additional mapping keys are specific to each (versioned) event kind,
|
||||
described below.
|
||||
|
||||
@ -141,6 +150,8 @@ A ``try_compile-v1`` event is a YAML mapping:
|
||||
kind: "try_compile-v1"
|
||||
backtrace:
|
||||
- "CMakeLists.txt:123 (try_compile)"
|
||||
checks:
|
||||
- "Checking for something"
|
||||
description: "Explicit LOG_DESCRIPTION"
|
||||
directories:
|
||||
source: "/path/to/.../TryCompile-01234"
|
||||
@ -212,6 +223,8 @@ A ``try_run-v1`` event is a YAML mapping:
|
||||
kind: "try_run-v1"
|
||||
backtrace:
|
||||
- "CMakeLists.txt:456 (try_run)"
|
||||
checks:
|
||||
- "Checking for something"
|
||||
description: "Explicit LOG_DESCRIPTION"
|
||||
directories:
|
||||
source: "/path/to/.../TryCompile-56789"
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
@ -78,6 +79,21 @@ void cmConfigureLog::WriteBacktrace(cmMakefile const& mf)
|
||||
this->WriteValue("backtrace"_s, backtrace);
|
||||
}
|
||||
|
||||
void cmConfigureLog::WriteChecks(cmMakefile const& mf)
|
||||
{
|
||||
if (!mf.GetCMakeInstance()->HasCheckInProgress()) {
|
||||
return;
|
||||
}
|
||||
this->BeginObject("checks"_s);
|
||||
for (auto const& value :
|
||||
cmReverseRange(mf.GetCMakeInstance()->GetCheckInProgressMessages())) {
|
||||
this->BeginLine() << "- ";
|
||||
this->Encoder->write(value, &this->Stream);
|
||||
this->EndLine();
|
||||
}
|
||||
this->EndObject();
|
||||
}
|
||||
|
||||
void cmConfigureLog::EnsureInit()
|
||||
{
|
||||
if (this->Opened) {
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
bool IsAnyLogVersionEnabled(std::vector<unsigned long> const& v) const;
|
||||
|
||||
void WriteBacktrace(cmMakefile const& mf);
|
||||
void WriteChecks(cmMakefile const& mf);
|
||||
|
||||
void EnsureInit();
|
||||
|
||||
|
@ -27,6 +27,7 @@ void WriteTryCompileEvent(cmConfigureLog& log, cmMakefile const& mf,
|
||||
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryCompileV1)) {
|
||||
log.BeginEvent("try_compile-v1");
|
||||
log.WriteBacktrace(mf);
|
||||
log.WriteChecks(mf);
|
||||
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
|
||||
log.EndEvent();
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ void WriteTryRunEvent(cmConfigureLog& log, cmMakefile const& mf,
|
||||
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryRunV1)) {
|
||||
log.BeginEvent("try_run-v1");
|
||||
log.WriteBacktrace(mf);
|
||||
log.WriteChecks(mf);
|
||||
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
|
||||
|
||||
log.BeginObject("runResult"_s);
|
||||
|
@ -479,6 +479,10 @@ public:
|
||||
{
|
||||
this->CheckInProgressMessages.emplace_back(std::move(message));
|
||||
}
|
||||
std::vector<std::string> const& GetCheckInProgressMessages() const
|
||||
{
|
||||
return this->CheckInProgressMessages;
|
||||
}
|
||||
|
||||
//! Should `message` command display context.
|
||||
bool GetShowLogContext() const { return this->LogContext; }
|
||||
|
@ -8,6 +8,8 @@ events:
|
||||
- "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
|
||||
- "ConfigureLog.cmake:[0-9]+ \(enable_language\)"
|
||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||
checks:
|
||||
- "Detecting C compiler ABI info"
|
||||
directories:
|
||||
source: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
binary: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
@ -35,6 +37,9 @@ events:
|
||||
backtrace:
|
||||
- "ConfigureLog.cmake:[0-9]+ \(try_compile\)"
|
||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||
checks:
|
||||
- "Check 2"
|
||||
- "Check 1"
|
||||
description: "Source that should compile\."
|
||||
directories:
|
||||
source: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
|
4
Tests/RunCMake/try_compile/ConfigureLog-stdout.txt
Normal file
4
Tests/RunCMake/try_compile/ConfigureLog-stdout.txt
Normal file
@ -0,0 +1,4 @@
|
||||
-- Check 1
|
||||
-- Check 2
|
||||
-- Check 2 - passed
|
||||
-- Check 1 - passed
|
@ -10,7 +10,16 @@ try_compile(COMPILE_RESULT
|
||||
NO_LOG
|
||||
)
|
||||
|
||||
message(CHECK_START "Check 1")
|
||||
message(CHECK_START "Check 2")
|
||||
try_compile(COMPILE_RESULT
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
||||
LOG_DESCRIPTION "Source that should compile."
|
||||
)
|
||||
if (COMPILE_RESULT)
|
||||
message(CHECK_PASS "passed")
|
||||
message(CHECK_PASS "passed")
|
||||
else()
|
||||
message(CHECK_FAIL "failed")
|
||||
message(CHECK_FAIL "failed")
|
||||
endif()
|
||||
|
@ -8,6 +8,8 @@ events:
|
||||
- "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
|
||||
- "Inspect.cmake:[0-9]+ \(enable_language\)"
|
||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||
checks:
|
||||
- "Detecting C compiler ABI info"
|
||||
directories:
|
||||
source: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
binary: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
@ -23,6 +25,8 @@ events:
|
||||
- "[^"]*/Modules/CMakeTestCXXCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
|
||||
- "Inspect.cmake:[0-9]+ \(enable_language\)"
|
||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||
checks:
|
||||
- "Detecting CXX compiler ABI info"
|
||||
directories:
|
||||
source: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
binary: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
|
@ -7,6 +7,8 @@ events:
|
||||
- "[^"]*/Modules/CMakeDetermineCompilerABI.cmake:[0-9]+ \(try_compile\)"
|
||||
- "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
|
||||
- "CMakeLists.txt:[0-9]+ \(project\)"
|
||||
checks:
|
||||
- "Detecting C compiler ABI info"
|
||||
directories:
|
||||
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
binary: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
@ -37,6 +39,8 @@ events:
|
||||
backtrace:
|
||||
- "ConfigureLog.cmake:[0-9]+ \(try_run\)"
|
||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||
checks:
|
||||
- "Check 1"
|
||||
description: "Source that should compile\."
|
||||
directories:
|
||||
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
@ -59,6 +63,9 @@ events:
|
||||
backtrace:
|
||||
- "ConfigureLog.cmake:[0-9]+ \(try_run\)"
|
||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||
checks:
|
||||
- "Check 2"
|
||||
- "Check 1"
|
||||
directories:
|
||||
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
binary: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||
|
4
Tests/RunCMake/try_run/ConfigureLog-stdout.txt
Normal file
4
Tests/RunCMake/try_run/ConfigureLog-stdout.txt
Normal file
@ -0,0 +1,4 @@
|
||||
-- Check 1
|
||||
-- Check 2
|
||||
-- Check 2 - passed
|
||||
-- Check 1 - passed
|
@ -8,15 +8,24 @@ try_run(RUN_RESULT COMPILE_RESULT
|
||||
NO_LOG
|
||||
)
|
||||
|
||||
message(CHECK_START "Check 1")
|
||||
try_run(RUN_RESULT COMPILE_RESULT
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
||||
LOG_DESCRIPTION "Source that should compile."
|
||||
)
|
||||
|
||||
message(CHECK_START "Check 2")
|
||||
try_run(RUN_RESULT COMPILE_RESULT
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
||||
RUN_OUTPUT_VARIABLE RUN_OUTPUT
|
||||
)
|
||||
if (RUN_RESULT)
|
||||
message(CHECK_PASS "passed")
|
||||
message(CHECK_PASS "passed")
|
||||
else()
|
||||
message(CHECK_FAIL "failed")
|
||||
message(CHECK_FAIL "failed")
|
||||
endif()
|
||||
|
||||
try_run(RUN_RESULT COMPILE_RESULT
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
||||
|
Loading…
Reference in New Issue
Block a user