targets/toolchain_gcc.py
changeset 290 3bd617ae7a05
parent 285 e5782a52dcea
child 297 8fca8b555808
equal deleted inserted replaced
289:d17bd2f00a87 290:3bd617ae7a05
    16         self.exe = PuginsRootInstance.GetProjectName() + self.extension
    16         self.exe = PuginsRootInstance.GetProjectName() + self.extension
    17         self.buildpath = PuginsRootInstance._getBuildPath()
    17         self.buildpath = PuginsRootInstance._getBuildPath()
    18         self.exe_path = os.path.join(self.buildpath, self.exe)
    18         self.exe_path = os.path.join(self.buildpath, self.exe)
    19         self.md5key = None
    19         self.md5key = None
    20         self.srcmd5 = {}
    20         self.srcmd5 = {}
       
    21 
       
    22     def getBuilderLDFLAGS(self):
       
    23         """
       
    24         Returns list of builder specific CFLAGS
       
    25         """
       
    26         return [self.PuginsRootInstance.BeremizRoot.getTargetType().getcontent()["value"].getCFLAGS()]
       
    27 
       
    28     def getBuilderCFLAGS(self):
       
    29         """
       
    30         Returns list of builder specific LDFLAGS
       
    31         """
       
    32         return self.PuginsRootInstance.LDFLAGS + \
       
    33                [self.PuginsRootInstance.BeremizRoot.getTargetType().getcontent()["value"].getLDFLAGS()]
    21 
    34 
    22     def GetBinaryCode(self):
    35     def GetBinaryCode(self):
    23         try:
    36         try:
    24             return open(self.exe_path, "rb").read()
    37             return open(self.exe_path, "rb").read()
    25         except Exception, e:
    38         except Exception, e:
    65                 
    78                 
    66     def build(self):
    79     def build(self):
    67         # Retrieve toolchain user parameters
    80         # Retrieve toolchain user parameters
    68         toolchain_params = self.PuginsRootInstance.BeremizRoot.getTargetType().getcontent()["value"]
    81         toolchain_params = self.PuginsRootInstance.BeremizRoot.getTargetType().getcontent()["value"]
    69         self.compiler = toolchain_params.getCompiler()
    82         self.compiler = toolchain_params.getCompiler()
    70         self._CFLAGS = toolchain_params.getCFLAGS()
       
    71         self.linker = toolchain_params.getLinker()
    83         self.linker = toolchain_params.getLinker()
    72         self._LDFLAGS = toolchain_params.getLDFLAGS()
    84 
       
    85         Builder_CFLAGS = ' '.join(self.getBuilderCFLAGS())
    73 
    86 
    74         ######### GENERATE OBJECT FILES ########################################
    87         ######### GENERATE OBJECT FILES ########################################
    75         obns = []
    88         obns = []
    76         objs = []
    89         objs = []
    77         for Location, CFilesAndCFLAGS, DoCalls in self.PuginsRootInstance.LocationCFilesAndCFLAGS:
    90         for Location, CFilesAndCFLAGS, DoCalls in self.PuginsRootInstance.LocationCFilesAndCFLAGS:
    96                     self.logger.write("   [CC]  "+bn+" -> "+obn+"\n")
   109                     self.logger.write("   [CC]  "+bn+" -> "+obn+"\n")
    97                     
   110                     
    98                     status, result, err_result = ProcessLogger(
   111                     status, result, err_result = ProcessLogger(
    99                            self.logger,
   112                            self.logger,
   100                            "\"%s\" -c \"%s\" -o \"%s\" %s %s"%
   113                            "\"%s\" -c \"%s\" -o \"%s\" %s %s"%
   101                                (self.compiler, CFile, objectfilename, self._CFLAGS, CFLAGS)
   114                                (self.compiler, CFile, objectfilename, Builder_CFLAGS, CFLAGS)
   102                            ).spin()
   115                            ).spin()
   103 
   116 
   104                     if status :
   117                     if status :
   105                         self.logger.write_error("C compilation of "+ bn +" failed.\n")
   118                         self.logger.write_error("C compilation of "+ bn +" failed.\n")
   106                         return False
   119                         return False
   115             objstring = []
   128             objstring = []
   116     
   129     
   117             # Generate list .o files
   130             # Generate list .o files
   118             listobjstring = '"' + '"  "'.join(objs) + '"'
   131             listobjstring = '"' + '"  "'.join(objs) + '"'
   119     
   132     
   120             ALLldflags = ' '.join(self.CustomLDFLAGS+self.PuginsRootInstance.LDFLAGS+[self._LDFLAGS])
   133             ALLldflags = ' '.join(self.getBuilderLDFLAGS())
   121     
   134     
   122             self.logger.write("   [CC]  " + ' '.join(obns)+" -> " + self.exe + "\n")
   135             self.logger.write("   [CC]  " + ' '.join(obns)+" -> " + self.exe + "\n")
   123     
   136     
   124             status, result, err_result = ProcessLogger(
   137             status, result, err_result = ProcessLogger(
   125                    self.logger,
   138                    self.logger,