targets/toolchain_makefile.py
changeset 425 f390e9fdd2cf
child 508 73ecb803d8af
equal deleted inserted replaced
424:86a7c1d11bbd 425:f390e9fdd2cf
       
     1 import os, re, operator
       
     2 from wxPopen import ProcessLogger
       
     3 import hashlib, shutil
       
     4 from toolchain_gcc import toolchain_gcc
       
     5 
       
     6 includes_re =  re.compile('\s*#include\s*["<]([^">]*)[">].*')
       
     7 
       
     8 class toolchain_makefile(toolchain_gcc):
       
     9     """
       
    10     This abstract class contains GCC specific code.
       
    11     It cannot be used as this and should be inherited in a target specific
       
    12     class such as target_linux or target_win32
       
    13     """
       
    14 
       
    15     def build(self):
       
    16         srcfiles= []
       
    17         cflags = []
       
    18         for Location, CFilesAndCFLAGS, DoCalls in self.PluginsRootInstance.LocationCFilesAndCFLAGS:
       
    19             # Get CFiles list to give it to makefile 
       
    20             for CFile, CFLAGS in CFilesAndCFLAGS:
       
    21                 CFileName = os.path.basename(CFile)
       
    22                 srcfiles.append(CFileName)
       
    23                 if CFLAGS not in cflags:
       
    24                     cflags.append(CFLAGS)
       
    25                     
       
    26         beremizcommand = {"src": ' '.join(srcfiles),
       
    27                           "cflags": ' '.join(cflags)
       
    28                          }
       
    29         
       
    30         target = self.getTarget().getcontent()["value"]
       
    31         command = target.getCommand().split(' ') +\
       
    32                   [target.getBuildPath()] +\
       
    33                   [arg % beremizcommand for arg in target.getArguments().split(' ')] +\
       
    34                   target.getRule().split(' ')
       
    35         
       
    36         # Call Makefile to build PLC code and link it with target specific code
       
    37         status, result, err_result = ProcessLogger(self.PluginsRootInstance.logger,
       
    38                                                    command).spin()
       
    39         if status :
       
    40             self.PluginsRootInstance.logger.write_error(_("C compilation of %s failed.\n"))
       
    41             return False
       
    42         return True