[cmake-commits] king committed cmDepends.cxx 1.14 1.15 cmDepends.h 1.11 1.12 cmLocalGenerator.h 1.88 1.89 cmLocalUnixMakefileGenerator3.cxx 1.221 1.222 cmLocalUnixMakefileGenerator3.h 1.76 1.77 cmMakefileTargetGenerator.cxx 1.74 1.75 cmake.cxx 1.343 1.344

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Dec 19 16:36:32 EST 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv32348/Source

Modified Files:
	cmDepends.cxx cmDepends.h cmLocalGenerator.h 
	cmLocalUnixMakefileGenerator3.cxx 
	cmLocalUnixMakefileGenerator3.h cmMakefileTargetGenerator.cxx 
	cmake.cxx 
Log Message:
ENH: Moved dependency integrity check from CheckBuildSystem over to a per-target UpdateDependencies step.  This greatly reduces the startup time for make processes and allows individual targets to be built without a global dependency check.


Index: cmLocalUnixMakefileGenerator3.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.h,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- cmLocalUnixMakefileGenerator3.h	18 Dec 2007 14:50:08 -0000	1.76
+++ cmLocalUnixMakefileGenerator3.h	19 Dec 2007 21:36:29 -0000	1.77
@@ -198,12 +198,15 @@
 
   std::string CreateMakeVariable(const char* sin, const char* s2in);
 
+  /** Called from command-line hook to bring dependencies up to date
+      for a target.  */
+  virtual bool UpdateDependencies(const char* tgtInfo, bool verbose);
+
   /** Called from command-line hook to scan dependencies.  */
-  virtual bool ScanDependencies(const char* tgtInfo);
+  bool ScanDependencies(const char* tgtInfo);
 
-  /** Called from command-line hook to check dependencies.  */
-  virtual void CheckDependencies(cmMakefile* mf, bool verbose,
-                                 bool clear);
+  /** Called from command-line hook to clear dependencies.  */
+  virtual void ClearDependencies(cmMakefile* mf, bool verbose);
   
   /** write some extra rules such as make test etc */
   void WriteSpecialTargetsTop(std::ostream& makefileStream);

Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- cmLocalGenerator.h	19 Dec 2007 08:56:13 -0000	1.88
+++ cmLocalGenerator.h	19 Dec 2007 21:36:29 -0000	1.89
@@ -157,13 +157,14 @@
   ///! for existing files convert to output path and short path if spaces
   std::string ConvertToOutputForExisting(const char* p);
   
-  /** Called from command-line hook to check dependencies.  */
-  virtual void CheckDependencies(cmMakefile* /* mf */, 
-                                 bool /* verbose */,
-                                 bool /* clear */) {};
+  /** Called from command-line hook to clear dependencies.  */
+  virtual void ClearDependencies(cmMakefile* /* mf */, 
+                                 bool /* verbose */) {}
   
-  /** Called from command-line hook to scan dependencies.  */
-  virtual bool ScanDependencies(const char* /* tgtInfo */) { return true; }
+  /** Called from command-line hook to update dependencies.  */
+  virtual bool UpdateDependencies(const char* /* tgtInfo */,
+                                  bool /*verbose*/)
+    { return true; }
 
   /** Compute the list of link libraries and directories for the given
       target and configuration.  */

Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.343
retrieving revision 1.344
diff -u -d -r1.343 -r1.344
--- cmake.cxx	19 Dec 2007 16:51:30 -0000	1.343
+++ cmake.cxx	19 Dec 2007 21:36:30 -0000	1.344
@@ -1353,6 +1353,10 @@
     // Internal CMake dependency scanning support.
     else if (args[1] == "cmake_depends" && args.size() >= 6)
       {
+      // Use the make system's VERBOSE environment variable to enable
+      // verbose output.
+      bool verbose = cmSystemTools::GetEnv("VERBOSE") != 0;
+
       // Create a cmake object instance to process dependencies.
       cmake cm;
       std::string gen;
@@ -1416,7 +1420,7 @@
         lgd->GetMakefile()->MakeStartDirectoriesCurrent();
 
         // Actually scan dependencies.
-        return lgd->ScanDependencies(depInfo.c_str())? 0 : 2;
+        return lgd->UpdateDependencies(depInfo.c_str(), verbose)? 0 : 2;
         }
       return 1;
       }
@@ -2549,7 +2553,11 @@
     // Check the dependencies in case source files were removed.
     std::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator());
     lgd->SetGlobalGenerator(ggd.get());
