summaryrefslogtreecommitdiff
path: root/utils/ipc/extract-docs.py
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-08-08 18:13:00 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-08-15 23:59:08 +0300
commit50c92cc7e2924009ecab3e4004448b01d687707c (patch)
treec22b49816a3c79dae4727780962aa0928df42b52 /utils/ipc/extract-docs.py
parentd3bf27180ef1d91b86b7b87a2378e559eaff5455 (diff)
meson: Move all code generation scripts to utils/codegen/
We have multiple code generation scripts in utils/, mixed with other miscellaneous utilities, as well as a larger code base based on mojom in utils/ipc/. To make code sharing easier between the generator scripts, without creating a mess in the utils/ directory, move all the code generation code to utils/codegen/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Diffstat (limited to 'utils/ipc/extract-docs.py')
-rwxr-xr-xutils/ipc/extract-docs.py79
1 files changed, 0 insertions, 79 deletions
diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
deleted file mode 100755
index 61f44cae..00000000
--- a/utils/ipc/extract-docs.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env python3
-# SPDX-License-Identifier: GPL-2.0-or-later
-# Copyright (C) 2021, Google Inc.
-#
-# Author: Paul Elder <paul.elder@ideasonboard.com>
-#
-# Extract doxygen documentation from mojom files
-
-import argparse
-import re
-import sys
-
-regex_block_start = re.compile(r'^/\*\*$')
-regex_block_end = re.compile(r'^ \*/$')
-regex_spdx = re.compile(r'^/\* SPDX-License-Identifier: .* \*/$')
-
-
-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', '')
-
- if not regex_spdx.match(lines[0]):
- raise Exception(f'Missing SPDX license header in {args.input}')
-
- data = lines[0]
- data += f'''\
-/*
- * Copyright (C) 2021, Google Inc.
- *
- * 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))