[rtems-libbsd commit] waf: Fix freebsd-to-rtems.py.

Christian Mauderer christianm at rtems.org
Tue Apr 10 07:07:50 UTC 2018


Module:    rtems-libbsd
Branch:    master
Commit:    a6a6d54909304ad8a401b8b3c946469bdb29c50f
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=a6a6d54909304ad8a401b8b3c946469bdb29c50f

Author:    Christian Mauderer <christian.mauderer at embedded-brains.de>
Date:      Tue Mar 27 09:31:49 2018 +0200

waf: Fix freebsd-to-rtems.py.

Update #3351

---

 builder.py    | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 waf_libbsd.py | 156 ----------------------------------------------------------
 2 files changed, 153 insertions(+), 156 deletions(-)

diff --git a/builder.py b/builder.py
index 2faf98d..e334f1a 100755
--- a/builder.py
+++ b/builder.py
@@ -66,6 +66,20 @@ verboseDetail = 2
 verboseMoreDetail = 3
 verboseDebug = 4
 
+def _cflagsIncludes(cflags, includes):
+    if type(cflags) is not list:
+        if cflags is not None:
+            _cflags = cflags.split(' ')
+        else:
+            _cflags = [None]
+    else:
+        _cflags = cflags
+    if type(includes) is not list:
+        _includes = [includes]
+    else:
+        _includes = includes
+    return _cflags, _includes
+
 def verbose(level = verboseInfo):
     return verboseLevel >= level
 
@@ -447,6 +461,119 @@ class BuildSystemFragmentComposer(object):
     def compose(self, path):
         return ''
 
+class SourceFileFragmentComposer(BuildSystemFragmentComposer):
+
+    def __init__(self, cflags = "default", includes = None):
+        self.cflags, self.includes = _cflagsIncludes(cflags, includes)
+
+    def compose(self, path):
+        if None in self.includes:
+            flags = self.cflags
+        else:
+            flags = self.cflags + self.includes
+        return ['sources', flags, ('default', None)], [path], self.cflags, self.includes
+
+class SourceFileIfHeaderComposer(SourceFileFragmentComposer):
+
+    def __init__(self, headers, cflags = "default", includes = None):
+        if headers is not list:
+            headers = [headers]
+        self.headers = headers
+        super(SourceFileIfHeaderComposer, self).__init__(cflags = cflags, includes = includes)
+
+    def compose(self, path):
+        r = SourceFileFragmentComposer.compose(self, path)
+        define_keys = ''
+        for h in self.headers:
+            h = h.upper()
+            for c in '\/-.':
+                h = h.replace(c, '_')
+            define_keys += ' ' + h
+        r[0][2] = (define_keys.strip(), self.headers)
+        return r
+
+class TestFragementComposer(BuildSystemFragmentComposer):
+
+    def __init__(self, testName, fileFragments, runTest = True, netTest = False):
+        self.testName = testName
+        self.fileFragments = fileFragments
+        self.runTest = runTest
+        self.netTest = netTest
+
+    def compose(self, path):
+        return ['tests', self.testName, ('default', None)], { 'files': self.fileFragments,
+                                                              'run': self.runTest,
+                                                              'net': self.netTest }
+
+class TestIfHeaderComposer(TestFragementComposer):
+
+    def __init__(self, testName, headers, fileFragments, runTest = True, netTest = False):
+        if headers is not list:
+            headers = [headers]
+        self.headers = headers
+        super(TestIfHeaderComposer, self).__init__(testName, fileFragments,
+                                                   runTest = runTest, netTest = netTest)
+
+    def compose(self, path):
+        r = TestFragementComposer.compose(self, path)
+        define_keys = ''
+        for h in self.headers:
+            h = h.upper()
+            for c in '\/-.':
+                h = h.replace(c, '_')
+            define_keys += ' ' + h
+        r[0][2] = (define_keys.strip(), self.headers)
+        return r
+
+class KVMSymbolsFragmentComposer(BuildSystemFragmentComposer):
+
+    def compose(self, path):
+        return ['KVMSymbols', 'files', ('default', None)], [path], self.includes
+
+class RPCGENFragmentComposer(BuildSystemFragmentComposer):
+
+    def compose(self, path):
+        return ['RPCGen', 'files', ('default', None)], [path]
+
+class RouteKeywordsFragmentComposer(BuildSystemFragmentComposer):
+
+    def compose(self, path):
+        return ['RouteKeywords', 'files', ('default', None)], [path]
+
+class LexFragmentComposer(BuildSystemFragmentComposer):
+
+    def __init__(self, sym, dep, cflags = None, includes = None):
+        self.sym = sym
+        self.dep = dep
+        self.cflags, self.includes = _cflagsIncludes(cflags, includes)
+
+    def compose(self, path):
+        d = { 'file': path,
+              'sym': self.sym,
+              'dep': self.dep }
+        if None not in self.cflags:
+            d['cflags'] = self.cflags
+        if None not in self.includes:
+            d['includes'] = self.includes
+        return ['lex', path, ('default', None)], d
+
+class YaccFragmentComposer(BuildSystemFragmentComposer):
+
+    def __init__(self, sym, header, cflags = None, includes = None):
+        self.sym = sym
+        self.header = header
+        self.cflags, self.includes = _cflagsIncludes(cflags, includes)
+
+    def compose(self, path):
+        d = { 'file': path,
+              'sym': self.sym,
+              'header': self.header }
+        if None not in self.cflags:
+            d['cflags'] = self.cflags
+        if None not in self.includes:
+            d['includes'] = self.includes
+        return ['yacc', path, ('default', None)], d
+
 #
 # File - a file in the source we move backwards and forwards.
 #
