Browse Source

instrumentation: Don't load query files before configure

Prevent the duplication of callbacks that came from loading instrumentation
queries both before and after configure.
Martin Duffy 2 months ago
parent
commit
9b65be6da5
2 changed files with 5 additions and 5 deletions
  1. 2 5
      Source/cmake.cxx
  2. 3 0
      Tests/RunCMake/Instrumentation/hook.cmake

+ 2 - 5
Source/cmake.cxx

@@ -2664,7 +2664,6 @@ int cmake::ActualConfigure()
     this->ConfigureLog = cm::make_unique<cmConfigureLog>(
       cmStrCat(this->GetHomeOutputDirectory(), "/CMakeFiles"_s),
       this->FileAPI->GetConfigureLogVersions());
-    this->Instrumentation->LoadQueries();
     this->Instrumentation->CheckCDashVariable();
   }
 #endif
@@ -3109,10 +3108,6 @@ int cmake::Generate()
         << ms.count() / 1000.0L << "s)";
     this->UpdateProgress(msg.str(), -1);
   }
-#if !defined(CMAKE_BOOTSTRAP)
-  this->Instrumentation->CollectTimingData(
-    cmInstrumentationQuery::Hook::PostGenerate);
-#endif
   if (!this->GraphVizFile.empty()) {
     std::cout << "Generate graphviz: " << this->GraphVizFile << '\n';
     this->GenerateGraphViz(this->GraphVizFile);
@@ -3132,6 +3127,8 @@ int cmake::Generate()
   this->SaveCache(this->GetHomeOutputDirectory());
 
 #if !defined(CMAKE_BOOTSTRAP)
+  this->Instrumentation->CollectTimingData(
+    cmInstrumentationQuery::Hook::PostGenerate);
   this->GlobalGenerator->WriteInstallJson();
   this->FileAPI->WriteReplies(cmFileAPI::IndexFor::Success);
 #endif

+ 3 - 0
Tests/RunCMake/Instrumentation/hook.cmake

@@ -76,6 +76,9 @@ endif()
 
 get_filename_component(dataDir ${index} DIRECTORY)
 get_filename_component(v1 ${dataDir} DIRECTORY)
+if (EXISTS ${v1}/${hook}.hook)
+  add_error("Received multiple triggers of the same hook: ${hook}")
+endif()
 file(WRITE ${v1}/${hook}.hook "${ERROR_MESSAGE}")
 
 if (NOT ERROR_MESSAGE MATCHES "^$")