From: Tim 'mithro' Ansell Date: Thu, 15 Dec 2016 18:14:12 +0000 (+0100) Subject: Don't modify file if contents hasn't changed. X-Git-Tag: 24jan2021_ls180~1919^2~3 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8179a9ea2e1a0233c5b9f9caca68a5463f68eb61;p=litex.git Don't modify file if contents hasn't changed. --- diff --git a/litex/build/tools.py b/litex/build/tools.py index 9e0880d5..34c054b1 100644 --- a/litex/build/tools.py +++ b/litex/build/tools.py @@ -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)