mirror of
https://github.com/systemd/systemd.git
synced 2024-10-30 14:55:37 +03:00
a6d1760024
When using "capture : true" in custom_target()s the mode of the source file is not preserved when the generated file is not installed and so needs to be tweaked manually. Switch from output capture to creating the target file and copy the permissions from the input file. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
36 lines
913 B
Python
Executable File
36 lines
913 B
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
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, undefined=jinja2.StrictUndefined)
|
|
return template.render(defines)
|
|
|
|
if __name__ == '__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)
|