mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
instrumentation: Disallow invocation from initial cache files
Prepare for future changes which invalidate this approach due to the cadence at which query files are cleared.
This commit is contained in:
@@ -22,6 +22,7 @@ file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#include "cmInstrumentationQuery.h"
|
||||
#include "cmList.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmValue.h"
|
||||
#include "cmake.h"
|
||||
@@ -70,6 +71,13 @@ bool cmInstrumentationCommand(std::vector<std::string> const& args,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status.GetMakefile().GetCMakeInstance()->GetInInitialCache()) {
|
||||
status.GetMakefile().IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
"Cannot invoke cmake_instrumentation() within an initial cache file.");
|
||||
return false;
|
||||
}
|
||||
|
||||
struct Arguments : public ArgumentParser::ParseResult
|
||||
{
|
||||
ArgumentParser::NonEmpty<std::string> ApiVersion;
|
||||
|
||||
+2
-1
@@ -734,14 +734,15 @@ bool cmake::SetCacheArgs(std::vector<std::string> const& args)
|
||||
cmSystemTools::Error("No file name specified for -C");
|
||||
return false;
|
||||
}
|
||||
state->SetInInitialCache(true);
|
||||
cmSystemTools::Stdout(
|
||||
cmStrCat("loading initial cache file ", value, '\n'));
|
||||
// Resolve script path specified on command line
|
||||
// relative to $PWD.
|
||||
auto path = cmSystemTools::ToNormalizedPathOnDisk(value);
|
||||
state->InitializeFileAPI();
|
||||
state->InitializeInstrumentation();
|
||||
state->ReadListFile(args, path);
|
||||
state->SetInInitialCache(false);
|
||||
return true;
|
||||
} },
|
||||
|
||||
|
||||
@@ -697,6 +697,9 @@ public:
|
||||
void InitializeFileAPI();
|
||||
void InitializeInstrumentation();
|
||||
|
||||
bool GetInInitialCache() const { return this->InInitialCache; }
|
||||
void SetInInitialCache(bool v) { this->InInitialCache = v; }
|
||||
|
||||
cmState* GetState() const { return this->State.get(); }
|
||||
void SetCurrentSnapshot(cmStateSnapshot const& snapshot)
|
||||
{
|
||||
@@ -839,6 +842,7 @@ private:
|
||||
bool DebugTryCompile = false;
|
||||
bool FreshCache = false;
|
||||
bool RegenerateDuringBuild = false;
|
||||
bool InInitialCache = false;
|
||||
std::string CMakeListName;
|
||||
std::unique_ptr<cmFileTimeCache> FileTimeCache;
|
||||
std::string GraphVizFile;
|
||||
|
||||
@@ -235,7 +235,6 @@ instrument(cmake-command-parallel-install
|
||||
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
|
||||
COPY_QUERIES_GENERATED
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,3 @@
|
||||
^CMake Error at [^
|
||||
]*/initial\.cmake:1 \(cmake_instrumentation\):
|
||||
Cannot invoke cmake_instrumentation\(\) within an initial cache file.$
|
||||
Reference in New Issue
Block a user