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

Gedare Bloom gedare at rtems.org
Thu Mar 5 13:58:58 UTC 2020


On Thu, Mar 5, 2020 at 3:23 AM <chrisj at rtems.org> wrote:
>
> From: Chris Johns <chrisj at rtems.org>
>
> - 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 2921bab8..0eda461f 100755
> --- a/builder.py
> +++ b/builder.py
> @@ -505,15 +505,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 = []):

I'm trying to pay more attention to the Python code. This method
definition is overlong.


>          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}
> @@ -524,7 +526,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)
>
> @@ -539,6 +541,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):
> @@ -857,3 +880,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 3823c03f..c2693e20 100644
> --- a/libbsd.py
> +++ b/libbsd.py
> @@ -5278,8 +5278,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 84f22b76..e6f3c21c 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):
>          #
> --
> 2.23.0
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list