[Cmake-commits] [cmake-commits] king committed cmGlobalGenerator.cxx 1.257.2.3 1.257.2.4 cmGlobalGenerator.h 1.125.2.3 1.125.2.4

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Feb 11 18:14:37 EST 2010


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

Modified Files:
      Tag: CMake-2-8
	cmGlobalGenerator.cxx cmGlobalGenerator.h 
Log Message:
Fix rule hash persistence file generation

We store custom command rule hashes in CMakeFiles/CMakeRuleHashes.txt
persistently across CMake runs.  When the rule hash changes we delete
the custom command output file and write a new hash into the persistence
file.

This functionality was first added by the commit 'Introduce "rule
hashes" to help rebuild files when rules change.' (2008-06-02).
However, the implementation in cmGlobalGenerator::CheckRuleHashes kept
the file open for read when attempting to rewrite a new file.  On
Windows filesystems this prevented the new version of the file from
being written!  This caused the first set of rule hashes to be used
forever within a build tree, meaning that all custom commands whose
rules changed would be rebuilt every time CMake regenerated the build
tree.

In this commit we address the problem by splitting the read and write
operations into separate methods.  This ensures that the input stream is
closed before the output stream opens the file.


Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.125.2.3
retrieving revision 1.125.2.4
diff -C 2 -d -r1.125.2.3 -r1.125.2.4
*** cmGlobalGenerator.h	28 Jan 2010 21:47:50 -0000	1.125.2.3
--- cmGlobalGenerator.h	11 Feb 2010 23:14:34 -0000	1.125.2.4
***************
*** 336,339 ****
--- 336,341 ----
    std::map<cmStdString, RuleHash> RuleHashes;
    void CheckRuleHashes();
+   void CheckRuleHashes(std::string const& pfile, std::string const& home);
+   void WriteRuleHashes(std::string const& pfile);
  
    void WriteSummary();

Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.257.2.3
retrieving revision 1.257.2.4
diff -C 2 -d -r1.257.2.3 -r1.257.2.4
*** cmGlobalGenerator.cxx	28 Jan 2010 21:47:50 -0000	1.257.2.3
--- cmGlobalGenerator.cxx	11 Feb 2010 23:14:34 -0000	1.257.2.4
***************
*** 2069,2073 ****
--- 2069,2081 ----
    pfile += this->GetCMakeInstance()->GetCMakeFilesDirectory();
    pfile += "/CMakeRuleHashes.txt";
+   this->CheckRuleHashes(pfile, home);
+   this->WriteRuleHashes(pfile);
+ #endif
+ }
  
+ //----------------------------------------------------------------------------
+ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
+                                         std::string const& home)
+ {
  #if defined(_WIN32) || defined(__CYGWIN__)
    std::ifstream fin(pfile.c_str(), std::ios::in | std::ios::binary);
***************
*** 2075,2086 ****
    std::ifstream fin(pfile.c_str(), std::ios::in);
  #endif
-   bool goodStream = true;
    if(!fin)
      {
!     goodStream = false;
      }
    std::string line;
    std::string fname;
!   while(goodStream && cmSystemTools::GetLineFromStream(fin, line))
      {
      // Line format is a 32-byte hex string followed by a space
--- 2083,2093 ----
    std::ifstream fin(pfile.c_str(), std::ios::in);
  #endif
    if(!fin)
      {
!     return;
      }
    std::string line;
    std::string fname;
!   while(cmSystemTools::GetLineFromStream(fin, line))
      {
      // Line format is a 32-byte hex string followed by a space
***************
*** 2128,2132 ****
--- 2135,2143 ----
        }
      }
+ }
  
+ //----------------------------------------------------------------------------
+ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile)
+ {
    // Now generate a new persistence file with the current hashes.
    if(this->RuleHashes.empty())
***************
*** 2145,2149 ****
        }
      }
- #endif
  }
  
--- 2156,2159 ----



More information about the Cmake-commits mailing list