--- a/targets/toolchain_gcc.py Tue Dec 30 22:47:15 2008 +0100
+++ b/targets/toolchain_gcc.py Sun Jan 04 17:25:22 2009 +0100
@@ -1,7 +1,9 @@
from wxPopen import ProcessLogger
+includes_re = re.compile('\s*#include\s*["<]([^">]*)[">].*') This abstract class contains GCC specific code.
@@ -15,6 +17,7 @@
self.buildpath = PuginsRootInstance._getBuildPath()
self.exe_path = os.path.join(self.buildpath, self.exe)
@@ -33,8 +36,33 @@
return open(self._GetMD5FileName(), "r").read()
+ def check_and_update_hash_and_deps(self, bn): + # Get latest computed hash and deps + oldhash, deps = self.srcmd5.get(bn,(None,[])) + src = open(os.path.join(self.buildpath, bn)).read() + newhash = hashlib.md5(src).hexdigest() + match = (oldhash == newhash) + # update direct dependencies + for l in src.splitlines(): + res = includes_re.match(l) + depfn = res.groups()[0] + if os.path.exists(os.path.join(self.buildpath, depfn)): + #print bn + " depends on "+depfn + # store that hashand deps + self.srcmd5[bn] = (newhash, deps) + # TODO detect cicular deps. + return reduce(operator.and_, map(self.check_and_update_hash_and_deps, deps), match)
# Retrieve toolchain user parameters
toolchain_params = self.PuginsRootInstance.BeremizRoot.getTargetType().getcontent()["value"]
@@ -52,56 +80,70 @@
self.logger.write("PLC :\n")
for CFile, CFLAGS in CFilesAndCFLAGS:
bn = os.path.basename(CFile)
obn = os.path.splitext(bn)[0]+".o"
- self.logger.write(" [CC] "+bn+" -> "+obn+"\n")
objectfilename = os.path.splitext(CFile)[0]+".o"
+ match = self.check_and_update_hash_and_deps(bn) - status, result, err_result = ProcessLogger(
- "\"%s\" -c \"%s\" -o \"%s\" %s %s"%
- (self.compiler, CFile, objectfilename, self._CFLAGS, CFLAGS)
+ self.logger.write(" [pass] "+bn+" -> "+obn+"\n")
- self.logger.write_error("C compilation of "+ bn +" failed.\n")
+ self.logger.write(" [CC] "+bn+" -> "+obn+"\n") + status, result, err_result = ProcessLogger( + "\"%s\" -c \"%s\" -o \"%s\" %s %s"% + (self.compiler, CFile, objectfilename, self._CFLAGS, CFLAGS) + self.logger.write_error("C compilation of "+ bn +" failed.\n") objs.append(objectfilename)
######### GENERATE library FILE ########################################
# Link all the object files into one binary file
self.logger.write("Linking :\n")
- # Generate list .o files
- listobjstring = '"' + '" "'.join(objs) + '"'
- ALLldflags = ' '.join(self.CustomLDFLAGS+self.PuginsRootInstance.LDFLAGS+[self._LDFLAGS])
- self.logger.write(" [CC] " + ' '.join(obns)+" -> " + self.exe + "\n")
- status, result, err_result = ProcessLogger(
- "\"%s\" %s -o \"%s\" %s"%
- # Calculate md5 key and get data for the new created PLC
- data=self.GetBinaryCode()
- self.md5key = hashlib.md5(data).hexdigest()
- # Store new PLC filename based on md5 key
- file = open(self._GetMD5FileName(), "w")
- file.write(self.md5key)
+ # Generate list .o files + listobjstring = '"' + '" "'.join(objs) + '"' + ALLldflags = ' '.join(self.CustomLDFLAGS+self.PuginsRootInstance.LDFLAGS+[self._LDFLAGS]) + self.logger.write(" [CC] " + ' '.join(obns)+" -> " + self.exe + "\n") + status, result, err_result = ProcessLogger( + "\"%s\" %s -o \"%s\" %s"% + # Calculate md5 key and get data for the new created PLC + data=self.GetBinaryCode() + self.md5key = hashlib.md5(data).hexdigest() + # Store new PLC filename based on md5 key + f = open(self._GetMD5FileName(), "w") + self.logger.write(" [pass] " + ' '.join(obns)+" -> " + self.exe + "\n")