--- 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
+