diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2024-08-08 18:13:00 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2024-08-15 23:59:08 +0300 |
commit | 50c92cc7e2924009ecab3e4004448b01d687707c (patch) | |
tree | c22b49816a3c79dae4727780962aa0928df42b52 /utils/codegen/gen-tp-header.py | |
parent | d3bf27180ef1d91b86b7b87a2378e559eaff5455 (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/codegen/gen-tp-header.py')
-rwxr-xr-x | utils/codegen/gen-tp-header.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/utils/codegen/gen-tp-header.py b/utils/codegen/gen-tp-header.py new file mode 100755 index 00000000..83606c32 --- /dev/null +++ b/utils/codegen/gen-tp-header.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2020, Google Inc. +# +# Author: Paul Elder <paul.elder@ideasonboard.com> +# +# Generate header file to contain lttng tracepoints + +import datetime +import jinja2 +import pathlib +import os +import sys + +def main(argv): + if len(argv) < 4: + print(f'Usage: {argv[0]} include_build_dir output template tp_files...') + return 1 + + output = argv[2] + template = argv[3] + + year = datetime.datetime.now().year + path = pathlib.Path(output).absolute().relative_to(argv[1]) + + source = '' + for fname in argv[4:]: + source += open(fname, 'r', encoding='utf-8').read() + '\n\n' + + template = jinja2.Template(open(template, 'r', encoding='utf-8').read()) + string = template.render(year=year, path=path, source=source) + + f = open(output, 'w', encoding='utf-8').write(string) + + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) |