1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-03 05:18:09 +03:00

meson: also allow setting GIT_VERSION via templates

GIT_VERSION is not available as a config.h variable, because it's rendered
into version.h during builds. Let's rework jinja2 rendering to also
parse version.h. No functional change, the new variable is so far unused.

I guess this will make partial rebuilds a bit slower, but it's useful
to be able to use the full version string.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-04-05 16:52:44 +02:00
parent 3761002eea
commit 8f04a1ca2b
22 changed files with 28 additions and 25 deletions

View File

@ -4,6 +4,6 @@ custom_target(
'README', 'README',
input : 'README.in', input : 'README.in',
output : 'README', output : 'README',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : conf.get('HAVE_SYSV_COMPAT') == 1, install : conf.get('HAVE_SYSV_COMPAT') == 1,
install_dir : sysvinit_path) install_dir : sysvinit_path)

View File

@ -6,6 +6,6 @@ custom_target(
'locale.conf', 'locale.conf',
input : 'locale.conf.in', input : 'locale.conf.in',
output : 'locale.conf', output : 'locale.conf',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : true, install : true,
install_dir : factory_etc_dir) install_dir : factory_etc_dir)

View File

@ -30,7 +30,7 @@ custom_entities_ent = custom_target(
'custom-entities.ent', 'custom-entities.ent',
input : 'custom-entities.ent.in', input : 'custom-entities.ent.in',
output : 'custom-entities.ent', output : 'custom-entities.ent',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@']) command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'])
man_pages = [] man_pages = []
html_pages = [] html_pages = []

View File

@ -1826,6 +1826,8 @@ config_h = configure_file(
add_project_arguments('-include', 'config.h', language : 'c') add_project_arguments('-include', 'config.h', language : 'c')
jinja2_cmdline = [meson_render_jinja2, config_h, version_h]
############################################################ ############################################################
# binaries that have --help and are intended for use by humans, # binaries that have --help and are intended for use by humans,

View File

@ -51,7 +51,7 @@ foreach file : rules_in
file, file,
input : file + '.in', input : file + '.in',
output: file, output: file,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : true, install : true,
install_dir : udevrulesdir) install_dir : udevrulesdir)
endforeach endforeach

View File

@ -14,7 +14,7 @@ custom_target(
'systemctl', 'systemctl',
input : 'systemctl.in', input : 'systemctl.in',
output : 'systemctl', output : 'systemctl',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : bashcompletiondir != 'no', install : bashcompletiondir != 'no',
install_dir : bashcompletiondir) install_dir : bashcompletiondir)

View File

@ -9,7 +9,7 @@ custom_target(
'_systemctl', '_systemctl',
input : '_systemctl.in', input : '_systemctl.in',
output : '_systemctl', output : '_systemctl',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : zshcompletiondir != 'no', install : zshcompletiondir != 'no',
install_dir : zshcompletiondir) install_dir : zshcompletiondir)

View File

@ -151,7 +151,7 @@ load_fragment_gperf_gperf = custom_target(
'load-fragment-gperf.gperf', 'load-fragment-gperf.gperf',
input : 'load-fragment-gperf.gperf.in', input : 'load-fragment-gperf.gperf.in',
output: 'load-fragment-gperf.gperf', output: 'load-fragment-gperf.gperf',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@']) command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'])
load_fragment_gperf_c = custom_target( load_fragment_gperf_c = custom_target(
'load-fragment-gperf.c', 'load-fragment-gperf.c',
@ -217,7 +217,7 @@ foreach item : in_files
file, file,
input : file + '.in', input : file + '.in',
output: file, output: file,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : (dir == pkgsysconfdir) ? install_sysconfdir_samples : (dir != 'no'), install : (dir == pkgsysconfdir) ? install_sysconfdir_samples : (dir != 'no'),
install_dir : dir) install_dir : dir)
endforeach endforeach

View File

@ -54,7 +54,7 @@ foreach tuple : in_files
file, file,
input : file + '.in', input : file + '.in',
output: file, output: file,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : tuple[1], install : tuple[1],
install_dir : pkgsysconfdir) install_dir : pkgsysconfdir)
endforeach endforeach

View File

@ -186,7 +186,7 @@ custom_target(
'libsystemd.pc', 'libsystemd.pc',
input : 'libsystemd.pc.in', input : 'libsystemd.pc.in',
output : 'libsystemd.pc', output : 'libsystemd.pc',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : pkgconfiglibdir != 'no', install : pkgconfiglibdir != 'no',
install_dir : pkgconfiglibdir) install_dir : pkgconfiglibdir)

View File

