targets/toolchain_gcc.py
branchpython3
changeset 3750 f62625418bff
parent 3739 99263915a91d
child 3755 ca814b175391
equal deleted inserted replaced
3749:fda6c1a37662 3750:f62625418bff
    22 # You should have received a copy of the GNU General Public License
    22 # You should have received a copy of the GNU General Public License
    23 # along with this program; if not, write to the Free Software
    23 # along with this program; if not, write to the Free Software
    24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    25 
    25 
    26 
    26 
    27 from __future__ import absolute_import
    27 
    28 import os
    28 import os
    29 import re
    29 import re
    30 import operator
    30 import operator
    31 import hashlib
    31 import hashlib
    32 from functools import reduce
    32 from functools import reduce
    50     def getBuilderCFLAGS(self):
    50     def getBuilderCFLAGS(self):
    51         """
    51         """
    52         Returns list of builder specific CFLAGS
    52         Returns list of builder specific CFLAGS
    53         """
    53         """
    54         cflags = [self.CTRInstance.GetTarget().getcontent().getCFLAGS()]
    54         cflags = [self.CTRInstance.GetTarget().getcontent().getCFLAGS()]
    55         if os.environ.has_key("CFLAGS"):
    55         if "CFLAGS" in os.environ:
    56             cflags.append(os.environ["CFLAGS"])
    56             cflags.append(os.environ["CFLAGS"])
    57         if os.environ.has_key("SYSROOT"):
    57         if "SYSROOT" in os.environ:
    58             cflags.append("--sysroot="+os.environ["SYSROOT"])
    58             cflags.append("--sysroot="+os.environ["SYSROOT"])
    59         return cflags
    59         return cflags
    60 
    60 
    61     def getBuilderLDFLAGS(self):
    61     def getBuilderLDFLAGS(self):
    62         """
    62         """
    63         Returns list of builder specific LDFLAGS
    63         Returns list of builder specific LDFLAGS
    64         """
    64         """
    65         ldflags = self.CTRInstance.LDFLAGS + \
    65         ldflags = self.CTRInstance.LDFLAGS + \
    66             [self.CTRInstance.GetTarget().getcontent().getLDFLAGS()]
    66             [self.CTRInstance.GetTarget().getcontent().getLDFLAGS()]
    67         if os.environ.has_key("LDFLAGS"):
    67         if "LDLAGS" in os.environ:
    68             ldflags.append(os.environ["LDFLAGS"])
    68             ldflags.append(os.environ["LDLAGS"])
    69         if os.environ.has_key("SYSROOT"):
    69         if "SYSROOT" in os.environ:
    70             ldflags.append("--sysroot="+os.environ["SYSROOT"])
    70             ldflags.append("--sysroot="+os.environ["SYSROOT"])
    71         return ldflags
    71         return ldflags
    72 
    72 
    73     def getCompiler(self):
    73     def getCompiler(self):
    74         """
    74         """
   126         # update direct dependencies
   126         # update direct dependencies
   127         deps = []
   127         deps = []
   128         self.append_cfile_deps(src, deps)
   128         self.append_cfile_deps(src, deps)
   129         # recurse through deps
   129         # recurse through deps
   130         # TODO detect cicular deps.
   130         # TODO detect cicular deps.
   131         return reduce(operator.concat, map(self.concat_deps, deps), src)
   131         return reduce(operator.concat, list(map(self.concat_deps, deps)), src)
   132 
   132 
   133     def check_and_update_hash_and_deps(self, bn):
   133     def check_and_update_hash_and_deps(self, bn):
   134         # Get latest computed hash and deps
   134         # Get latest computed hash and deps
   135         oldhash, deps = self.srcmd5.get(bn, (None, []))
   135         oldhash, deps = self.srcmd5.get(bn, (None, []))
   136         # read source
   136         # read source
   146             self.append_cfile_deps(src, deps)
   146             self.append_cfile_deps(src, deps)
   147             # store that hashand deps
   147             # store that hashand deps
   148             self.srcmd5[bn] = (newhash, deps)
   148             self.srcmd5[bn] = (newhash, deps)
   149         # recurse through deps
   149         # recurse through deps
   150         # TODO detect cicular deps.
   150         # TODO detect cicular deps.
   151         return reduce(operator.and_, map(self.check_and_update_hash_and_deps, deps), match)
   151         return reduce(operator.and_, list(map(self.check_and_update_hash_and_deps, deps)), match)
   152 
   152 
   153     def calc_source_md5(self):
   153     def calc_source_md5(self):
   154         wholesrcdata = ""
   154         wholesrcdata = ""
   155         for _Location, CFilesAndCFLAGS, _DoCalls in self.CTRInstance.LocationCFilesAndCFLAGS:
   155         for _Location, CFilesAndCFLAGS, _DoCalls in self.CTRInstance.LocationCFilesAndCFLAGS:
   156             # Get CFiles list to give it to makefile
   156             # Get CFiles list to give it to makefile