mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
5c25f9dbc5
version_h includes GIT_VERSION which only makes sense for C files which aren't preprocessed by jinja2 so remove the argument. The end result of this change is that the man pages are not recompiled anymore every time GIT_VERSION changes.
44 lines
1.1 KiB
Python
Executable File
44 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
# pylint: disable=consider-using-with
|
|
|
|
import ast
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
import jinja2
|
|
|
|
def parse_config_h(filename):
|
|
# Parse config.h file generated by meson.
|
|
ans = {}
|
|
for line in open(filename):
|
|
m = re.match(r'#define\s+(\w+)\s+(.*)', line)
|
|
if not m:
|
|
continue
|
|
a, b = m.groups()
|
|
if b and b[0] in '0123456789"':
|
|
b = ast.literal_eval(b)
|
|
ans[a] = b
|
|
return ans
|
|
|
|
def render(filename, defines):
|
|
text = open(filename).read()
|
|
template = jinja2.Template(text,
|
|
trim_blocks=True,
|
|
lstrip_blocks=True,
|
|
keep_trailing_newline=True,
|
|
undefined=jinja2.StrictUndefined)
|
|
return template.render(defines)
|
|
|
|
def main():
|
|
defines = parse_config_h(sys.argv[1])
|
|
output = render(sys.argv[2], defines)
|
|
with open(sys.argv[3], 'w') as f:
|
|
f.write(output)
|
|
info = os.stat(sys.argv[2])
|
|
os.chmod(sys.argv[3], info.st_mode)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|