[cmake-commits] king committed cmGlobalVisualStudio8Generator.cxx 1.23 1.24 cmLocalVisualStudio7Generator.cxx 1.202 1.203 cmake.cxx 1.329 1.330 cmake.h 1.93 1.94

cmake-commits at cmake.org cmake-commits at cmake.org
Sat Nov 10 08:15:16 EST 2007


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

Modified Files:
	cmGlobalVisualStudio8Generator.cxx 
	cmLocalVisualStudio7Generator.cxx cmake.cxx cmake.h 
Log Message:
ENH: Allow VS 7 project Rebuild and Solution Rebuild to work without re-running CMake for every project during the rebuild.


Index: cmake.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.h,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- cmake.h	6 Nov 2007 19:16:00 -0000	1.93
+++ cmake.h	10 Nov 2007 13:15:13 -0000	1.94
@@ -401,6 +401,7 @@
   std::string CXXEnvironment;
   std::string CCEnvironment;
   std::string CheckBuildSystemArgument;
+  std::string CheckStampFile;
   std::string CTestCommand;
   std::string CPackCommand;
   bool ClearBuildSystem;

Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.202
retrieving revision 1.203
diff -u -d -r1.202 -r1.203
--- cmLocalVisualStudio7Generator.cxx	9 Nov 2007 20:08:56 -0000	1.202
+++ cmLocalVisualStudio7Generator.cxx	10 Nov 2007 13:15:13 -0000	1.203
@@ -164,17 +164,40 @@
   this->WriteVCProjFile(fout,lname,target);
   }
 
+  // Create a helper file so CMake can determine when it is run
+  // through the rule created by AddVCProjBuildRule whether it really
+  // needs to regenerate the project.  This file lists its own
+  // dependencies.  If any file listed in it is newer than itself then
+  // CMake must rerun.  Otherwise the project file is up to date and
+  // the stamp file can just be touched.
+  {
+  std::string depName = this->Makefile->GetStartOutputDirectory();
+  depName += cmake::GetCMakeFilesDirectory();
+  depName += "/";
+  depName += lname;
+  depName += ".vcproj.stamp.depend";
+  std::ofstream depFile(depName.c_str());
+  depFile << "# CMake dependency list for corresponding VS project.\n";
+  std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
+  for(std::vector<std::string>::const_iterator lf = listFiles.begin();
+      lf != listFiles.end(); ++lf)
+    {
+    depFile << *lf << std::endl;
+    }
+  }
+
   // Touch a timestamp file used to determine when the project file is
   // out of date.
-  std::string stampName;
-  stampName = this->Makefile->GetStartOutputDirectory();
+  {
+  std::string stampName = this->Makefile->GetStartOutputDirectory();
   stampName += cmake::GetCMakeFilesDirectory();
   cmSystemTools::MakeDirectory(stampName.c_str());
   stampName += "/";
   stampName += lname;
   stampName += ".vcproj.stamp";
   std::ofstream stamp(stampName.c_str());
-  stamp << "# CMake timestamp for " << lname << ".vcproj" << std::endl;
+  stamp << "# CMake timestamp file for corresponding VS project.\n";
+  }
 }
 
 
@@ -203,6 +226,8 @@
     this->Convert(this->Makefile->GetHomeOutputDirectory(),
                   START_OUTPUT, UNCHANGED, true);
   commandLine.push_back(args);
+  commandLine.push_back("--check-stamp-file");
+  commandLine.push_back(stampName.c_str());
 
   std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
 

Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.329
retrieving revision 1.330
diff -u -d -r1.329 -r1.330
--- cmake.cxx	6 Nov 2007 19:16:00 -0000	1.329
+++ cmake.cxx	10 Nov 2007 13:15:13 -0000	1.330
@@ -104,6 +104,8 @@
 
 #include <memory> // auto_ptr
 
+static bool cmakeCheckStampFile(const char* stampName);
+
 void cmNeedBackwardsCompatibility(const std::string& variable,
   int access_type, void*, const char*, const cmMakefile*)
 {
@@ -520,6 +522,10 @@
       this->CheckBuildSystemArgument = args[++i];
       this->ClearBuildSystem = (atoi(args[++i].c_str()) > 0);
       }
