浏览代码

Ninja: Track when running to re-generate during a build

Tell CMake explicitly when it is re-running inside a `ninja` invocation
to re-generate the build system.
Brad King 5 年之前
父节点
当前提交
657820a00b
共有 4 个文件被更改,包括 7 次插入1 次删除
  1. 1 0
      Source/cmGlobalGenerator.cxx
  2. 1 1
      Source/cmGlobalNinjaGenerator.cxx
  3. 2 0
      Source/cmake.cxx
  4. 3 0
      Source/cmake.h

+ 1 - 0
Source/cmGlobalGenerator.cxx

@@ -2525,6 +2525,7 @@ void cmGlobalGenerator::AddGlobalTarget_RebuildCache(
   gti.PerConfig = false;
   cmCustomCommandLine singleLine;
   singleLine.push_back(cmSystemTools::GetCMakeCommand());
+  singleLine.push_back("--regenerate-during-build");
   singleLine.push_back("-S$(CMAKE_SOURCE_DIR)");
   singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
   gti.CommandLines.push_back(std::move(singleLine));

+ 1 - 1
Source/cmGlobalNinjaGenerator.cxx

@@ -1530,7 +1530,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
   {
     cmNinjaRule rule("RERUN_CMAKE");
     rule.Command =
-      cmStrCat(CMakeCmd(), " -S",
+      cmStrCat(CMakeCmd(), " --regenerate-during-build -S",
                lg->ConvertToOutputFormat(lg->GetSourceDirectory(),
                                          cmOutputConverter::SHELL),
                " -B",

+ 2 - 0
Source/cmake.cxx

@@ -663,6 +663,8 @@ void cmake::SetArgs(const std::vector<std::string>& args)
     } else if ((i < args.size() - 1) &&
                (arg.find("--check-stamp-list", 0) == 0)) {
       this->CheckStampList = args[++i];
+    } else if (arg == "--regenerate-during-build") {
+      this->RegenerateDuringBuild = true;
     }
 #if defined(CMAKE_HAVE_VS_GENERATORS)
     else if ((i < args.size() - 1) &&

+ 3 - 0
Source/cmake.h

@@ -547,6 +547,8 @@ public:
   }
   cmStateSnapshot GetCurrentSnapshot() const { return this->CurrentSnapshot; }
 
+  bool GetRegenerateDuringBuild() const { return this->RegenerateDuringBuild; }
+
 protected:
   void RunCheckForUnusedVariables();
   int HandleDeleteCacheVariables(const std::string& var);
@@ -621,6 +623,7 @@ private:
   FileExtensions FortranFileExtensions;
   bool ClearBuildSystem = false;
   bool DebugTryCompile = false;
+  bool RegenerateDuringBuild = false;
   std::unique_ptr<cmFileTimeCache> FileTimeCache;
   std::string GraphVizFile;
   InstalledFilesMap InstalledFiles;