[rtems-libbsd commit] waf: Change the test configure check for libdebugger to it's lib

Chris Johns chrisj at rtems.org
Thu Mar 5 10:57:26 UTC 2020


Module:    rtems-libbsd
Branch:    5-freebsd-12
Commit:    3cc039cdac77272a8e16b33ae5a53ccd89edf989
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=3cc039cdac77272a8e16b33ae5a53ccd89edf989

Author:    Chris Johns <chrisj at rtems.org>
Date:      Thu Mar  5 21:18:05 2020 +1100

waf: Change the test configure check for libdebugger to it's lib

- Add support for a 'test-if-library'

- Use rtems_waf's 'test_application()' fragment in the check_cc
  call

Closes #3948

---

 builder.py    | 30 +++++++++++++++++++++++++++---
 libbsd.py     |  4 ++--
 waf_libbsd.py | 28 +++++++++++++++++++++-------
 3 files changed, 50 insertions(+), 12 deletions(-)

diff --git a/builder.py b/builder.py
index 1679b6c..f5fe2af 100755
--- a/builder.py
+++ b/builder.py
@@ -502,15 +502,17 @@ class SourceFileIfHeaderComposer(SourceFileFragmentComposer):
 
 class TestFragementComposer(BuildSystemFragmentComposer):
 
-    def __init__(self, testName, fileFragments, runTest = True, netTest = False, extraLibs = []):
+    def __init__(self, testName, fileFragments, configTest = None, runTest = True, netTest = False, extraLibs = []):
         self.testName = testName
         self.fileFragments = fileFragments
+        self.configTest = configTest
         self.runTest = runTest
         self.netTest = netTest
         self.extraLibs = extraLibs
 
     def compose(self, path):
-        return ['tests', self.testName, ('default', None)], { 'files': self.fileFragments,
+        return ['tests', self.testName, ('default', None)], { 'configTest': self.configTest,
+                                                              'files': self.fileFragments,
                                                               'run': self.runTest,
                                                               'net': self.netTest,
                                                               'libs': self.extraLibs}
@@ -521,7 +523,7 @@ class TestIfHeaderComposer(TestFragementComposer):
         if headers is not list:
             headers = [headers]
         self.headers = headers
-        super(TestIfHeaderComposer, self).__init__(testName, fileFragments,
+        super(TestIfHeaderComposer, self).__init__(testName, fileFragments, 'header',
                                                    runTest = runTest, netTest = netTest,
                                                    extraLibs = extraLibs)
 
@@ -536,6 +538,27 @@ class TestIfHeaderComposer(TestFragementComposer):
         r[0][2] = (define_keys.strip(), self.headers)
         return r
 
+class TestIfLibraryComposer(TestFragementComposer):
+
+    def __init__(self, testName, libraries, fileFragments, runTest = True, netTest = False, extraLibs = []):
+        if libraries is not list:
+            libraries = [libraries]
+        self.libraries = libraries
+        super(TestIfLibraryComposer, self).__init__(testName, fileFragments, 'library',
+                                                    runTest = runTest, netTest = netTest,
+                                                    extraLibs = extraLibs)
+
+    def compose(self, path):
+        r = TestFragementComposer.compose(self, path)
+        define_keys = ''
+        for l in self.libraries:
+            l = l.upper()
+            for c in '\/-.':
+                l = l.replace(c, '_')
+            define_keys += ' ' + l
+        r[0][2] = (define_keys.strip(), self.libraries)
+        return r
+
 class KVMSymbolsFragmentComposer(BuildSystemFragmentComposer):
 
     def compose(self, path):
@@ -849,3 +872,4 @@ class ModuleManager(object):
 
         self.generator['source-if-header'] = SourceFileIfHeaderComposer
         self.generator['test-if-header'] = TestIfHeaderComposer
+        self.generator['test-if-library'] = TestIfLibraryComposer
diff --git a/libbsd.py b/libbsd.py
index e00496d..d791efe 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -5105,8 +5105,8 @@ class tests(builder.Module):
         self.addTest(mm.generator['test']('termios06', ['test_main',
                                                         '../termios/test_termios_driver',
                                                         '../termios/test_termios_utilities']))
-        self.addTest(mm.generator['test-if-header']('debugger01', 'rtems/rtems-debugger.h',
-                                                    ['test_main'], runTest = False, netTest = True,
+        self.addTest(mm.generator['test-if-library']('debugger01', 'debugger',
+                                                     ['test_main'], runTest = False, netTest = True,
                                                     extraLibs = ['debugger']))
         self.addTest(mm.generator['test']('crypto01', ['test_main']))
         self.addTest(mm.generator['test']('ipsec01', ['test_main']))
diff --git a/waf_libbsd.py b/waf_libbsd.py
index 46237c2..3a14541 100644
--- a/waf_libbsd.py
+++ b/waf_libbsd.py
@@ -109,7 +109,10 @@ class Builder(builder.ModuleManager):
                 if config != 'default':
                     if 'configure' not in data:
                         data['configure'] = { }
-                    data['configure'][config] = frag[0][2][1]
+                    configTest = frag[1]['configTest']
+                    if configTest not in data['configure']:
+                        data['configure'][configTest] = { }
+                    data['configure'][configTest][config] = frag[0][2][1]
                 if type(frag[1]) is list:
                     if config not in d[cpu]:
                         d[cpu][config] = []
@@ -149,12 +152,23 @@ class Builder(builder.ModuleManager):
 
     def bsp_configure(self, conf, arch_bsp):
         if 'configure' in self.data:
-            for cfg in self.data['configure']:
-                for h in self.data['configure'][cfg]:
-                    conf.check(header_name = h,
-                               features = "c",
-                               includes = conf.env.IFLAGS,
-                               mandatory = False)
+            for configTest in self.data['configure']:
+                for cfg in self.data['configure'][configTest]:
+                    if configTest == 'header':
+                        for h in self.data['configure'][configTest][cfg]:
+                            conf.check(header_name = h,
+                                       features = "c",
+                                       includes = conf.env.IFLAGS,
+                                       mandatory = False)
+                    elif configTest == 'library':
+                        for l in self.data['configure'][configTest][cfg]:
+                            conf.check_cc(lib = l,
+                                          fragment = rtems.test_application(),
+                                          execute = False,
+                                          mandatory = False)
+                    else:
+                        bld.fatal('invalid config test: %s' % (configTest))
+
 
     def build(self, bld):
         #



More information about the vc mailing list