From 1853f84abc64ed9dee6ef913760b0295c36a4ef5 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Fri, 3 Jul 2020 15:14:10 +0430 Subject: [PATCH] [py] overwrite harfbuzz.cc only when there is a needed change --- src/gen-harfbuzzcc.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gen-harfbuzzcc.py b/src/gen-harfbuzzcc.py index 7009cd540..dae4e1a86 100755 --- a/src/gen-harfbuzzcc.py +++ b/src/gen-harfbuzzcc.py @@ -12,7 +12,11 @@ if len (sys.argv) < 3: output_file = sys.argv[1] source_paths = sys.argv[2:] -with open (output_file, "wb") as f: - f.write ("".join ('#include "{}"\n'.format (x) - for x in source_paths - if x.endswith (".cc")).encode ()) +result = "".join ('#include "{}"\n'.format (x) for x in source_paths if x.endswith (".cc")).encode () + +with open (output_file, "rb") as f: + current = f.read() + +if result != current: + with open (output_file, "wb") as f: + f.write (result)