From add76e7c44aff75bd72a2a22beb24579fbe3f723 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 11 Jul 2022 19:04:08 -0600 Subject: [PATCH] buildman: Return an error if there are maintainer warnings Detect warnings about missing maintain info and return result code 2 in that case. Signed-off-by: Simon Glass --- tools/buildman/README | 3 ++- tools/buildman/boards.py | 22 +++++++++++++++++----- tools/buildman/control.py | 10 +++++----- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/tools/buildman/README b/tools/buildman/README index 0666bc7d56..3ba08d0dac 100644 --- a/tools/buildman/README +++ b/tools/buildman/README @@ -1314,7 +1314,8 @@ Using boards.cfg This file is no-longer needed by buildman but it is still generated in the working directory. This helps avoid a delay on every build, since scanning all the Kconfig files takes a few seconds. Use the -R flag to force regeneration -of the file - in that case buildman exits after writing the file. +of the file - in that case buildman exits after writing the file. with exit code +2 if there was an error in the maintainer files. You should use 'buildman -nv ' instead of greoing the boards.cfg file, since it may be dropped altogether in future. diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py index 8832e40cd5..b30b344bc8 100644 --- a/tools/buildman/boards.py +++ b/tools/buildman/boards.py @@ -276,11 +276,13 @@ class MaintainersDatabase: value: tuple: str: Board status (e.g. 'Active') str: List of maintainers, separated by : + warnings (list of str): List of warnings due to missing status, etc. """ def __init__(self): """Create an empty database.""" self.database = {} + self.warnings = [] def get_status(self, target): """Return the status of the given board. @@ -296,7 +298,7 @@ class MaintainersDatabase: str: 'Active', 'Orphan' or '-'. """ if not target in self.database: - print(f"WARNING: no status info for '{target}'", file=sys.stderr) + self.warnings.append(f"WARNING: no status info for '{target}'") return '-' tmp = self.database[target][0] @@ -306,7 +308,7 @@ class MaintainersDatabase: return 'Active' if tmp.startswith('Orphan'): return 'Orphan' - print(f"WARNING: {tmp}: unknown status for '{target}'", file=sys.stderr) + self.warnings.append(f"WARNING: {tmp}: unknown status for '{target}'") return '-' def get_maintainers(self, target): @@ -320,7 +322,7 @@ class MaintainersDatabase: maintainers, they are separated with colons. """ if not target in self.database: - print(f"WARNING: no maintainers for '{target}'", file=sys.stderr) + self.warnings.append(f"WARNING: no maintainers for '{target}'") return '' return ':'.join(self.database[target][1]) @@ -677,6 +679,9 @@ class Boards: Args: params_list (list of dict): A list of the board parameters + + Returns: + list of str: List of warnings collected due to missing status, etc. """ database = MaintainersDatabase() for (dirpath, _, filenames) in os.walk('.'): @@ -688,6 +693,7 @@ class Boards: params['status'] = database.get_status(target) params['maintainers'] = database.get_maintainers(target) params_list[i] = params + return database.warnings @classmethod def format_and_output(cls, params_list, output): @@ -731,11 +737,17 @@ class Boards: jobs (int): The number of jobs to run simultaneously force (bool): Force to generate the output even if it is new quiet (bool): True to avoid printing a message if nothing needs doing + + Returns: + bool: True if all is well, False if there were warnings """ if not force and output_is_new(output): if not quiet: print(f'{output} is up to date. Nothing to do.') - return + return True params_list = self.scan_defconfigs(jobs) - self.insert_maintainers_info(params_list) + warnings = self.insert_maintainers_info(params_list) + for warn in warnings: + print(warn, file=sys.stderr) self.format_and_output(params_list, output) + return not warnings diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 79ce2f6978..0c75466fbd 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -188,12 +188,12 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None, board_file = os.path.join(options.output_dir, 'boards.cfg') brds = boards.Boards() - brds.ensure_board_list(board_file, - options.threads or multiprocessing.cpu_count(), - force=options.regen_board_list, - quiet=not options.verbose) + ok = brds.ensure_board_list(board_file, + options.threads or multiprocessing.cpu_count(), + force=options.regen_board_list, + quiet=not options.verbose) if options.regen_board_list: - return 0 + return 0 if ok else 2 brds.read_boards(board_file) exclude = [] -- 2.39.5