From 8179a9ea2e1a0233c5b9f9caca68a5463f68eb61 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 15 Dec 2016 19:14:12 +0100 Subject: [PATCH] Don't modify file if contents hasn't changed. --- litex/build/tools.py | 3 +++ 1 file changed, 3 insertions(+) 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) -- 2.30.2