Changeset a6a6d54 in rtems-libbsd


Ignore:
Timestamp:
Mar 27, 2018, 7:31:49 AM (15 months ago)
Author:
Christian Mauderer <christian.mauderer@…>
Branches:
eeb3fd5d9b07ac9a2e280cff60a1b762bd273a8d, 1e989998de954bef51e6c19cc3d64d39f32100aa
Children:
494b156
Parents:
d797c5d
git-author:
Christian Mauderer <christian.mauderer@…> (03/27/18 07:31:49)
git-committer:
Christian Mauderer <christian.mauderer@…> (04/10/18 06:55:28)
Message:

waf: Fix freebsd-to-rtems.py.

Update #3351

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • builder.py

    rd797c5d ra6a6d54  
    6666verboseMoreDetail = 3
    6767verboseDebug = 4
     68
     69def _cflagsIncludes(cflags, includes):
     70    if type(cflags) is not list:
     71        if cflags is not None:
     72            _cflags = cflags.split(' ')
     73        else:
     74            _cflags = [None]
     75    else:
     76        _cflags = cflags
     77    if type(includes) is not list:
     78        _includes = [includes]
     79    else:
     80        _includes = includes
     81    return _cflags, _includes
    6882
    6983def verbose(level = verboseInfo):
     
    448462        return ''
    449463
     464class SourceFileFragmentComposer(BuildSystemFragmentComposer):
     465
     466    def __init__(self, cflags = "default", includes = None):
     467        self.cflags, self.includes = _cflagsIncludes(cflags, includes)
     468
     469    def compose(self, path):
     470        if None in self.includes:
     471            flags = self.cflags
     472        else:
     473            flags = self.cflags + self.includes
     474        return ['sources', flags, ('default', None)], [path], self.cflags, self.includes
     475
     476class SourceFileIfHeaderComposer(SourceFileFragmentComposer):
     477
     478    def __init__(self, headers, cflags = "default", includes = None):
     479        if headers is not list:
     480            headers = [headers]
     481        self.headers = headers
     482        super(SourceFileIfHeaderComposer, self).__init__(cflags = cflags, includes = includes)
     483
     484    def compose(self, path):
     485        r = SourceFileFragmentComposer.compose(self, path)
     486        define_keys = ''
     487        for h in self.headers:
     488            h = h.upper()
     489            for c in '\/-.':
     490                h = h.replace(c, '_')
     491            define_keys += ' ' + h
     492        r[0][2] = (define_keys.strip(), self.headers)
     493        return r
     494
     495class TestFragementComposer(BuildSystemFragmentComposer):
     496
     497    def __init__(self, testName, fileFragments, runTest = True, netTest = False):
     498        self.testName = testName
     499        self.fileFragments = fileFragments
     500        self.runTest = runTest
     501        self.netTest = netTest
     502
     503    def compose(self, path):
     504        return ['tests', self.testName, ('default', None)], { 'files': self.fileFragments,
     505                                                              'run': self.runTest,
     506                                                              'net': self.netTest }
     507
     508class TestIfHeaderComposer(TestFragementComposer):
     509
     510    def __init__(self, testName, headers, fileFragments, runTest = True, netTest = False):
     511        if headers is not list:
     512            headers = [headers]
     513        self.headers = headers
     514        super(TestIfHeaderComposer, self).__init__(testName, fileFragments,
     515                                                   runTest = runTest, netTest = netTest)
     516
     517    def compose(self, path):
     518        r = TestFragementComposer.compose(self, path)
     519        define_keys = ''
     520        for h in self.headers:
     521            h = h.upper()
     522            for c in '\/-.':
     523                h = h.replace(c, '_')
     524            define_keys += ' ' + h
     525        r[0][2] = (define_keys.strip(), self.headers)
     526        return r
     527
     528class KVMSymbolsFragmentComposer(BuildSystemFragmentComposer):
     529
     530    def compose(self, path):
     531        return ['KVMSymbols', 'files', ('default', None)], [path], self.includes
     532
     533class RPCGENFragmentComposer(BuildSystemFragmentComposer):
     534
     535    def compose(self, path):
     536        return ['RPCGen', 'files', ('default', None)], [path]
     537
     538class RouteKeywordsFragmentComposer(BuildSystemFragmentComposer):
     539
     540    def compose(self, path):
     541        return ['RouteKeywords', 'files', ('default', None)], [path]
     542
     543class LexFragmentComposer(BuildSystemFragmentComposer):
     544
     545    def __init__(self, sym, dep, cflags = None, includes = None):
     546        self.sym = sym
     547        self.dep = dep
     548        self.cflags, self.includes = _cflagsIncludes(cflags, includes)
     549
     550    def compose(self, path):
     551        d = { 'file': path,
     552              'sym': self.sym,
     553              'dep': self.dep }
     554        if None not in self.cflags:
     555            d['cflags'] = self.cflags
     556        if None not in self.includes:
     557            d['includes'] = self.includes
     558        return ['lex', path, ('default', None)], d
     559
     560class YaccFragmentComposer(BuildSystemFragmentComposer):
     561
     562    def __init__(self, sym, header, cflags = None, includes = None):
     563        self.sym = sym
     564        self.header = header
     565        self.cflags, self.includes = _cflagsIncludes(cflags, includes)
     566
     567    def compose(self, path):
     568        d = { 'file': path,
     569              'sym': self.sym,
     570              'header': self.header }
     571        if None not in self.cflags:
     572            d['cflags'] = self.cflags
     573        if None not in self.includes:
     574            d['includes'] = self.includes
     575        return ['yacc', path, ('default', None)], d
     576
    450577#
    451578# File - a file in the source we move backwards and forwards.
     
    678805        for m in self.getEnabledModules():
    679806            self.modules[m].generate()
     807
     808    def setGenerators(self):
     809        self.generator['convert'] = Converter
     810        self.generator['no-convert'] = NoConverter
     811        self.generator['from-FreeBSD-to-RTEMS-UserSpaceSourceConverter'] = FromFreeBSDToRTEMSUserSpaceSourceConverter
     812        self.generator['from-RTEMS-To-FreeBSD-SourceConverter'] = FromRTEMSToFreeBSDSourceConverter
     813        self.generator['buildSystemFragmentComposer'] = BuildSystemFragmentComposer
     814
     815        self.generator['file'] = File
     816
     817        self.generator['path'] = PathComposer
     818        self.generator['freebsd-path'] = FreeBSDPathComposer
     819        self.generator['rtems-path'] = RTEMSPathComposer
     820        self.generator['cpu-path'] = CPUDependentFreeBSDPathComposer
     821        self.generator['target-src-cpu--path'] = TargetSourceCPUDependentPathComposer
     822
     823        self.generator['source'] = SourceFileFragmentComposer
     824        self.generator['test'] = TestFragementComposer
     825        self.generator['kvm-symbols'] = KVMSymbolsFragmentComposer
     826        self.generator['rpc-gen'] = RPCGENFragmentComposer
     827        self.generator['route-keywords'] = RouteKeywordsFragmentComposer
     828        self.generator['lex'] = LexFragmentComposer
     829        self.generator['yacc'] = YaccFragmentComposer
     830
     831        self.generator['source-if-header'] = SourceFileIfHeaderComposer
     832        self.generator['test-if-header'] = TestIfHeaderComposer
  • waf_libbsd.py

    rd797c5d ra6a6d54  
    4949else:
    5050    host_shell = ''
    51 
    52 def _cflagsIncludes(cflags, includes):
    53     if type(cflags) is not list:
    54         if cflags is not None:
    55             _cflags = cflags.split(' ')
    56         else:
    57             _cflags = [None]
    58     else:
    59         _cflags = cflags
    60     if type(includes) is not list:
    61         _includes = [includes]
    62     else:
    63         _includes = includes
    64     return _cflags, _includes
    65 
    66 class SourceFileFragmentComposer(builder.BuildSystemFragmentComposer):
    67 
    68     def __init__(self, cflags = "default", includes = None):
    69         self.cflags, self.includes = _cflagsIncludes(cflags, includes)
    70 
    71     def compose(self, path):
    72         if None in self.includes:
    73             flags = self.cflags
    74         else:
    75             flags = self.cflags + self.includes
    76         return ['sources', flags, ('default', None)], [path], self.cflags, self.includes
    77 
    78 class SourceFileIfHeaderComposer(SourceFileFragmentComposer):
    79 
    80     def __init__(self, headers, cflags = "default", includes = None):
    81         if headers is not list:
    82             headers = [headers]
    83         self.headers = headers
    84         super(SourceFileIfHeaderComposer, self).__init__(cflags = cflags, includes = includes)
    85 
    86     def compose(self, path):
    87         r = SourceFileFragmentComposer.compose(self, path)
    88         define_keys = ''
    89         for h in self.headers:
    90             h = h.upper()
    91             for c in '\/-.':
    92                 h = h.replace(c, '_')
    93             define_keys += ' ' + h
    94         r[0][2] = (define_keys.strip(), self.headers)
    95         return r
    96 
    97 class TestFragementComposer(builder.BuildSystemFragmentComposer):
    98 
    99     def __init__(self, testName, fileFragments, runTest = True, netTest = False):
    100         self.testName = testName
    101         self.fileFragments = fileFragments
    102         self.runTest = runTest
    103         self.netTest = netTest
    104 
    105     def compose(self, path):
    106         return ['tests', self.testName, ('default', None)], { 'files': self.fileFragments,
    107                                                               'run': self.runTest,
    108                                                               'net': self.netTest }
    109 
    110 class TestIfHeaderComposer(TestFragementComposer):
    111 
    112     def __init__(self, testName, headers, fileFragments, runTest = True, netTest = False):
    113         if headers is not list:
    114             headers = [headers]
    115         self.headers = headers
    116         super(TestIfHeaderComposer, self).__init__(testName, fileFragments,
    117                                                    runTest = runTest, netTest = netTest)
    118 
    119     def compose(self, path):
    120         r = TestFragementComposer.compose(self, path)
    121         define_keys = ''
    122         for h in self.headers:
    123             h = h.upper()
    124             for c in '\/-.':
    125                 h = h.replace(c, '_')
    126             define_keys += ' ' + h
    127         r[0][2] = (define_keys.strip(), self.headers)
    128         return r
    129 
    130 class KVMSymbolsFragmentComposer(builder.BuildSystemFragmentComposer):
    131 
    132     def compose(self, path):
    133         return ['KVMSymbols', 'files', ('default', None)], [path], self.includes
    134 
    135 class RPCGENFragmentComposer(builder.BuildSystemFragmentComposer):
    136 
    137     def compose(self, path):
    138         return ['RPCGen', 'files', ('default', None)], [path]
    139 
    140 class RouteKeywordsFragmentComposer(builder.BuildSystemFragmentComposer):
    141 
    142     def compose(self, path):
    143         return ['RouteKeywords', 'files', ('default', None)], [path]
    144 
    145 class LexFragmentComposer(builder.BuildSystemFragmentComposer):
    146 
    147     def __init__(self, sym, dep, cflags = None, includes = None):
    148         self.sym = sym
    149         self.dep = dep
    150         self.cflags, self.includes = _cflagsIncludes(cflags, includes)
    151 
    152     def compose(self, path):
    153         d = { 'file': path,
    154               'sym': self.sym,
    155               'dep': self.dep }
    156         if None not in self.cflags:
    157             d['cflags'] = self.cflags
    158         if None not in self.includes:
    159             d['includes'] = self.includes
    160         return ['lex', path, ('default', None)], d
    161 
    162 class YaccFragmentComposer(builder.BuildSystemFragmentComposer):
    163 
    164     def __init__(self, sym, header, cflags = None, includes = None):
    165         self.sym = sym
    166         self.header = header
    167         self.cflags, self.includes = _cflagsIncludes(cflags, includes)
    168 
    169     def compose(self, path):
    170         d = { 'file': path,
    171               'sym': self.sym,
    172               'header': self.header }
    173         if None not in self.cflags:
    174             d['cflags'] = self.cflags
    175         if None not in self.includes:
    176             d['includes'] = self.includes
    177         return ['yacc', path, ('default', None)], d
    17851
    17952#
     
    20275            sources = sorted(files)
    20376        return sources
    204 
    205     def setGenerators(self):
    206         #
    207         # Called when the builder.ModuleManager.__init__ is run
    208         #
    209         self.generator['convert'] = builder.Converter
    210         self.generator['no-convert'] = builder.NoConverter
    211         self.generator['from-FreeBSD-to-RTEMS-UserSpaceSourceConverter'] = builder.FromFreeBSDToRTEMSUserSpaceSourceConverter
    212         self.generator['from-RTEMS-To-FreeBSD-SourceConverter'] = builder.FromRTEMSToFreeBSDSourceConverter
    213         self.generator['buildSystemFragmentComposer'] = builder.BuildSystemFragmentComposer
    214 
    215         self.generator['file'] = builder.File
    216 
    217         self.generator['path'] = builder.PathComposer
    218         self.generator['freebsd-path'] = builder.FreeBSDPathComposer
    219         self.generator['rtems-path'] = builder.RTEMSPathComposer
    220         self.generator['cpu-path'] = builder.CPUDependentFreeBSDPathComposer
    221         self.generator['target-src-cpu--path'] = builder.TargetSourceCPUDependentPathComposer
    222 
    223         self.generator['source'] = SourceFileFragmentComposer
    224         self.generator['test'] = TestFragementComposer
    225         self.generator['kvm-symbols'] = KVMSymbolsFragmentComposer
    226         self.generator['rpc-gen'] = RPCGENFragmentComposer
    227         self.generator['route-keywords'] = RouteKeywordsFragmentComposer
    228         self.generator['lex'] = LexFragmentComposer
    229         self.generator['yacc'] = YaccFragmentComposer
    230 
    231         self.generator['source-if-header'] = SourceFileIfHeaderComposer
    232         self.generator['test-if-header'] = TestIfHeaderComposer
    23377
    23478    def generate(self, rtems_version):
Note: See TracChangeset for help on using the changeset viewer.