-    lgd->CheckDependencies(mf, verbose, this->ClearBuildSystem);
+
+    if(this->ClearBuildSystem)
+      {
+      lgd->ClearDependencies(mf, verbose);
+      }
 
     // Check for multiple output pairs.
     ggd->CheckMultipleOutputs(mf, verbose);

Index: cmDepends.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDepends.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- cmDepends.cxx	25 May 2006 13:47:30 -0000	1.14
+++ cmDepends.cxx	19 Dec 2007 21:36:29 -0000	1.15
@@ -48,7 +48,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmDepends::Check(const char *makeFile, const char *internalFile)
+bool cmDepends::Check(const char *makeFile, const char *internalFile)
 {
   // Dependency checks must be done in proper working directory.
   std::string oldcwd = ".";
@@ -61,12 +61,14 @@
     }
 
   // Check whether dependencies must be regenerated.
+  bool okay = true;
   std::ifstream fin(internalFile);
   if(!(fin && this->CheckDependencies(fin)))
     {
     // Clear all dependencies so they will be regenerated.
     this->Clear(makeFile);
-    this->Clear(internalFile);
+    cmSystemTools::RemoveFile(internalFile);
+    okay = false;
     }
 
   // Restore working directory.
@@ -74,6 +76,8 @@
     {
     cmSystemTools::ChangeDirectory(oldcwd.c_str());
     }
+
+  return okay;
 }
 
 //----------------------------------------------------------------------------
@@ -87,12 +91,6 @@
     cmSystemTools::Stdout(msg.str().c_str());
     }
 
-  // Remove the dependency mark file to be sure dependencies will be
-  // regenerated.
-  std::string markFile = file;
-  markFile += ".mark";
-  cmSystemTools::RemoveFile(markFile.c_str());
-  
   // Write an empty dependency file.
   cmGeneratedFileStream depFileStream(file);
   depFileStream
@@ -101,6 +99,14 @@
 }
 
 //----------------------------------------------------------------------------
+bool cmDepends::WriteDependencies(const char*, const char*,
+                                  std::ostream&, std::ostream&)
+{
+  // This should be implemented by the subclass.
+  return false;
+}
+
+//----------------------------------------------------------------------------
 bool cmDepends::CheckDependencies(std::istream& internalDepends)
 {
   // Parse dependencies from the stream.  If any dependee is missing

Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.221
retrieving revision 1.222
diff -u -d -r1.221 -r1.222
--- cmLocalUnixMakefileGenerator3.cxx	19 Dec 2007 19:28:46 -0000	1.221
+++ cmLocalUnixMakefileGenerator3.cxx	19 Dec 2007 21:36:29 -0000	1.222
@@ -1224,6 +1224,40 @@
 }
 
 //----------------------------------------------------------------------------
+bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
+                                                       bool verbose)
+{
+  std::string dir = cmSystemTools::GetFilenamePath(tgtInfo);
+  std::string internalDependFile = dir + "/depend.internal";
+  std::string dependFile = dir + "/depend.make";
+
+  // Check the implicit dependencies to see if they are up to date.
+  // The build.make file may have explicit dependencies for the object
+  // files but these will not affect the scanning process so they need
+  // not be considered.
+  cmDependsC checker;
+  checker.SetVerbose(verbose);
+  checker.SetFileComparison
+    (this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
+  if(!checker.Check(dependFile.c_str(), internalDependFile.c_str()))
+    {
+    // The dependencies must be regenerated.
+
+    // TODO: Make this like cmLocalUnixMakefileGenerator3::EchoDepend
+    std::string targetName = cmSystemTools::GetFilenameName(dir);
+    targetName = targetName.substr(0, targetName.length()-4);
+    fprintf(stdout, "Scanning dependencies of target %s\n", targetName.c_str());
+
+    return this->ScanDependencies(tgtInfo);
+    }
+  else
+    {
+    // The dependencies are already up-to-date.
+    return true;
+    }
+}
+
+//----------------------------------------------------------------------------
 bool cmLocalUnixMakefileGenerator3::ScanDependencies(const char* tgtInfo)
 {
   // The info file for this target
@@ -1403,11 +1437,6 @@
       }
     }
 
-  // dependencies were generated, so touch the mark file
-  ruleFileNameFull += ".mark";
-  std::ofstream fmark(ruleFileNameFull.c_str());
-  fmark << "Dependencies updated>" << std::endl;
-  
   return true;
 }
 
@@ -1619,9 +1648,8 @@
 
 
 //----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator3::CheckDependencies(cmMakefile* mf, 
