From: Chris Johns <chr...@rtems.org> - Generate a config for all BSPs in an arch --- rtems-bsps | 92 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 12 deletions(-)
diff --git a/rtems-bsps b/rtems-bsps index 8f3a887b9d..79ea745753 100755 --- a/rtems-bsps +++ b/rtems-bsps @@ -1,7 +1,7 @@ #! /usr/bin/env python # # RTEMS (http://www.rtems.org/) -# Copyright 2020 Chris Johns (chr...@rtems.org) +# Copyright 2020, 2022 Chris Johns (chr...@rtems.org) # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -63,7 +63,10 @@ class ArchBsps: def _out(self, line=''): """Output a line to the output buffer.""" - self._output += [line] + if isinstance(line, list): + self._output += line + else: + self._output += [line] def _collect(self, ext): """Collect the config files from the source tree.""" @@ -266,7 +269,7 @@ class ArchBsps: (max_bsp, bsp, max_fb, family, p)) else: self._out('%-*s |%s' % (max_bsp, bsp, family)) - + def pairs(self, arch_selector=None, family_selector=None, show_path=False): """Generate output as pairs""" self._clear() @@ -290,11 +293,70 @@ class ArchBsps: self.archs[arch][family][bsp]) pair = arch + '/' + bsp pair = '%-*s %s' % (max_arch + max_bsp + 1, pair, p) - + self._out(pair) else: self._out('%s/%s' % (arch, bsp)) + def config(self, arch_selector=None, family_selector=None): + """Generate output as pairs""" + self._clear() + self._out(['# Generated by rtems-bsp', + '[DEFAULT]', + '# Build', + 'RTEMS_BUILD_LABEL = DEFAULT', + 'RTEMS_DEBUG = False', + 'RTEMS_PROFILING = False', + 'RTEMS_POSIX_API = True', + '# Tests', + 'BUILD_TESTS = False', + 'BUILD_BENCHMARKS = False', + 'BUILD_FSTESTS = False', + 'BUILD_LIBTESTS = False', + 'BUILD_MPTESTS = False', + 'BUILD_PSXTESTS = False', + 'BUILD_PSXTMTESTS = False', + 'BUILD_RHEALSTONE = False', + 'BUILD_SAMPLES = True', + 'BUILD_SMPTESTS = False', + 'BUILD_SPTESTS = False', + 'BUILD_TMTESTS = False', + 'BUILD_UNITTESTS = False', + 'BUILD_VALIDATIONTESTS = False', + 'RTEMS_TEST_VERBOSITY = Normal', + '# Compliler', + '; WARNING_FLAGS = -Wall', + '; CC_WARNING_FLAGS = -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs', + '; CXX_WARNING_FLAGS = ', + '; OPTIMIZATION_FLAGS = -O2 -g -fdata-sections -ffunction-sections', + '; BSP_OPTIMIZATION_FLAGS = ${OPTIMIZATION_FLAGS}', + '; CPUKIT_OPTIMIZATION_FLAGS = ${OPTIMIZATION_FLAGS}', + '; TEST_OPTIMIZATION_FLAGS = ${OPTIMIZATION_FLAGS}', + '; LINKFLAGS = ', + '; LDFLAGS = -Wl,--gc-sections', + '# BSP', + 'BSP_VERBOSE_FATAL_EXTENSION = 1', + 'BSP_PRINT_EXCEPTION_CONTEXT = 1', + 'BSP_RESET_BOARD_AT_EXIT = 1']) + self._out() + max_arch = self._max_arch_len() + max_bsp = self._max_bsp_len() + if arch_selector is None: + arch_matcher = [] + else: + arch_matcher = [a.strip() for a in arch_selector.split(',')] + if family_selector is None: + family_matcher = [] + else: + family_matcher = [f.strip() for f in family_selector.split(',')] + for arch in sorted(self.archs.keys()): + if arch_selector is None or arch in arch_matcher: + for family in sorted(self.archs[arch].keys()): + if family_selector is None or family in family_matcher: + for bsp in sorted(self.archs[arch][family].keys()): + self._out('[%s/%s]' % (arch, bsp)) + self._out() + def run(args): """Runs the command""" @@ -331,6 +393,10 @@ def run(args): '--pairs', help='Output architectures and BSPs in CPU/BSP format', action='store_true') + argsp.add_argument('-C', + '--config', + help='Output architectures and BSPs in `config.ini` format', + action='store_true') argopts = argsp.parse_args(args[1:]) @@ -345,15 +411,17 @@ def run(args): family_selector=argopts.family, show_path=argopts.paths, show_title=argopts.title) + elif argopts.pairs: + ab.pairs(arch_selector=argopts.arch, + family_selector=argopts.family, + show_path=argopts.paths) + elif argopts.config: + ab.config(arch_selector=argopts.arch, + family_selector=argopts.family) else: - if argopts.pairs: - ab.pairs(arch_selector=argopts.arch, - family_selector=argopts.family, - show_path=argopts.paths) - else: - ab.text(arch_selector=argopts.arch, - family_selector=argopts.family, - show_path=argopts.paths) + ab.text(arch_selector=argopts.arch, + family_selector=argopts.family, + show_path=argopts.paths) print(os.linesep.join(ab.output())) -- 2.37.1 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel