浏览代码

instrumentation: Disable preBuild and postBuild hooks on Windows

The implementation does not work on Windows.

Issue: #26668
Martin Duffy 9 月之前
父节点
当前提交
0fbb927bdd

+ 4 - 4
Help/manual/cmake-instrumentation.7.rst

@@ -117,10 +117,10 @@ optional.
   should be one of the following:
   should be one of the following:
 
 
   * ``postGenerate``
   * ``postGenerate``
-  * ``preBuild`` (:ref:`Ninja Generators`. only, when ``ninja`` is invoked)
-  * ``postBuild`` (:ref:`Ninja Generators`. only, when ``ninja`` completes)
-  * ``preCMakeBuild`` (when ``cmake --build`` is invoked)
-  * ``postCMakeBuild`` (when ``cmake --build`` completes)
+  * ``preBuild`` (called when ``ninja`` is invoked; unavailable on Windows)
+  * ``postBuild`` (called when ``ninja`` completes; unavailable on Windows)
+  * ``preCMakeBuild`` (called when ``cmake --build`` is invoked)
+  * ``postCMakeBuild`` (called when ``cmake --build`` completes)
   * ``postInstall``
   * ``postInstall``
   * ``postTest``
   * ``postTest``
 
 

+ 7 - 4
Source/cmGlobalNinjaGenerator.cxx

@@ -1762,7 +1762,8 @@ void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os)
   this->WriteTargetRebuildManifest(os);
   this->WriteTargetRebuildManifest(os);
   this->WriteTargetClean(os);
   this->WriteTargetClean(os);
   this->WriteTargetHelp(os);
   this->WriteTargetHelp(os);
-#if !defined(CMAKE_BOOTSTRAP)
+#if !defined(CMAKE_BOOTSTRAP) && !defined(_WIN32)
+  // FIXME(#26668) This does not work on Windows
   if (this->GetCMakeInstance()
   if (this->GetCMakeInstance()
         ->GetInstrumentation()
         ->GetInstrumentation()
         ->HasPreOrPostBuildHook()) {
         ->HasPreOrPostBuildHook()) {
@@ -1843,7 +1844,8 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
   }
   }
   reBuild.ImplicitDeps.push_back(this->CMakeCacheFile);
   reBuild.ImplicitDeps.push_back(this->CMakeCacheFile);
 
 
-#if !defined(CMAKE_BOOTSTRAP)
+#if !defined(CMAKE_BOOTSTRAP) && !defined(_WIN32)
+  // FIXME(#26668) This does not work on Windows
   if (this->GetCMakeInstance()
   if (this->GetCMakeInstance()
         ->GetInstrumentation()
         ->GetInstrumentation()
         ->HasPreOrPostBuildHook()) {
         ->HasPreOrPostBuildHook()) {
@@ -2196,6 +2198,8 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os)
   }
   }
 }
 }
 
 
+#if !defined(CMAKE_BOOTSTRAP) && !defined(_WIN32)
+// FIXME(#26668) This does not work on Windows
 void cmGlobalNinjaGenerator::WriteTargetInstrument(std::ostream& os)
 void cmGlobalNinjaGenerator::WriteTargetInstrument(std::ostream& os)
 {
 {
   // Write rule
   // Write rule
@@ -2204,13 +2208,11 @@ void cmGlobalNinjaGenerator::WriteTargetInstrument(std::ostream& os)
     rule.Command = cmStrCat(
     rule.Command = cmStrCat(
       "\"", cmSystemTools::GetCTestCommand(), "\" --start-instrumentation \"",
       "\"", cmSystemTools::GetCTestCommand(), "\" --start-instrumentation \"",
       this->GetCMakeInstance()->GetHomeOutputDirectory(), "\"");
       this->GetCMakeInstance()->GetHomeOutputDirectory(), "\"");
-#ifndef _WIN32
     /*
     /*
      * On Unix systems, Ninja will prefix the command with `/bin/sh -c`.
      * On Unix systems, Ninja will prefix the command with `/bin/sh -c`.
      * Use exec so that Ninja is the parent process of the command.
      * Use exec so that Ninja is the parent process of the command.
      */
      */
     rule.Command = cmStrCat("exec ", rule.Command);
     rule.Command = cmStrCat("exec ", rule.Command);
-#endif
     rule.Description = "Collecting build metrics";
     rule.Description = "Collecting build metrics";
     rule.Comment = "Rule to initialize instrumentation daemon.";
     rule.Comment = "Rule to initialize instrumentation daemon.";
     rule.Restat = "1";
     rule.Restat = "1";
@@ -2231,6 +2233,7 @@ void cmGlobalNinjaGenerator::WriteTargetInstrument(std::ostream& os)
     WriteBuild(os, instrument);
     WriteBuild(os, instrument);
   }
   }
 }
 }
+#endif
 
 
 void cmGlobalNinjaGenerator::InitOutputPathPrefix()
 void cmGlobalNinjaGenerator::InitOutputPathPrefix()
 {
 {

+ 3 - 0
Source/cmGlobalNinjaGenerator.h

@@ -536,7 +536,10 @@ private:
   void WriteTargetRebuildManifest(std::ostream& os);
   void WriteTargetRebuildManifest(std::ostream& os);
   bool WriteTargetCleanAdditional(std::ostream& os);
   bool WriteTargetCleanAdditional(std::ostream& os);
   void WriteTargetClean(std::ostream& os);
   void WriteTargetClean(std::ostream& os);
+#if !defined(CMAKE_BOOTSTRAP) && !defined(_WIN32)
+  // FIXME(#26668) This does not work on Windows
   void WriteTargetInstrument(std::ostream& os);
   void WriteTargetInstrument(std::ostream& os);
+#endif
   void WriteTargetHelp(std::ostream& os);
   void WriteTargetHelp(std::ostream& os);
 
 
   void ComputeTargetDependsClosure(
   void ComputeTargetDependsClosure(

+ 2 - 0
Tests/RunCMake/Instrumentation/RunCMakeTest.cmake

@@ -115,6 +115,8 @@ instrument(cmake-command-bad-arg NO_WARN)
 instrument(cmake-command-parallel-install
 instrument(cmake-command-parallel-install
   BUILD INSTALL TEST NO_WARN INSTALL_PARALLEL DYNAMIC_QUERY
   BUILD INSTALL TEST NO_WARN INSTALL_PARALLEL DYNAMIC_QUERY
   CHECK_SCRIPT check-data-dir.cmake)
   CHECK_SCRIPT check-data-dir.cmake)
+
+# FIXME(#26668) This does not work on Windows
 if (UNIX AND ${RunCMake_GENERATOR} MATCHES "^Ninja")
 if (UNIX AND ${RunCMake_GENERATOR} MATCHES "^Ninja")
   instrument(cmake-command-ninja NO_WARN
   instrument(cmake-command-ninja NO_WARN
     BUILD_MAKE_PROGRAM
     BUILD_MAKE_PROGRAM