mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 23:28:32 -05:00
instrumentation: Fix crash on cmake_instrumentation() call in initial cache
This commit is contained in:
+14
-5
@@ -719,6 +719,7 @@ bool cmake::SetCacheArgs(std::vector<std::string> const& args)
|
||||
// relative to $PWD.
|
||||
auto path = cmSystemTools::ToNormalizedPathOnDisk(value);
|
||||
state->InitializeFileAPI();
|
||||
state->InitializeInstrumentation();
|
||||
state->ReadListFile(args, path);
|
||||
return true;
|
||||
} },
|
||||
@@ -2668,11 +2669,7 @@ int cmake::ActualConfigure()
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
this->InitializeFileAPI();
|
||||
this->FileAPI->ReadQueries();
|
||||
|
||||
this->Instrumentation = cm::make_unique<cmInstrumentation>(
|
||||
this->State->GetBinaryDirectory(),
|
||||
cmInstrumentation::LoadQueriesAfter::No);
|
||||
this->Instrumentation->ClearGeneratedQueries();
|
||||
this->InitializeInstrumentation();
|
||||
|
||||
if (!this->GetIsInTryCompile()) {
|
||||
this->TruncateOutputLog("CMakeConfigureLog.yaml");
|
||||
@@ -2939,6 +2936,18 @@ void cmake::InitializeFileAPI()
|
||||
#endif
|
||||
}
|
||||
|
||||
void cmake::InitializeInstrumentation()
|
||||
{
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
if (!this->Instrumentation) {
|
||||
this->Instrumentation = cm::make_unique<cmInstrumentation>(
|
||||
this->State->GetBinaryDirectory(),
|
||||
cmInstrumentation::LoadQueriesAfter::No);
|
||||
this->Instrumentation->ClearGeneratedQueries();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// handle a command line invocation
|
||||
int cmake::Run(std::vector<std::string> const& args, bool noconfigure)
|
||||
{
|
||||
|
||||
@@ -709,6 +709,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
void InitializeFileAPI();
|
||||
void InitializeInstrumentation();
|
||||
|
||||
cmState* GetState() const { return this->State.get(); }
|
||||
void SetCurrentSnapshot(cmStateSnapshot const& snapshot)
|
||||
|
||||
@@ -28,6 +28,7 @@ function(instrument test)
|
||||
set(v1 ${RunCMake_TEST_BINARY_DIR}/.cmake/instrumentation-${uuid}/v1)
|
||||
set(v1 ${v1} PARENT_SCOPE)
|
||||
set(query_dir ${CMAKE_CURRENT_LIST_DIR}/query)
|
||||
configure_file(${RunCMake_SOURCE_DIR}/initial.cmake.in ${RunCMake_BINARY_DIR}/initial.cmake)
|
||||
|
||||
# Clear previous instrumentation data
|
||||
# We can't use RunCMake_TEST_NO_CLEAN 0 because we preserve queries placed in the build tree after
|
||||
@@ -189,6 +190,10 @@ instrument(cmake-command-bad-arg NO_WARN)
|
||||
instrument(cmake-command-parallel-install
|
||||
BUILD INSTALL TEST NO_WARN INSTALL_PARALLEL DYNAMIC_QUERY
|
||||
CHECK_SCRIPT check-data-dir.cmake)
|
||||
instrument(cmake-command-initial-cache
|
||||
CONFIGURE_ARG "-C ${RunCMake_BINARY_DIR}/initial.cmake"
|
||||
CHECK_SCRIPT check-data-dir.cmake
|
||||
)
|
||||
instrument(cmake-command-resets-generated
|
||||
NO_WARN COPY_QUERIES_GENERATED
|
||||
CHECK_SCRIPT check-data-dir.cmake
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
CMake Warning \(dev\) at .*
|
||||
CMake's support for collecting instrumentation data is experimental. It is
|
||||
meant only for experimentation and feedback to CMake developers.
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
@@ -0,0 +1,5 @@
|
||||
set(CMAKE_EXPERIMENTAL_INSTRUMENTATION @uuid@)
|
||||
cmake_instrumentation(
|
||||
API_VERSION 1
|
||||
DATA_VERSION 1
|
||||
)
|
||||
Reference in New Issue
Block a user