Skip to content

Commit

Permalink
MSVC: Don't overwrite version.h if it hasn't changed
Browse files Browse the repository at this point in the history
That avoids superfluous recompilation and linkage of project when nothing
has changed.
  • Loading branch information
lephilousophe authored and sev- committed Sep 20, 2019
1 parent 42707ca commit d16e6a7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions devtools/create_project/scripts/revision.vbs
Expand Up @@ -128,8 +128,9 @@ End Sub

' Output revision header file
Sub OutputRevisionHeader(str)
FSO.CopyFile rootFolder & "\\base\\internal_revision.h.in", targetFolder & "\\internal_revision.h"
FindReplaceInFile targetFolder & "\\internal_revision.h", "@REVISION@", str
FSO.CopyFile rootFolder & "\\base\\internal_revision.h.in", targetFolder & "\\internal_revision.h.tmp"
FindReplaceInFile targetFolder & "\\internal_revision.h.tmp", "@REVISION@", str
CompareFileAndReplace targetFolder & "\\internal_revision.h.tmp", targetFolder & "\\internal_revision.h"
End Sub

Function DetermineTortoiseSVNVersion()
Expand Down Expand Up @@ -482,3 +483,20 @@ Sub FindReplaceInFile(filename, to_find, replacement)
file.Write data
file.Close
End Sub

Sub CompareFileAndReplace(src_filename, dst_filename)
Dim file, src_data, dst_data
Set file = FSO.OpenTextFile(src_filename, 1, 0, 0)
src_data = file.ReadAll
file.Close
Set file = FSO.OpenTextFile(dst_filename, 1, 0, 0)
dst_data = file.ReadAll
file.Close
If StrComp(src_data, dst_data, vbBinaryCompare) = 0 Then
' Files are the same, just remove the source
FSO.DeleteFile src_filename
Else
' Files are different, overwrite the destination
FSO.MoveFile src_filename, dst_filename
End If
End Sub

0 comments on commit d16e6a7

Please sign in to comment.