projects
/
litex.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a2938a7
)
Only write file if contents will change.
author
Tim 'mithro' Ansell
<me@mith.ro>
Thu, 29 Nov 2018 04:18:31 +0000
(20:18 -0800)
committer
Tim 'mithro' Ansell
<me@mith.ro>
Mon, 2 Sep 2019 21:26:41 +0000
(14:26 -0700)
litex/build/tools.py
patch
|
blob
|
history
diff --git
a/litex/build/tools.py
b/litex/build/tools.py
index 28e1937d5a64844b8d76837ecc509b36bcb152fc..8132620129cf7edff3f43066d247a5db783aeaac 100644
(file)
--- a/
litex/build/tools.py
+++ b/
litex/build/tools.py
@@
-28,8
+28,13
@@
def write_to_file(filename, contents, force_unix=False):
newline = None
if force_unix:
newline = "\n"
- with open(filename, "w", newline=newline) as f:
- f.write(contents)
+ old_contents = None
+ if os.path.exists(filename):
+ with open(filename, "r", newline=newline) as f:
+ old_contents = f.read()
+ if old_contents != contents:
+ with open(filename, "w", newline=newline) as f:
+ f.write(contents)
def arch_bits():