Avoid endlessly regenerating bindings after modifying CodegenRust.py.

This commit is contained in:
Josh Matthews 2013-07-09 14:33:55 -04:00
parent 34a35054e9
commit e1c406f594

View file

@ -24,16 +24,21 @@ def replaceFileIfChanged(filename, newContents):
Read a copy of the old file, so that we don't touch it if it hasn't changed. Read a copy of the old file, so that we don't touch it if it hasn't changed.
Returns True if the file was updated, false otherwise. Returns True if the file was updated, false otherwise.
""" """
oldFileContents = "" #XXXjdm This doesn't play well with make right now.
try: # Force the file to always be updated, or else changing CodegenRust.py
oldFile = open(filename, 'rb') # will cause many autogenerated bindings to be regenerated perpetually
oldFileContents = ''.join(oldFile.readlines()) # until the result is actually different.
oldFile.close()
except:
pass
if newContents == oldFileContents: #oldFileContents = ""
return False #try:
# oldFile = open(filename, 'rb')
# oldFileContents = ''.join(oldFile.readlines())
# oldFile.close()
#except:
# pass
#if newContents == oldFileContents:
# return False
f = open(filename, 'wb') f = open(filename, 'wb')
f.write(newContents) f.write(newContents)