targets/toolchain_gcc.py
changeset 1735 c02818d7e29f
parent 1734 750eeb7230a1
child 1736 7e61baa047f0
--- a/targets/toolchain_gcc.py	Mon Aug 14 22:23:17 2017 +0300
+++ b/targets/toolchain_gcc.py	Mon Aug 14 22:30:41 2017 +0300
@@ -41,7 +41,7 @@
         self.CTRInstance = CTRInstance
         self.buildpath = None
         self.SetBuildPath(self.CTRInstance._getBuildPath())
-    
+
     def getBuilderCFLAGS(self):
         """
         Returns list of builder specific CFLAGS
@@ -60,19 +60,19 @@
         Returns compiler
         """
         return self.CTRInstance.GetTarget().getcontent().getCompiler()
-      
+
     def getLinker(self):
         """
         Returns linker
         """
         return self.CTRInstance.GetTarget().getcontent().getLinker()
-               
+
     def GetBinaryCode(self):
         try:
             return open(self.exe_path, "rb").read()
         except Exception, e:
             return None
-        
+
     def _GetMD5FileName(self):
         return os.path.join(self.buildpath, "lastbuildPLC.md5")
 
@@ -82,7 +82,7 @@
             os.remove(self._GetMD5FileName())
         except Exception, e:
             pass
-    
+
     def GetBinaryCodeMD5(self):
         if self.md5key is not None:
             return self.md5key
@@ -91,7 +91,7 @@
                 return open(self._GetMD5FileName(), "r").read()
             except Exception, e:
                 return None
-    
+
     def SetBuildPath(self, buildpath):
         if self.buildpath != buildpath:
             self.buildpath = buildpath
@@ -99,7 +99,7 @@
             self.exe_path = os.path.join(self.buildpath, self.exe)
             self.md5key = None
             self.srcmd5 = {}
-            
+
     def append_cfile_deps(self, src, deps):
         for l in src.splitlines():
             res = includes_re.match(l)
@@ -107,7 +107,7 @@
                 depfn = res.groups()[0]
                 if os.path.exists(os.path.join(self.buildpath, depfn)):
                     deps.append(depfn)
-                    
+
     def concat_deps(self, bn):
         # read source
         src = open(os.path.join(self.buildpath, bn),"r").read()
@@ -117,7 +117,7 @@
         # recurse through deps
         # TODO detect cicular deps.
         return reduce(operator.concat, map(self.concat_deps, deps), src)
-        
+
     def check_and_update_hash_and_deps(self, bn):
         # Get latest computed hash and deps
         oldhash, deps = self.srcmd5.get(bn,(None,[]))
@@ -137,7 +137,7 @@
         # recurse through deps
         # TODO detect cicular deps.
         return reduce(operator.and_, map(self.check_and_update_hash_and_deps, deps), match)
-        
+
     def calc_source_md5(self):
         wholesrcdata = ""
         for Location, CFilesAndCFLAGS, DoCalls in self.CTRInstance.LocationCFilesAndCFLAGS:
@@ -146,10 +146,10 @@
                 CFileName = os.path.basename(CFile)
                 wholesrcdata += self.concat_deps(CFileName)
         return hashlib.md5(wholesrcdata).hexdigest()
-    
+
     def calc_md5(self):
         return hashlib.md5(self.GetBinaryCode()).hexdigest()
-    
+
     def build(self):
         # Retrieve compiler and linker
         self.compiler = self.getCompiler()
@@ -167,7 +167,7 @@
                     self.CTRInstance.logger.write(".".join(map(str,Location))+" :\n")
                 else:
                     self.CTRInstance.logger.write(_("PLC :\n"))
-                
+
             for CFile, CFLAGS in CFilesAndCFLAGS:
                 if CFile.endswith(".c"):
                     bn = os.path.basename(CFile)
@@ -175,14 +175,14 @@
                     objectfilename = os.path.splitext(CFile)[0]+".o"
 
                     match = self.check_and_update_hash_and_deps(bn)
-                    
+
                     if match:
                         self.CTRInstance.logger.write("   [pass]  "+bn+" -> "+obn+"\n")
                     else:
                         relink = True
 
                         self.CTRInstance.logger.write("   [CC]  "+bn+" -> "+obn+"\n")
-                        
+
                         status, result, err_result = ProcessLogger(
                                self.CTRInstance.logger,
                                "\"%s\" -c \"%s\" -o \"%s\" %s %s"%
@@ -204,14 +204,14 @@
         self.CTRInstance.logger.write(_("Linking :\n"))
         if relink:
             objstring = []
-    
+
             # Generate list .o files
             listobjstring = '"' + '"  "'.join(objs) + '"'
-    
+
             ALLldflags = ' '.join(self.getBuilderLDFLAGS())
-    
+
             self.CTRInstance.logger.write("   [CC]  " + ' '.join(obns)+" -> " + self.exe + "\n")
-    
+
             status, result, err_result = ProcessLogger(
                    self.CTRInstance.logger,
                    "\"%s\" %s -o \"%s\" %s"%
@@ -220,13 +220,13 @@
                         self.exe_path,
                         ALLldflags)
                    ).spin()
-            
+
             if status :
                 return False
-                
+
         else:
             self.CTRInstance.logger.write("   [pass]  " + ' '.join(obns)+" -> " + self.exe + "\n")
-        
+
         # Calculate md5 key and get data for the new created PLC
         self.md5key = self.calc_md5()
 
@@ -234,6 +234,5 @@
         f = open(self._GetMD5FileName(), "w")
         f.write(self.md5key)
         f.close()
-        
+
         return True
-