@ -38,7 +38,7 @@ custom_target(
'libudev.pc', 'libudev.pc',
input : 'libudev.pc.in', input : 'libudev.pc.in',
output : 'libudev.pc', output : 'libudev.pc',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : pkgconfiglibdir != 'no', install : pkgconfiglibdir != 'no',
install_dir : pkgconfiglibdir) install_dir : pkgconfiglibdir)

View File

@ -80,7 +80,7 @@ foreach tuple : in_files
file, file,
input : file + '.in', input : file + '.in',
output: file, output: file,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : tuple[2] and install, install : tuple[2] and install,
install_dir : dir) install_dir : dir)
endforeach endforeach

View File

@ -168,7 +168,7 @@ custom_target(
'resolved.conf', 'resolved.conf',
input : 'resolved.conf.in', input : 'resolved.conf.in',
output : 'resolved.conf', output : 'resolved.conf',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : conf.get('ENABLE_RESOLVE') == 1 and install_sysconfdir_samples, install : conf.get('ENABLE_RESOLVE') == 1 and install_sysconfdir_samples,
install_dir : pkgsysconfdir) install_dir : pkgsysconfdir)

View File

@ -18,7 +18,7 @@ foreach tuple : in_files
file, file,
input : file + '.in', input : file + '.in',
output : file, output : file,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : tuple[1], install : tuple[1],
install_dir : tuple.length() > 2 ? tuple[2] : '', install_dir : tuple.length() > 2 ? tuple[2] : '',
build_by_default : true) build_by_default : true)

View File

@ -39,7 +39,7 @@ custom_target(
'timesyncd.conf', 'timesyncd.conf',
input : 'timesyncd.conf.in', input : 'timesyncd.conf.in',
output : 'timesyncd.conf', output : 'timesyncd.conf',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : conf.get('ENABLE_TIMESYNCD') == 1 and install_sysconfdir_samples, install : conf.get('ENABLE_TIMESYNCD') == 1 and install_sysconfdir_samples,
install_dir : pkgsysconfdir) install_dir : pkgsysconfdir)

View File

@ -166,7 +166,7 @@ custom_target(
'udev.pc', 'udev.pc',
input : 'udev.pc.in', input : 'udev.pc.in',
output : 'udev.pc', output : 'udev.pc',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : pkgconfigdatadir != 'no', install : pkgconfigdatadir != 'no',
install_dir : pkgconfigdatadir) install_dir : pkgconfigdatadir)

View File

@ -4,6 +4,6 @@ custom_target(
'90-vconsole.rules', '90-vconsole.rules',
input : '90-vconsole.rules.in', input : '90-vconsole.rules.in',
output : '90-vconsole.rules', output : '90-vconsole.rules',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : conf.get('ENABLE_VCONSOLE') == 1, install : conf.get('ENABLE_VCONSOLE') == 1,
install_dir : udevrulesdir) install_dir : udevrulesdir)

View File

@ -16,7 +16,7 @@ custom_target(
'50-coredump.conf', '50-coredump.conf',
input : '50-coredump.conf.in', input : '50-coredump.conf.in',
output : '50-coredump.conf', output : '50-coredump.conf',
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : conf.get('ENABLE_COREDUMP') == 1, install : conf.get('ENABLE_COREDUMP') == 1,
install_dir : sysctldir) install_dir : sysctldir)

View File

@ -33,7 +33,7 @@ foreach tuple : in_files
file, file,
input : file + '.in', input : file + '.in',
output: file, output: file,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : tuple[1], install : tuple[1],
install_dir : sysusersdir) install_dir : sysusersdir)
endforeach endforeach

View File

@ -41,7 +41,7 @@ foreach pair : in_files
pair[0], pair[0],
input : pair[0] + '.in', input : pair[0] + '.in',
output: pair[0], output: pair[0],
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : enable_tmpfiles, install : enable_tmpfiles,
install_dir : tmpfilesdir) install_dir : tmpfilesdir)
else else

View File

@ -28,9 +28,10 @@ def render(filename, defines):
if __name__ == '__main__': if __name__ == '__main__':
defines = parse_config_h(sys.argv[1]) defines = parse_config_h(sys.argv[1])
output = render(sys.argv[2], defines) defines.update(parse_config_h(sys.argv[2]))
with open(sys.argv[3], 'w') as f: output = render(sys.argv[3], defines)
with open(sys.argv[4], 'w') as f:
f.write(output) f.write(output)
f.write('\n') f.write('\n')
info = os.stat(sys.argv[2]) info = os.stat(sys.argv[3])
os.chmod(sys.argv[3], info.st_mode) os.chmod(sys.argv[4], info.st_mode)

View File

@ -276,7 +276,7 @@ foreach tuple : in_units
file, file,
input : file + '.in', input : file + '.in',
output : file, output : file,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : install, install : install,
install_dir : systemunitdir) install_dir : systemunitdir)