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>"
|
kind: "<kind>-v<major>"
|
||||||
backtrace:
|
backtrace:
|
||||||
- "<file>:<line> (<function>)"
|
- "<file>:<line> (<function>)"
|
||||||
|
checks:
|
||||||
|
- "Checking for something"
|
||||||
#...event-specific keys...
|
#...event-specific keys...
|
||||||
|
|
||||||
The keys common to all events are:
|
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
|
least-recent. Each node is a string specifying one location
|
||||||
formatted as ``<file>:<line> (<function>)``.
|
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,
|
Additional mapping keys are specific to each (versioned) event kind,
|
||||||
described below.
|
described below.
|
||||||
|
|
||||||
@ -141,6 +150,8 @@ A ``try_compile-v1`` event is a YAML mapping:
|
|||||||
kind: "try_compile-v1"
|
kind: "try_compile-v1"
|
||||||
backtrace:
|
backtrace:
|
||||||
- "CMakeLists.txt:123 (try_compile)"
|
- "CMakeLists.txt:123 (try_compile)"
|
||||||
|
checks:
|
||||||
|
- "Checking for something"
|
||||||
description: "Explicit LOG_DESCRIPTION"
|
description: "Explicit LOG_DESCRIPTION"
|
||||||
directories:
|
directories:
|
||||||
source: "/path/to/.../TryCompile-01234"
|
source: "/path/to/.../TryCompile-01234"
|
||||||
@ -212,6 +223,8 @@ A ``try_run-v1`` event is a YAML mapping:
|
|||||||
kind: "try_run-v1"
|
kind: "try_run-v1"
|
||||||
backtrace:
|
backtrace:
|
||||||
- "CMakeLists.txt:456 (try_run)"
|
- "CMakeLists.txt:456 (try_run)"
|
||||||
|
checks:
|
||||||
|
- "Checking for something"
|
||||||
description: "Explicit LOG_DESCRIPTION"
|
description: "Explicit LOG_DESCRIPTION"
|
||||||
directories:
|
directories:
|
||||||
source: "/path/to/.../TryCompile-56789"
|
source: "/path/to/.../TryCompile-56789"
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "cmListFileCache.h"
|
#include "cmListFileCache.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
|
#include "cmRange.h"
|
||||||
#include "cmStringAlgorithms.h"
|
#include "cmStringAlgorithms.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
@ -78,6 +79,21 @@ void cmConfigureLog::WriteBacktrace(cmMakefile const& mf)
|
|||||||
this->WriteValue("backtrace"_s, backtrace);
|
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()
|
void cmConfigureLog::EnsureInit()
|
||||||
{
|
{
|
||||||
if (this->Opened) {
|
if (this->Opened) {
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
bool IsAnyLogVersionEnabled(std::vector<unsigned long> const& v) const;
|
bool IsAnyLogVersionEnabled(std::vector<unsigned long> const& v) const;
|
||||||
|
|
||||||
void WriteBacktrace(cmMakefile const& mf);
|
void WriteBacktrace(cmMakefile const& mf);
|
||||||
|
void WriteChecks(cmMakefile const& mf);
|
||||||
|
|
||||||
void EnsureInit();
|
void EnsureInit();
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ void WriteTryCompileEvent(cmConfigureLog& log, cmMakefile const& mf,
|
|||||||
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryCompileV1)) {
|
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryCompileV1)) {
|
||||||
log.BeginEvent("try_compile-v1");
|
log.BeginEvent("try_compile-v1");
|
||||||
log.WriteBacktrace(mf);
|
log.WriteBacktrace(mf);
|
||||||
|
log.WriteChecks(mf);
|
||||||
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
|
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
|
||||||
log.EndEvent();
|
log.EndEvent();
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ void WriteTryRunEvent(cmConfigureLog& log, cmMakefile const& mf,
|
|||||||
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryRunV1)) {
|
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryRunV1)) {
|
||||||
log.BeginEvent("try_run-v1");
|
log.BeginEvent("try_run-v1");
|
||||||
log.WriteBacktrace(mf);
|
log.WriteBacktrace(mf);
|
||||||
|
log.WriteChecks(mf);
|
||||||
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
|
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
|
||||||
|
|
||||||
log.BeginObject("runResult"_s);
|
log.BeginObject("runResult"_s);
|
||||||
|
@ -479,6 +479,10 @@ public:
|
|||||||
{
|
{
|
||||||
this->CheckInProgressMessages.emplace_back(std::move(message));
|
this->CheckInProgressMessages.emplace_back(std::move(message));
|
||||||
}
|
}
|
||||||
|
std::vector<std::string> const& GetCheckInProgressMessages() const
|
||||||
|
{
|
||||||
|
return this->CheckInProgressMessages;
|
||||||
|
}
|
||||||
|
|
||||||
//! Should `message` command display context.
|
//! Should `message` command display context.
|
||||||
bool GetShowLogContext() const { return this->LogContext; }
|
bool GetShowLogContext() const { return this->LogContext; }
|
||||||
|
@ -8,6 +8,8 @@ events:
|
|||||||
- "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
|
- "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
|
||||||
- "ConfigureLog.cmake:[0-9]+ \(enable_language\)"
|
- "ConfigureLog.cmake:[0-9]+ \(enable_language\)"
|
||||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||||
|
checks:
|
||||||
|
- "Detecting C compiler ABI info"
|
||||||
directories:
|
directories:
|
||||||
source: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
source: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||||
binary: "[^"]*/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:
|
backtrace:
|
||||||
- "ConfigureLog.cmake:[0-9]+ \(try_compile\)"
|
- "ConfigureLog.cmake:[0-9]+ \(try_compile\)"
|
||||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||||
|
checks:
|
||||||
|
- "Check 2"
|
||||||
|
- "Check 1"
|
||||||
description: "Source that should compile\."
|
description: "Source that should compile\."
|
||||||
directories:
|
directories:
|
||||||
source: "[^"]*/Tests/RunCMake/try_compile/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
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
|
NO_LOG
|
||||||
)
|
)
|
||||||
|
|
||||||
|
message(CHECK_START "Check 1")
|
||||||
|
message(CHECK_START "Check 2")
|
||||||
try_compile(COMPILE_RESULT
|
try_compile(COMPILE_RESULT
|
||||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
||||||
LOG_DESCRIPTION "Source that should compile."
|
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\)"
|
- "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
|
||||||
- "Inspect.cmake:[0-9]+ \(enable_language\)"
|
- "Inspect.cmake:[0-9]+ \(enable_language\)"
|
||||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||||
|
checks:
|
||||||
|
- "Detecting C compiler ABI info"
|
||||||
directories:
|
directories:
|
||||||
source: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
source: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||||
binary: "[^"]*/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\)"
|
- "[^"]*/Modules/CMakeTestCXXCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
|
||||||
- "Inspect.cmake:[0-9]+ \(enable_language\)"
|
- "Inspect.cmake:[0-9]+ \(enable_language\)"
|
||||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||||
|
checks:
|
||||||
|
- "Detecting CXX compiler ABI info"
|
||||||
directories:
|
directories:
|
||||||
source: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
source: "[^"]*/Tests/RunCMake/try_compile/Inspect-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||||
binary: "[^"]*/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/CMakeDetermineCompilerABI.cmake:[0-9]+ \(try_compile\)"
|
||||||
- "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
|
- "[^"]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)"
|
||||||
- "CMakeLists.txt:[0-9]+ \(project\)"
|
- "CMakeLists.txt:[0-9]+ \(project\)"
|
||||||
|
checks:
|
||||||
|
- "Detecting C compiler ABI info"
|
||||||
directories:
|
directories:
|
||||||
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||||
binary: "[^"]*/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:
|
backtrace:
|
||||||
- "ConfigureLog.cmake:[0-9]+ \(try_run\)"
|
- "ConfigureLog.cmake:[0-9]+ \(try_run\)"
|
||||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||||
|
checks:
|
||||||
|
- "Check 1"
|
||||||
description: "Source that should compile\."
|
description: "Source that should compile\."
|
||||||
directories:
|
directories:
|
||||||
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||||
@ -59,6 +63,9 @@ events:
|
|||||||
backtrace:
|
backtrace:
|
||||||
- "ConfigureLog.cmake:[0-9]+ \(try_run\)"
|
- "ConfigureLog.cmake:[0-9]+ \(try_run\)"
|
||||||
- "CMakeLists.txt:[0-9]+ \(include\)"
|
- "CMakeLists.txt:[0-9]+ \(include\)"
|
||||||
|
checks:
|
||||||
|
- "Check 2"
|
||||||
|
- "Check 1"
|
||||||
directories:
|
directories:
|
||||||
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
source: "[^"]*/Tests/RunCMake/try_run/ConfigureLog-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+"
|
||||||
binary: "[^"]*/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
|
NO_LOG
|
||||||
)
|
)
|
||||||
|
|
||||||
|
message(CHECK_START "Check 1")
|
||||||
try_run(RUN_RESULT COMPILE_RESULT
|
try_run(RUN_RESULT COMPILE_RESULT
|
||||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
||||||
LOG_DESCRIPTION "Source that should compile."
|
LOG_DESCRIPTION "Source that should compile."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
message(CHECK_START "Check 2")
|
||||||
try_run(RUN_RESULT COMPILE_RESULT
|
try_run(RUN_RESULT COMPILE_RESULT
|
||||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
||||||
RUN_OUTPUT_VARIABLE RUN_OUTPUT
|
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
|
try_run(RUN_RESULT COMPILE_RESULT
|
||||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureLog-test.c
|
||||||
|
Loading…
Reference in New Issue
Block a user