meson: call find_program() once and reuse the variable everywhere

Meson 0.58 has gotten quite bad with emitting a message every time
a quoted command is used:
Program /home/zbyszek/src/systemd-work/tools/meson-make-symlink.sh found: YES (/home/zbyszek/src/systemd-work/tools/meson-make-symlink.sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program sh found: YES (/usr/bin/sh)
Program xsltproc found: YES (/usr/bin/xsltproc)
Configuring custom-entities.ent using configuration
Message: Skipping bootctl.1 because ENABLE_EFI is false
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Message: Skipping journal-remote.conf.5 because HAVE_MICROHTTPD is false
Message: Skipping journal-upload.conf.5 because HAVE_MICROHTTPD is false
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Message: Skipping loader.conf.5 because ENABLE_EFI is false
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
Program ln found: YES (/usr/bin/ln)
...

Let's suffer one message only for each command. Hopefully we can silence
even this when https://github.com/mesonbuild/meson/issues/8642 is
resolved.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-05-14 14:21:27 +02:00
parent a2031de849
commit 0f4c4f3824
18 changed files with 80 additions and 97 deletions
+5 -4
View File
@@ -72,14 +72,14 @@ if conf.get('ENABLE_EFI') == 1 and get_option('gnu-efi') != 'false'
if efi_libdir == ''
# New location first introduced with gnu-efi 3.0.11
efi_libdir = join_paths('/usr/lib/gnuefi', EFI_MACHINE_TYPE_NAME)
cmd = run_command('test', '-e', efi_libdir)
cmd = run_command(test, '-e', efi_libdir)
if cmd.returncode() != 0
# Fall back to the old approach
cmd = run_command(efi_cc + ['-print-multi-os-directory'])
if cmd.returncode() == 0
path = join_paths('/usr/lib', cmd.stdout().strip())
cmd = run_command('realpath', '-e', path)
cmd = run_command(env, 'realpath', '-e', path)
if cmd.returncode() == 0
efi_libdir = cmd.stdout().strip()
endif
@@ -116,7 +116,8 @@ if have_gnu_efi
foreach sbatvar : sbatvars
value = get_option(sbatvar[0])
if value == '' or value == 'auto'
value = run_command('sh', '-c', 'if [ -e /etc/os-release ]; then . /etc/os-release; else . /usr/lib/os-release; fi; echo $' + sbatvar[1]).stdout().strip()
cmd = 'if [ -e /etc/os-release ]; then . /etc/os-release; else . /usr/lib/os-release; fi; echo $@0@'.format(sbatvar[1])
value = run_command(sh, '-c', cmd).stdout().strip()
endif
if value == ''
error('Required @0@ option not set and autodetection failed'.format(sbatvar[0]))
@@ -156,7 +157,7 @@ if have_gnu_efi
efi_lds = ''
foreach location : efi_location_map
if efi_lds == ''
cmd = run_command('test', '-f', location[0])
cmd = run_command(test, '-f', location[0])
if cmd.returncode() == 0
efi_lds = location[0]
efi_crt0 = location[1]
+7 -7
View File
@@ -203,15 +203,15 @@ policy = configure_file(
install_data(policy,
install_dir : polkitpolicydir)
meson.add_install_script('sh', '-c', mkdir_p.format(systemshutdowndir))
meson.add_install_script('sh', '-c', mkdir_p.format(systemsleepdir))
meson.add_install_script('sh', '-c', mkdir_p.format(systemgeneratordir))
meson.add_install_script('sh', '-c', mkdir_p.format(usergeneratordir))
meson.add_install_script(sh, '-c', mkdir_p.format(systemshutdowndir))
meson.add_install_script(sh, '-c', mkdir_p.format(systemsleepdir))
meson.add_install_script(sh, '-c', mkdir_p.format(systemgeneratordir))
meson.add_install_script(sh, '-c', mkdir_p.format(usergeneratordir))
if install_sysconfdir
meson.add_install_script('sh', '-c', mkdir_p.format(join_paths(pkgsysconfdir, 'system')))
meson.add_install_script('sh', '-c', mkdir_p.format(join_paths(pkgsysconfdir, 'user')))
meson.add_install_script('sh', '-c', mkdir_p.format(join_paths(sysconfdir, 'xdg/systemd')))
meson.add_install_script(sh, '-c', mkdir_p.format(join_paths(pkgsysconfdir, 'system')))
meson.add_install_script(sh, '-c', mkdir_p.format(join_paths(pkgsysconfdir, 'user')))
meson.add_install_script(sh, '-c', mkdir_p.format(join_paths(sysconfdir, 'xdg/systemd')))
endif
############################################################
+2 -2
View File
@@ -67,9 +67,9 @@ if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
install_dir : join_paths(pkgdatadir, 'gatewayd'))
if get_option('create-log-dirs')
meson.add_install_script('sh', '-c',
meson.add_install_script(sh, '-c',
mkdir_p.format('/var/log/journal/remote'))
meson.add_install_script('sh', '-c',
meson.add_install_script(sh, '-c',
'''chown 0:0 $DESTDIR/var/log/journal/remote &&
chmod 755 $DESTDIR/var/log/journal/remote || :''')
endif
+8 -13
View File
@@ -56,22 +56,17 @@ if install_sysconfdir_samples
endif
if get_option('create-log-dirs')
meson.add_install_script(
'sh', '-c',
mkdir_p.format('/var/log/journal'))
meson.add_install_script(
'sh', '-c',
'''chown 0:0 $DESTDIR/var/log/journal &&
chmod 755 $DESTDIR/var/log/journal || :''')
meson.add_install_script(sh, '-c', mkdir_p.format('/var/log/journal'))
meson.add_install_script(sh, '-c',
'''chown 0:0 $DESTDIR/var/log/journal &&
chmod 755 $DESTDIR/var/log/journal || :''')
if get_option('adm-group')
meson.add_install_script(
'sh', '-c',
'setfacl -nm g:adm:rx,d:g:adm:rx $DESTDIR/var/log/journal || :')
meson.add_install_script(sh, '-c',
'setfacl -nm g:adm:rx,d:g:adm:rx $DESTDIR/var/log/journal || :')
endif
if get_option('wheel-group')
meson.add_install_script(
'sh', '-c',
'setfacl -nm g:wheel:rx,d:g:wheel:rx $DESTDIR/var/log/journal || :')
meson.add_install_script(sh, '-c',
'setfacl -nm g:wheel:rx,d:g:wheel:rx $DESTDIR/var/log/journal || :')
endif
endif
+1 -1
View File
@@ -14,7 +14,7 @@ if want_kernel_install
install_dir : kernelinstalldir)
if install_sysconfdir
meson.add_install_script('sh', '-c',
meson.add_install_script(sh, '-c',
mkdir_p.format(join_paths(sysconfdir, 'kernel/install.d')))
endif
+1 -1
View File
@@ -20,7 +20,7 @@ endif
# If you know a way that allows the same variables to be used
# in sources list and concatenated to a string for test_env,
# let me know.
kbd_model_map = join_paths(meson.current_source_dir(), 'kbd-model-map')
kbd_model_map = join_paths(meson.current_source_dir(), 'kbd-model-map')
language_fallback_map = join_paths(meson.current_source_dir(), 'language-fallback-map')
if conf.get('ENABLE_LOCALED') == 1
+1 -1
View File
@@ -11,7 +11,7 @@ test_hashmap_ordered_c = custom_target(
test_include_dir = include_directories('.')
path = run_command('sh', ['-c', 'echo "$PATH"']).stdout().strip()
path = run_command(sh, '-c', 'echo "$PATH"').stdout().strip()
test_env = environment()
test_env.set('SYSTEMD_KBD_MODEL_MAP', kbd_model_map)
test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map)
+1 -2
View File
@@ -165,8 +165,7 @@ configure_file(
install_dir : pkgconfigdatadir == 'no' ? '' : pkgconfigdatadir)
if install_sysconfdir
meson.add_install_script('sh', '-c',
mkdir_p.format(join_paths(sysconfdir, 'udev/rules.d')))
meson.add_install_script(sh, '-c', mkdir_p.format(join_paths(sysconfdir, 'udev/rules.d')))
endif
fuzzers += [