targets/toolchain_makefile.py
changeset 573 f0c5fc74018d
parent 572 c965548cb6f7
child 677 607731b33026
equal deleted inserted replaced
572:c965548cb6f7 573:f0c5fc74018d
     1 import os, re
     1 import os, re, operator
     2 from wxPopen import ProcessLogger
     2 from wxPopen import ProcessLogger
     3 import hashlib
     3 import hashlib
     4 
     4 
     5 import time
     5 import time
     6 
     6 
    31             try:
    31             try:
    32                 return open(self._GetMD5FileName(), "r").read()
    32                 return open(self._GetMD5FileName(), "r").read()
    33             except IOError, e:
    33             except IOError, e:
    34                 return None
    34                 return None
    35 
    35 
       
    36     def concat_deps(self, bn):
       
    37         # read source
       
    38         src = open(os.path.join(self.buildpath, bn),"r").read()
       
    39         # update direct dependencies
       
    40         deps = []
       
    41         for l in src.splitlines():
       
    42             res = includes_re.match(l)
       
    43             if res is not None:
       
    44                 depfn = res.groups()[0]
       
    45                 if os.path.exists(os.path.join(self.buildpath, depfn)):
       
    46                     #print bn + " depends on "+depfn
       
    47                     deps.append(depfn)
       
    48         # recurse through deps
       
    49         # TODO detect cicular deps.
       
    50         return reduce(operator.concat, map(self.concat_deps, deps), src)
       
    51 
    36     def build(self):
    52     def build(self):
    37         srcfiles= []
    53         srcfiles= []
    38         cflags = []
    54         cflags = []
    39         wholesrcdata = "" 
    55         wholesrcdata = "" 
    40         print self.PluginsRootInstance.LocationCFilesAndCFLAGS
       
    41         for Location, CFilesAndCFLAGS, DoCalls in self.PluginsRootInstance.LocationCFilesAndCFLAGS:
    56         for Location, CFilesAndCFLAGS, DoCalls in self.PluginsRootInstance.LocationCFilesAndCFLAGS:
    42             # Get CFiles list to give it to makefile
    57             # Get CFiles list to give it to makefile
    43             for CFile, CFLAGS in CFilesAndCFLAGS:
    58             for CFile, CFLAGS in CFilesAndCFLAGS:
    44                 CFileName = os.path.basename(CFile)
    59                 CFileName = os.path.basename(CFile)
    45                 wholesrcdata += open(CFile, "r").read()
    60                 wholesrcdata += self.concat_deps(CFileName)
       
    61                 #wholesrcdata += open(CFile, "r").read()
    46                 srcfiles.append(CFileName)
    62                 srcfiles.append(CFileName)
    47                 if CFLAGS not in cflags:
    63                 if CFLAGS not in cflags:
    48                     cflags.append(CFLAGS)
    64                     cflags.append(CFLAGS)
    49                         
    65                         
    50         oldmd5 = self.md5key
    66         oldmd5 = self.md5key