Преглед на файлове

ENH: added support for forcing recomputation of depends

Ken Martin преди 20 години
родител
ревизия
e559aa11ac

+ 16 - 0
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -418,6 +418,22 @@ void cmGlobalUnixMakefileGenerator3
   commands.push_back(lg->GetRecursiveMakeCall("Makefile2","clean"));
   lg->WriteMakeRule(makefileStream, "The main clean target", "clean", 
                     depends, commands);
+
+  // write the depend rule, really a recompute depends rule
+  depends.clear();
+  commands.clear();
+  std::string cmakefileName = "Makefile.cmake";
+  std::string runRule =
+    "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
+  runRule += " --check-build-system ";
+  runRule += lg->Convert(cmakefileName.c_str(),cmLocalGenerator::NONE,
+                         cmLocalGenerator::SHELL);
+  runRule += " 1";
+  
+  commands.push_back(runRule);
+  lg->WriteMakeRule(makefileStream, "clear depends", 
+                    "depend", 
+                    depends, commands);
 }
 
 

+ 4 - 2
Source/cmLocalGenerator.h

@@ -135,8 +135,10 @@ public:
   std::string ConvertToOutputForExisting(const char* p);
   
   /** Called from command-line hook to check dependencies.  */
-  virtual void CheckDependencies(cmMakefile* /* mf */, bool /* verbose */) {};
-
+  virtual void CheckDependencies(cmMakefile* /* mf */, 
+                                 bool /* verbose */,
+                                 bool /* clear */) {};
+  
   /** Called from command-line hook to scan dependencies.  */
   virtual bool ScanDependencies(std::vector<std::string> const& /* args */) {return true;};
 

+ 12 - 3
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -1164,7 +1164,8 @@ cmLocalUnixMakefileGenerator3
     "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
   runRule += " --check-build-system ";
   runRule += this->Convert(cmakefileName.c_str(),NONE,SHELL);
-
+  runRule += " 0";
+  
   std::vector<std::string> no_depends;
   std::vector<std::string> commands;
   commands.push_back(runRule);
@@ -2883,7 +2884,8 @@ void cmLocalUnixMakefileGenerator3
 
 //----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::CheckDependencies(cmMakefile* mf, 
-                                                      bool verbose)
+                                                      bool verbose,
+                                                      bool clear)
 {
   // Get the list of languages that may have sources to check.
   const char* langDef = mf->GetDefinition("CMAKE_DEPENDS_LANGUAGES");
@@ -2914,7 +2916,14 @@ void cmLocalUnixMakefileGenerator3::CheckDependencies(cmMakefile* mf,
           checker(this->GetDependsChecker(*l, ".", f->c_str(), verbose));
         if(checker.get())
           {
-          checker->Check();
+          if (clear)
+            {
+            checker->Clear();
+            }
+          else
+            {
+            checker->Check();
+            }
           }
         }
       }

+ 2 - 1
Source/cmLocalUnixMakefileGenerator3.h

@@ -128,7 +128,8 @@ public:
   virtual bool ScanDependencies(std::vector<std::string> const& args);
 
   /** Called from command-line hook to check dependencies.  */
-  virtual void CheckDependencies(cmMakefile* mf, bool verbose);
+  virtual void CheckDependencies(cmMakefile* mf, bool verbose,
+                                 bool clear);
   
   /** write some extra rules suahc as make test etc */
   void WriteSpecialTargetsTop(std::ostream& makefileStream);

+ 4 - 1
Source/cmake.cxx

@@ -92,6 +92,8 @@ void cmNeedBackwardsCompatibility(const std::string& variable,
 cmake::cmake()
 {
   m_DebugTryCompile = false;
+  m_ClearBuildSystem = false;
+  
 #ifdef __APPLE__
   struct rlimit rlp;
   if(!getrlimit(RLIMIT_STACK, &rlp))
@@ -304,6 +306,7 @@ void cmake::SetArgs(const std::vector<std::string>& args)
     else if((i < args.size()-1) && (arg.find("--check-build-system",0) == 0))
       {
       m_CheckBuildSystem = args[++i];
+      m_ClearBuildSystem = (atoi(args[++i].c_str()) > 0);
       }
     else if(arg.find("-V",0) == 0)
       {
@@ -1637,7 +1640,7 @@ int cmake::CheckBuildSystem()
     {
     std::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator());
     lgd->SetGlobalGenerator(ggd);
-    lgd->CheckDependencies(mf, verbose);
+    lgd->CheckDependencies(mf, verbose, m_ClearBuildSystem);
     }
 
   // No need to rerun.

+ 1 - 0
Source/cmake.h

@@ -303,6 +303,7 @@ private:
   std::string m_CXXEnvironment;
   std::string m_CCEnvironment;
   std::string m_CheckBuildSystem;
+  bool m_ClearBuildSystem;
   bool m_DebugTryCompile;
   
   void UpdateConversionPathTable();