-                                                      bool verbose,
-                                                      bool clear)
+void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
+                                                      bool verbose)
 {
   // Get the list of target files to check
   const char* infoDef = mf->GetDefinition("CMAKE_DEPEND_INFO_FILES");
@@ -1632,27 +1660,23 @@
   std::vector<std::string> files;
   cmSystemTools::ExpandListArgument(infoDef, files);
 
-  // For each info file run the check
-  cmDependsC checker;
-  checker.SetVerbose(verbose);
-  checker.SetFileComparison
-    (this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
+  // Each depend information file corresponds to a target.  Clear the
+  // dependencies for that target.
+  cmDepends clearer;
+  clearer.SetVerbose(verbose);
   for(std::vector<std::string>::iterator l = files.begin();
       l != files.end(); ++l)
     {
-    // either clear or check the files
     std::string dir = cmSystemTools::GetFilenamePath(l->c_str());
-    std::string internalDependFile = dir + "/depend.internal";
+
+    // Clear the implicit dependency makefile.
     std::string dependFile = dir + "/depend.make";
-    if (clear)
-      {
-      checker.Clear(internalDependFile.c_str());
-      checker.Clear(dependFile.c_str());
-      }
-    else
-      {
-      checker.Check(dependFile.c_str(), internalDependFile.c_str());
-      }
+    clearer.Clear(dependFile.c_str());
+
+    // Remove the internal dependency check file to force
+    // regeneration.
+    std::string internalDependFile = dir + "/depend.internal";
+    cmSystemTools::RemoveFile(internalDependFile.c_str());
     }
 }
 

Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- cmMakefileTargetGenerator.cxx	13 Dec 2007 20:54:29 -0000	1.74
+++ cmMakefileTargetGenerator.cxx	19 Dec 2007 21:36:29 -0000	1.75
@@ -519,15 +519,6 @@
     this->LocalGenerator->ExpandRuleVariables(*i, vars);
     }
 
-  // Make the target dependency scanning rule include cmake-time-known
-  // dependencies.  The others are handled by the check-build-system
-  // path.
-  std::string depMark =
-    this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
-  depMark += "/depend.make.mark";
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      depMark.c_str(),
-                                      depends, no_commands, false);
 
   // Write the rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
@@ -793,21 +784,6 @@
     this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
   depTarget += "/depend";
 
-  std::string depMark = depTarget;
-  depMark += ".make.mark";
-  depends.push_back(depMark);
-
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      depTarget.c_str(),
-                                      depends, commands, true);
-  depends.clear();
-
-  // Write the dependency generation rule.
-  std::string depEcho = "Scanning dependencies of target ";
-  depEcho += this->Target->GetName();
-  this->LocalGenerator->AppendEcho(commands, depEcho.c_str(),
-                                   cmLocalUnixMakefileGenerator3::EchoDepend);
-
   // Add a command to call CMake to scan dependencies.  CMake will
   // touch the corresponding depends file after scanning dependencies.
   cmOStringStream depCmd;
@@ -859,7 +835,7 @@
 
   // Write the rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      depMark.c_str(),
+                                      depTarget.c_str(),
                                       depends, commands, false);
 }
 

Index: cmDepends.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDepends.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- cmDepends.h	25 May 2006 13:47:30 -0000	1.11
+++ cmDepends.h	19 Dec 2007 21:36:29 -0000	1.12
@@ -55,8 +55,11 @@
   bool Write(const char *src, const char *obj,
     std::ostream &makeDepends, std::ostream &internalDepends);
   
-  /** Check dependencies for the target file.  */
-  void Check(const char *makeFile, const char* internalFile);
+  /** Check dependencies for the target file.  Returns true if
+      dependencies are okay and false if they must be generated.  If
+      they must be generated Clear has already been called to wipe out
+      the old dependencies.  */
+  bool Check(const char *makeFile, const char* internalFile);
 
   /** Clear dependencies for the target file so they will be regenerated.  */
   void Clear(const char *file);
@@ -70,7 +73,7 @@
   // Write dependencies for the target file to the given stream.
   // Return true for success and false for failure.
   virtual bool WriteDependencies(const char *src, const char* obj,
-    std::ostream& makeDepends, std::ostream& internalDepends)=0;
+    std::ostream& makeDepends, std::ostream& internalDepends);
 
   // Check dependencies for the target file in the given stream.
   // Return false if dependencies must be regenerated and true



More information about the Cmake-commits mailing list