From patchwork Tue May 25 09:52:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12405 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id BAC44C3202 for ; Tue, 25 May 2021 09:52:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7794168926; Tue, 25 May 2021 11:52:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eiqsofPb"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9FDDB602AF for ; Tue, 25 May 2021 11:52:37 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 867FA344; Tue, 25 May 2021 11:52:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1621936357; bh=tMfrxX9B2T9sVXPgvMxRyLpEATqYD49uGqyijlbGOjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eiqsofPb7Cxc6TBjV4nv6oS1stl6vPXNsPcIuL//ddqTNBnNcK1rLcC/Km+3BB7GM lqyuY+RN2l1W4Re9w8psCcazdvKC5ilAbhPbyZawdi7NqtJvjxhjv6ZoFjxTCXCGjA ECi+BeDC/QTQhh21Uq5buzmP+9LJZIeMuKGAhVLA= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 25 May 2021 18:52:14 +0900 Message-Id: <20210525095218.1237140-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210525095218.1237140-1-paul.elder@ideasonboard.com> References: <20210525095218.1237140-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/5] utils: ipc: Add script to extract doxygen docs from mojom files X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a script to extract doxygen documentation comments from mojom files. It matches based on ^\/\*\*$ for start of block and ^ \*\/$ for end of block, and simply copies the comments to the output file along with a header and the libcamera namespace. Also add it to the meson file so it is usable by other meson files. Signed-off-by: Paul Elder Acked-by: Umang Jain Reviewed-by: Laurent Pinchart --- utils/ipc/extract-docs.py | 74 +++++++++++++++++++++++++++++++++++++++ utils/ipc/meson.build | 2 ++ 2 files changed, 76 insertions(+) create mode 100755 utils/ipc/extract-docs.py diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py new file mode 100755 index 00000000..56566ce0 --- /dev/null +++ b/utils/ipc/extract-docs.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2021, Google Inc. +# +# Author: Paul Elder +# +# extract-docs.py - Extract doxygen documentation from mojom files + +import argparse +import re +import sys + +regex_block_start = re.compile('^\/\*\*$') +regex_block_end = re.compile('^ \*\/$') + + +def main(argv): + + # Parse command line arguments + parser = argparse.ArgumentParser() + parser.add_argument('-o', dest='output', metavar='file', + type=argparse.FileType('w', encoding='utf-8'), + default=sys.stdout, + help='Output file name (default: standard output)') + parser.add_argument('input', type=str, + help='Input file name.') + args = parser.parse_args(argv[1:]) + + lines = open(args.input, 'r').readlines() + pipeline = args.input.split('/')[-1].replace('.mojom', '') + data = f'''\ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Google Inc. + * + * {pipeline}_ipa_interface.cpp - Docs file for generated {pipeline}.mojom + * + * This file is auto-generated. Do not edit. + */ + +namespace libcamera {{ + +''' + + in_block = False + comment = '' + for lineno, line in enumerate(lines, start=1): + if regex_block_start.match(line): + if in_block: + raise SyntaxError('Expected end of comment', + (args.input, lineno, 1, line)) + in_block = True + comment = line + continue + + if regex_block_end.match(line): + if in_block: + comment += line + data += comment + '\n' + in_block = False + continue + + if in_block: + comment += line + + data += '} /* namespace libcamera */\n' + + args.output.write(data) + + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/utils/ipc/meson.build b/utils/ipc/meson.build index 4a41b9c1..973a5417 100644 --- a/utils/ipc/meson.build +++ b/utils/ipc/meson.build @@ -8,6 +8,8 @@ mojom_parser = find_program('./parser.py') mojom_generator = find_program('./generate.py') +mojom_docs_extractor = find_program('./extract-docs.py') + mojom_templates = custom_target('mojom_templates', input : mojom_template_files, output : 'libcamera_templates.zip',