--- a/targets/toolchain_gcc.py Wed Jul 03 11:44:01 2024 +0200
+++ b/targets/toolchain_gcc.py Thu Jul 04 11:24:04 2024 +0200
@@ -38,6 +38,18 @@
includes_re = re.compile(r'\s*#include\s*["<]([^">]*)[">].*')
+def compute_file_md5(filetocheck): + with open(filetocheck, 'rb') as afile: + buf = afile.read(65536) + return hasher.hexdigest() class toolchain_gcc(object):
This abstract class contains GCC specific code.
@@ -136,9 +148,9 @@
# Get latest computed hash and deps
oldhash, deps = self.srcmd5.get(bn, (None, []))
- src = open(os.path.join(self.buildpath, bn)).read()
+ src = os.path.join(self.buildpath, bn) - newhash = hashlib.md5(src.encode()).hexdigest()
+ newhash = compute_file_md5(src) match = (oldhash == newhash)
@@ -256,7 +268,7 @@
self.CTRInstance.logger.write(" [pass] " + ' '.join(obns)+" -> " + self.bin + "\n")
# Calculate md5 key and get data for the new created PLC
- self.md5key = hashlib.md5(open(self.bin_path, "rb").read()).hexdigest()
+ self.md5key = compute_file_md5(self.bin_path) # Store new PLC filename based on md5 key
f = open(self._GetMD5FileName(), "w")