@@ -677,3 +804,29 @@ class ModuleManager(object):
     def generateBuild(self):
         for m in self.getEnabledModules():
             self.modules[m].generate()
+
+    def setGenerators(self):
+        self.generator['convert'] = Converter
+        self.generator['no-convert'] = NoConverter
+        self.generator['from-FreeBSD-to-RTEMS-UserSpaceSourceConverter'] = FromFreeBSDToRTEMSUserSpaceSourceConverter
+        self.generator['from-RTEMS-To-FreeBSD-SourceConverter'] = FromRTEMSToFreeBSDSourceConverter
+        self.generator['buildSystemFragmentComposer'] = BuildSystemFragmentComposer
+
+        self.generator['file'] = File
+
+        self.generator['path'] = PathComposer
+        self.generator['freebsd-path'] = FreeBSDPathComposer
+        self.generator['rtems-path'] = RTEMSPathComposer
+        self.generator['cpu-path'] = CPUDependentFreeBSDPathComposer
+        self.generator['target-src-cpu--path'] = TargetSourceCPUDependentPathComposer
+
+        self.generator['source'] = SourceFileFragmentComposer
+        self.generator['test'] = TestFragementComposer
+        self.generator['kvm-symbols'] = KVMSymbolsFragmentComposer
+        self.generator['rpc-gen'] = RPCGENFragmentComposer
+        self.generator['route-keywords'] = RouteKeywordsFragmentComposer
+        self.generator['lex'] = LexFragmentComposer
+        self.generator['yacc'] = YaccFragmentComposer
+
+        self.generator['source-if-header'] = SourceFileIfHeaderComposer
+        self.generator['test-if-header'] = TestIfHeaderComposer
diff --git a/waf_libbsd.py b/waf_libbsd.py
index eddfaf9..0529306 100644
--- a/waf_libbsd.py
+++ b/waf_libbsd.py
@@ -49,133 +49,6 @@ if windows:
 else:
     host_shell = ''
 
