Fixed MD5 computation for makefile based toolchain, helps avoiding unnecessary builds
--- a/LPCBeremiz.py Thu Feb 17 10:11:04 2011 +0100
+++ b/LPCBeremiz.py Thu Feb 17 15:59:56 2011 +0100
@@ -375,7 +375,7 @@
elif os.path.isfile(srcpath):
shutil.copy2(srcpath, dstpath)
-[SIMULATION_MODE, ONLINE_MODE] = range(2)
+[SIMULATION_MODE, TRANSFER_MODE] = range(2)
class LPCPluginsRoot(PluginsRoot):
@@ -494,7 +494,7 @@
if self.StatusTimer and not self.StatusTimer.IsRunning():
# Start the status Timer
- self.StatusTimer.Start(milliseconds=1000, oneShot=False)
+ self.StatusTimer.Start(milliseconds=2000, oneShot=False)
if self.previous_plcstate=="Started":
if self.DebugAvailable() and self.GetIECProgramsAndVariables():
@@ -507,7 +507,7 @@
elif self.StatusTimer and self.StatusTimer.IsRunning():
self.StatusTimer.Stop()
- if self.CurrentMode == ONLINE_MODE:
+ if self.CurrentMode == TRANSFER_MODE:
if self.OnlineMode == "BOOTLOADER":
self.BeginTransfer()
@@ -795,7 +795,7 @@
def _Transfer(self):
if self.CurrentMode is None and self.OnlineMode != "OFF":
- self.CurrentMode = ONLINE_MODE
+ self.CurrentMode = TRANSFER_MODE
PluginsRoot._build(self)
--- a/targets/toolchain_makefile.py Thu Feb 17 10:11:04 2011 +0100
+++ b/targets/toolchain_makefile.py Thu Feb 17 15:59:56 2011 +0100
@@ -14,7 +14,9 @@
self.SetBuildPath(self.PluginsRootInstance._getBuildPath())
def SetBuildPath(self, buildpath):
- self.buildpath = buildpath
+ if self.buildpath != buildpath:
+ self.buildpath = buildpath
+ self.md5key = None
def GetBinaryCode(self):
return None
@@ -34,8 +36,9 @@
def build(self):
srcfiles= []
cflags = []
+ wholesrcdata = ""
+ print self.PluginsRootInstance.LocationCFilesAndCFLAGS
for Location, CFilesAndCFLAGS, DoCalls in self.PluginsRootInstance.LocationCFilesAndCFLAGS:
- wholesrcdata = ""
# Get CFiles list to give it to makefile
for CFile, CFLAGS in CFilesAndCFLAGS:
CFileName = os.path.basename(CFile)
@@ -43,32 +46,39 @@
srcfiles.append(CFileName)
if CFLAGS not in cflags:
cflags.append(CFLAGS)
-
- self.md5key = hashlib.md5(wholesrcdata).hexdigest()
- props = self.PluginsRootInstance.GetProjectProperties()
- self.md5key += '#'.join([props[key] for key in ['companyName',
- 'projectName',
- 'productName']])
- self.md5key += '#' #+','.join(map(str,time.localtime()))
- # Store new PLC filename based on md5 key
- f = open(self._GetMD5FileName(), "w")
- f.write(self.md5key)
- f.close()
- beremizcommand = {"src": ' '.join(srcfiles),
- "cflags": ' '.join(cflags),
- "md5": '"'+self.md5key+'"'
- }
-
- target = self.PluginsRootInstance.GetTarget().getcontent()["value"]
- command = target.getCommand().split(' ') +\
- [target.getBuildPath()] +\
- [arg % beremizcommand for arg in target.getArguments().split(' ')] +\
- target.getRule().split(' ')
-
- # Call Makefile to build PLC code and link it with target specific code
- status, result, err_result = ProcessLogger(self.PluginsRootInstance.logger,
- command).spin()
- if status :
- self.PluginsRootInstance.logger.write_error(_("C compilation of %s failed.\n"))
- return False
- return True
+
+ oldmd5 = self.md5key
+ self.md5key = hashlib.md5(wholesrcdata).hexdigest()
+ props = self.PluginsRootInstance.GetProjectProperties()
+ self.md5key += '#'.join([props[key] for key in ['companyName',
+ 'projectName',
+ 'productName']])
+ self.md5key += '#' #+','.join(map(str,time.localtime()))
+ # Store new PLC filename based on md5 key
+ f = open(self._GetMD5FileName(), "w")
+ f.write(self.md5key)
+ f.close()
+
+ if oldmd5 != self.md5key :
+ beremizcommand = {"src": ' '.join(srcfiles),
+ "cflags": ' '.join(cflags),
+ "md5": '"'+self.md5key+'"'
+ }
+
+ target = self.PluginsRootInstance.GetTarget().getcontent()["value"]
+ command = target.getCommand().split(' ') +\
+ [target.getBuildPath()] +\
+ [arg % beremizcommand for arg in target.getArguments().split(' ')] +\
+ target.getRule().split(' ')
+
+ # Call Makefile to build PLC code and link it with target specific code
+ status, result, err_result = ProcessLogger(self.PluginsRootInstance.logger,
+ command).spin()
+ if status :
+ self.PluginsRootInstance.logger.write_error(_("C compilation of %s failed.\n"))
+ return False
+ return True
+ else :
+ self.PluginsRootInstance.logger.write(_("Source didn't change, no build.\n"))
+ return True
+