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.
Showing with 16 additions and 4 deletions