libcamera/utils/codegen/gen-tp-header.py
Bernhard M. Wiedemann ae51d30468 libcamera: tracepoints: Fix copyright year for reproducible builds
The tracepoints.h file is generated from the tracepoints.h.in template
by the gen-tp-header.py script. The template contains a {{year}}
placeholder for the copyright year, which the script fills with the
current year. This breaks reproducible builds with at least the openSUSE
debugsource package.

As the gen-tp-header.py script doesn't add any copyrightable contents to
the tracepoints.h file, fix this by replacing the {{year}} placeholder
with the year of the last copyright-worthy change to tracepoints.h.in.

Signed-off-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-10-18 23:39:11 +03:00

37 lines
883 B
Python
Executable file

#!/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 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]
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(path=path, source=source)
f = open(output, 'w', encoding='utf-8').write(string)
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))