Skip to content

Commit 28064f1

Browse files
committed
Use hash to determine changes to command files
1 parent 8292aff commit 28064f1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tools/toolchains/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,17 @@ def make_option_file(self, options, naming=".options_{}.txt"):
312312
""" Generate a via file for a pile of defines
313313
ARM, GCC, IAR cross compatible
314314
"""
315-
option_md5 = md5(' '.join(options).encode('utf-8')).hexdigest()
316-
via_file = join(self.build_dir, naming.format(option_md5))
317-
if not exists(via_file):
315+
to_write = " ".join(options).encode('utf-8')
316+
new_md5 = md5(to_write).hexdigest()
317+
via_file = join(self.build_dir, naming.format(new_md5))
318+
try:
319+
with open(via_file, "r") as fd:
320+
old_md5 = md5(fd.read().encode('utf-8')).hexdigest()
321+
except IOError:
322+
old_md5 = None
323+
if old_md5 != new_md5:
318324
with open(via_file, "w") as fd:
319-
string = " ".join(options)
320-
fd.write(string)
325+
fd.write(to_write)
321326
return via_file
322327

323328
def get_inc_file(self, includes):

0 commit comments

Comments
 (0)