Don't modify file if contents hasn't changed.
authorTim 'mithro' Ansell <mithro@mithis.com>
Thu, 15 Dec 2016 18:14:12 +0000 (19:14 +0100)
committerTim 'mithro' Ansell <mithro@mithis.com>
Thu, 15 Dec 2016 18:14:12 +0000 (19:14 +0100)
litex/build/tools.py

index 9e0880d594cb697b85864c2a683e345923fa57b4..34c054b16ec69a25122780bde7d9f0d56b0b5e02 100644 (file)
@@ -23,6 +23,9 @@ def write_to_file(filename, contents, force_unix=False):
     newline = None
     if force_unix:
         newline = "\n"
+    if os.path.exists(filename):
+        if open(filename, "r", newline=newline).read() == contents:
+            return
     with open(filename, "w", newline=newline) as f:
         f.write(contents)