-def _cflagsIncludes(cflags, includes):
-    if type(cflags) is not list:
-        if cflags is not None:
-            _cflags = cflags.split(' ')
-        else:
-            _cflags = [None]
-    else:
-        _cflags = cflags
-    if type(includes) is not list:
-        _includes = [includes]
-    else:
-        _includes = includes
-    return _cflags, _includes
-
-class SourceFileFragmentComposer(builder.BuildSystemFragmentComposer):
-
-    def __init__(self, cflags = "default", includes = None):
-        self.cflags, self.includes = _cflagsIncludes(cflags, includes)
-
-    def compose(self, path):
-        if None in self.includes:
-            flags = self.cflags
-        else:
-            flags = self.cflags + self.includes
-        return ['sources', flags, ('default', None)], [path], self.cflags, self.includes
-
-class SourceFileIfHeaderComposer(SourceFileFragmentComposer):
-
-    def __init__(self, headers, cflags = "default", includes = None):
-        if headers is not list:
-            headers = [headers]
-        self.headers = headers
-        super(SourceFileIfHeaderComposer, self).__init__(cflags = cflags, includes = includes)
-
-    def compose(self, path):
-        r = SourceFileFragmentComposer.compose(self, path)
-        define_keys = ''
-        for h in self.headers:
-            h = h.upper()
-            for c in '\/-.':
-                h = h.replace(c, '_')
-            define_keys += ' ' + h
-        r[0][2] = (define_keys.strip(), self.headers)
-        return r
-
-class TestFragementComposer(builder.BuildSystemFragmentComposer):
-
-    def __init__(self, testName, fileFragments, runTest = True, netTest = False):
-        self.testName = testName
-        self.fileFragments = fileFragments
-        self.runTest = runTest
-        self.netTest = netTest
-
-    def compose(self, path):
-        return ['tests', self.testName, ('default', None)], { 'files': self.fileFragments,
-                                                              'run': self.runTest,
-                                                              'net': self.netTest }
-
-class TestIfHeaderComposer(TestFragementComposer):
-
-    def __init__(self, testName, headers, fileFragments, runTest = True, netTest = False):
-        if headers is not list:
-            headers = [headers]
-        self.headers = headers
-        super(TestIfHeaderComposer, self).__init__(testName, fileFragments,
-                                                   runTest = runTest, netTest = netTest)
-
-    def compose(self, path):
-        r = TestFragementComposer.compose(self, path)
-        define_keys = ''
-        for h in self.headers:
-            h = h.upper()
-            for c in '\/-.':
-                h = h.replace(c, '_')
-            define_keys += ' ' + h
-        r[0][2] = (define_keys.strip(), self.headers)
-        return r
-
-class KVMSymbolsFragmentComposer(builder.BuildSystemFragmentComposer):
-
-    def compose(self, path):
-        return ['KVMSymbols', 'files', ('default', None)], [path], self.includes
-
-class RPCGENFragmentComposer(builder.BuildSystemFragmentComposer):
-
-    def compose(self, path):
-        return ['RPCGen', 'files', ('default', None)], [path]
-
-class RouteKeywordsFragmentComposer(builder.BuildSystemFragmentComposer):
-
-    def compose(self, path):
-        return ['RouteKeywords', 'files', ('default', None)], [path]
-
-class LexFragmentComposer(builder.BuildSystemFragmentComposer):
-
-    def __init__(self, sym, dep, cflags = None, includes = None):
-        self.sym = sym
-        self.dep = dep
-        self.cflags, self.includes = _cflagsIncludes(cflags, includes)
-
-    def compose(self, path):
-        d = { 'file': path,
-              'sym': self.sym,
-              'dep': self.dep }
-        if None not in self.cflags:
-            d['cflags'] = self.cflags
-        if None not in self.includes:
-            d['includes'] = self.includes
-        return ['lex', path, ('default', None)], d
-
-class YaccFragmentComposer(builder.BuildSystemFragmentComposer):
-
-    def __init__(self, sym, header, cflags = None, includes = None):
-        self.sym = sym
-        self.header = header
-        self.cflags, self.includes = _cflagsIncludes(cflags, includes)
-
-    def compose(self, path):
-        d = { 'file': path,
-              'sym': self.sym,
-              'header': self.header }
-        if None not in self.cflags:
-            d['cflags'] = self.cflags
-        if None not in self.includes:
-            d['includes'] = self.includes
-        return ['yacc', path, ('default', None)], d
-
 #
 # The waf builder for libbsd.
 #
@@ -202,35 +75,6 @@ class Builder(builder.ModuleManager):
             sources = sorted(files)
         return sources
 
-    def setGenerators(self):
-        #
-        # Called when the builder.ModuleManager.__init__ is run
-        #
-        self.generator['convert'] = builder.Converter
-        self.generator['no-convert'] = builder.NoConverter
-        self.generator['from-FreeBSD-to-RTEMS-UserSpaceSourceConverter'] = builder.FromFreeBSDToRTEMSUserSpaceSourceConverter
-        self.generator['from-RTEMS-To-FreeBSD-SourceConverter'] = builder.FromRTEMSToFreeBSDSourceConverter
-        self.generator['buildSystemFragmentComposer'] = builder.BuildSystemFragmentComposer
-
-        self.generator['file'] = builder.File
-
-        self.generator['path'] = builder.PathComposer
-        self.generator['freebsd-path'] = builder.FreeBSDPathComposer
-        self.generator['rtems-path'] = builder.RTEMSPathComposer
-        self.generator['cpu-path'] = builder.CPUDependentFreeBSDPathComposer
-        self.generator['target-src-cpu--path'] = builder.TargetSourceCPUDependentPathComposer
-
-        self.generator['source'] = SourceFileFragmentComposer
-        self.generator['test'] = TestFragementComposer
-        self.generator['kvm-symbols'] = KVMSymbolsFragmentComposer
-        self.generator['rpc-gen'] = RPCGENFragmentComposer
-        self.generator['route-keywords'] = RouteKeywordsFragmentComposer
-        self.generator['lex'] = LexFragmentComposer
-        self.generator['yacc'] = YaccFragmentComposer
-
-        self.generator['source-if-header'] = SourceFileIfHeaderComposer
-        self.generator['test-if-header'] = TestIfHeaderComposer
-
     def generate(self, rtems_version):
 
         def _dataInsert(data, cpu, frag):



More information about the vc mailing list