+    else if((i < args.size()-1) && (arg.find("--check-stamp-file",0) == 0))
+      {
+      this->CheckStampFile = args[++i];
+      }
     else if(arg.find("-V",0) == 0)
       {
         this->Verbose = true;
@@ -1994,6 +2000,13 @@
     return -1;
     }
 
+  // If we are given a stamp file check if it is really out of date.
+  if(!this->CheckStampFile.empty() &&
+     cmakeCheckStampFile(this->CheckStampFile.c_str()))
+    {
+    return 0;
+    }
+
   // set the cmake command
   this->CMakeCommand = args[0];
   
@@ -3406,3 +3419,68 @@
   cmSystemTools::RemoveADirectory(destPath.c_str());
   return 0;
 }
+
+//----------------------------------------------------------------------------
+static bool cmakeCheckStampFile(const char* stampName)
+{
+  // If the stamp file still exists then it must really be out of
+  // date.
+  if(cmSystemTools::FileExists(stampName))
+    {
+    return false;
+    }
+
+  // The stamp file does not exist.  Use the stamp dependencies to
+  // determine whether it is really out of date.  This works in
+  // conjunction with cmLocalVisualStudio7Generator to avoid
+  // repeatedly re-running CMake when the user rebuilds the entire
+  // solution.
+  std::string stampDepends = stampName;
+  stampDepends += ".depend";
+#if defined(_WIN32) || defined(__CYGWIN__)
+  std::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary);
+#else
+  std::ifstream fin(stampDepends.c_str(), std::ios::in);
+#endif
+  if(!fin)
+    {
+    // The stamp dependencies file cannot be read.  Just assume the
+    // build system is really out of date.
+    return false;
+    }
+
+  // Compare the stamp dependencies against the dependency file itself.
+  cmFileTimeComparison ftc;
+  std::string dep;
+  while(cmSystemTools::GetLineFromStream(fin, dep))
+    {
+    int result;
+    if(dep.length() >= 1 && dep[0] != '#' &&
+       (!ftc.FileTimeCompare(stampDepends.c_str(), dep.c_str(), &result)
+        || result < 0))
+      {
+      // The stamp depends file is older than this dependency.  The
+      // build system is really out of date.
+      return false;
+      }
+    }
+
+  // The build system is up to date.  The stamp file has been removed
+  // by the VS IDE due to a "rebuild" request.  Just restore it.
+  std::ofstream stamp(stampName);
+  stamp << "# CMake timestamp file for corresponding VS project.\n";
+  if(stamp)
+    {
+    // Notify the user why CMake is not re-running.  It is safe to
+    // just print to stdout here because this code is only reachable
+    // through an undocumented flag used by the VS generator.
+    std::cout << "CMake does not need to re-run because the "
+              << "project timestamp is up-to-date.\n";
+    return true;
+    }
+  else
+    {
+    cmSystemTools::Error("Cannot restore timestamp ", stampName);
+    return false;
+    }
+}

Index: cmGlobalVisualStudio8Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio8Generator.cxx,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cmGlobalVisualStudio8Generator.cxx	9 Nov 2007 17:05:03 -0000	1.23
+++ cmGlobalVisualStudio8Generator.cxx	10 Nov 2007 13:15:13 -0000	1.24
@@ -124,6 +124,8 @@
         listFiles.erase(new_end, listFiles.end());
 
         // Create a rule to re-run CMake.
+        std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
+        stampName += CMAKE_CHECK_BUILD_SYSTEM_TARGET ".vcproj.stamp";
         const char* dsprule = mf->GetRequiredDefinition("CMAKE_COMMAND");
         cmCustomCommandLine commandLine;
         commandLine.push_back(dsprule);
@@ -137,6 +139,8 @@
                             cmLocalGenerator::START_OUTPUT,
                             cmLocalGenerator::UNCHANGED, true);
         commandLine.push_back(argB);
+        commandLine.push_back("--check-stamp-file");
+        commandLine.push_back(stampName.c_str());
         cmCustomCommandLines commandLines;
         commandLines.push_back(commandLine);
 
@@ -146,8 +150,6 @@
         // target.
         const char* no_main_dependency = 0;
         const char* no_working_directory = 0;
-        std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
-        stampName += CMAKE_CHECK_BUILD_SYSTEM_TARGET ".vcproj.stamp";
         mf->AddCustomCommandToOutput(
           stampName.c_str(), listFiles,
           no_main_dependency, commandLines, "Checking Build System",



More information about the Cmake-commits mailing list