From 0e031d5e0bddc17cf912743ab07409b946977420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 25 Jul 2025 11:37:29 +0200 Subject: [PATCH 1/6] meson: inline output file names Before 7d247d3cb875e1778e6cc81dbf255b13092b29e0, we needed the file name twice. But now we only need it once, so no need to overcomplicate things by defining a variable with a single use. When a variable is used, it's also easier to make a mistake and e.g. accidentally reuse the variable later. --- src/basic/meson.build | 18 ++++++------------ src/shared/meson.build | 18 ++++++------------ src/udev/meson.build | 6 ++---- 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/basic/meson.build b/src/basic/meson.build index d21c47af8b6..82f50d6d06f 100644 --- a/src/basic/meson.build +++ b/src/basic/meson.build @@ -129,25 +129,22 @@ foreach item : [ ['errno', [], '', [''], ], ] - fname = '@0@-list.txt'.format(item[0]) generate_list = files('generate-@0@-list.sh'.format(item[0])) list_txt = custom_target( input : [generate_list, item[1]], - output : fname, + output : '@0@-list.txt'.format(item[0]), command : [env, 'bash', generate_list, cpp, system_include_args], capture : true) - fname = '@0@-from-name.gperf'.format(item[0]) gperf_file = custom_target( input : list_txt, - output : fname, + output : '@0@-from-name.gperf'.format(item[0]), command : [generate_gperfs, item[0], item[2], '@INPUT@'] + item[3], capture : true) - fname = '@0@-from-name.inc'.format(item[0]) target1 = custom_target( input : gperf_file, - output : fname, + output : '@0@-from-name.inc'.format(item[0]), command : [gperf, '-L', 'ANSI-C', '-t', '--ignore-case', '-N', 'lookup_@0@'.format(item[0]), @@ -156,11 +153,10 @@ foreach item : [ '@INPUT@'], capture : true) - fname = '@0@-to-name.inc'.format(item[0]) awkscript = '@0@-to-name.awk'.format(item[0]) target2 = custom_target( input : [awkscript, list_txt], - output : fname, + output : '@0@-to-name.inc'.format(item[0]), command : [awk, '-f', '@INPUT0@', '@INPUT1@'], capture : true) @@ -191,19 +187,17 @@ filesystems_gperf_h = custom_target( command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@']) generate_filesystem_list = find_program('generate-filesystem-list.py') -fname = 'filesystem-list.inc' filesystem_list_inc = custom_target( input : 'filesystems-gperf.gperf', - output : fname, + output : 'filesystem-list.inc', command : [generate_filesystem_list, '@INPUT@'], capture : true) generate_filesystem_switch_case_inc = find_program('generate-filesystem-switch-case.py') -fname = 'filesystem-switch-case.inc' filesystem_switch_case_inc = custom_target( input : 'filesystems-gperf.gperf', - output : fname, + output : 'filesystem-switch-case.inc', command : [generate_filesystem_switch_case_inc, '@INPUT@'], capture : true) diff --git a/src/shared/meson.build b/src/shared/meson.build index 97e15a0a5d7..9466a1742e1 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -232,10 +232,9 @@ if get_option('tests') != 'false' endif generate_syscall_list = find_program('generate-syscall-list.py') -fname = 'syscall-list.inc' syscall_list_inc = custom_target( input : syscall_list_txt, - output : fname, + output : 'syscall-list.inc', command : [generate_syscall_list, '@INPUT@'], capture : true) @@ -266,17 +265,15 @@ ip_protocol_list_txt = custom_target( command : [env, 'bash', generate_ip_protocol_list, cpp, system_include_args], capture : true) -fname = 'ip-protocol-from-name.gperf' gperf_file = custom_target( input : ip_protocol_list_txt, - output : fname, + output : 'ip-protocol-from-name.gperf', command : [generate_gperfs, 'ip_protocol', 'IPPROTO_', '@INPUT@', ''], capture : true) -fname = 'ip-protocol-from-name.inc' target1 = custom_target( input : gperf_file, - output : fname, + output : 'ip-protocol-from-name.inc', command : [gperf, '-L', 'ANSI-C', '-t', '--ignore-case', '-N', 'lookup_ip_protocol', @@ -285,11 +282,10 @@ target1 = custom_target( '@INPUT@'], capture : true) -fname = 'ip-protocol-to-name.inc' awkscript = 'ip-protocol-to-name.awk' target2 = custom_target( input : [awkscript, ip_protocol_list_txt], - output : fname, + output : 'ip-protocol-to-name.inc', command : [awk, '-f', '@INPUT0@', '@INPUT1@'], capture : true) @@ -297,10 +293,9 @@ generated_sources += [target1, target2] shared_sources += [target1, target2] ethtool_link_mode_py = files('ethtool-link-mode.py') -fname = 'ethtool-link-mode.inc' ethtool_link_mode_inc = custom_target( input : [ethtool_link_mode_py, ethtool_link_mode_sources], - output : fname, + output : 'ethtool-link-mode.inc', command : [python, ethtool_link_mode_py, '--header', cpp, system_include_args], capture : true) @@ -308,10 +303,9 @@ generated_sources += ethtool_link_mode_inc shared_sources += ethtool_link_mode_inc sources += shared_sources -fname = 'ethtool-link-mode.xml' ethtool_link_mode_xml = custom_target( input : [ethtool_link_mode_py, ethtool_link_mode_sources], - output : fname, + output : 'ethtool-link-mode.xml', command : [python, ethtool_link_mode_py, '--xml', cpp, system_include_args], capture : true) man_page_depends += ethtool_link_mode_xml diff --git a/src/udev/meson.build b/src/udev/meson.build index 7e49959bc5d..dc54d4e6887 100644 --- a/src/udev/meson.build +++ b/src/udev/meson.build @@ -69,17 +69,15 @@ keyboard_keys_list_txt = custom_target( capture : true) generate_keyboard_keys_gperf = files('generate-keyboard-keys-gperf.sh') -fname = 'keyboard-keys-from-name.gperf' gperf_file = custom_target( input : [generate_keyboard_keys_gperf, keyboard_keys_list_txt], - output : fname, + output : 'keyboard-keys-from-name.gperf', command : [env, 'bash', '@INPUT@'], capture : true) -fname = 'keyboard-keys-from-name.inc' keyboard_keys_from_name_inc = custom_target( input : gperf_file, - output : fname, + output : 'keyboard-keys-from-name.inc', command : [gperf, '-L', 'ANSI-C', '-t', '-N', 'keyboard_lookup_key', From 0e371ebb12a815189ef7644785cc02d727c8aad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 25 Jul 2025 12:06:14 +0200 Subject: [PATCH 2/6] man: consistently use #!/usr/bin/python Some files were using that, others weren't. Since those are user-facing docs, we should use the nice clean form, not the workaround for strange systems that we use in other places. --- man/90-rearrange-path.py | 2 +- man/notify-selfcontained-example.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/90-rearrange-path.py b/man/90-rearrange-path.py index 0620195157e..b5b6294754c 100755 --- a/man/90-rearrange-path.py +++ b/man/90-rearrange-path.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/python # SPDX-License-Identifier: MIT-0 """ diff --git a/man/notify-selfcontained-example.py b/man/notify-selfcontained-example.py index a1efb419ced..6a1e25b99b2 100644 --- a/man/notify-selfcontained-example.py +++ b/man/notify-selfcontained-example.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/python # SPDX-License-Identifier: MIT-0 # # Implement the systemd notify protocol without external dependencies. From 0bf9bbecae364963f27f5b62d826a7df4782f198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 25 Jul 2025 12:09:46 +0200 Subject: [PATCH 3/6] tools: consistently use #!/usr/bin/env python3 It's ugly, but it's better to be consistently ugly. --- .ycm_extra_conf.py | 2 +- src/fuzz/fuzz-bootspec-gen.py | 1 + test/integration-tests/integration-test-wrapper.py | 2 +- tools/analyze-dump-sort.py | 2 +- tools/check-efi-alignment.py | 2 +- tools/dump-auxv.py | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) mode change 100644 => 100755 .ycm_extra_conf.py diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py old mode 100644 new mode 100755 index f297deefe2b..46b5ecd9d9a --- a/.ycm_extra_conf.py +++ b/.ycm_extra_conf.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # SPDX-License-Identifier: Unlicense # diff --git a/src/fuzz/fuzz-bootspec-gen.py b/src/fuzz/fuzz-bootspec-gen.py index 99af3f5f699..a73e59203bb 100644 --- a/src/fuzz/fuzz-bootspec-gen.py +++ b/src/fuzz/fuzz-bootspec-gen.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # SPDX-License-Identifier: LGPL-2.1-or-later """Generate sample input for fuzz-bootspec""" diff --git a/test/integration-tests/integration-test-wrapper.py b/test/integration-tests/integration-test-wrapper.py index 34908e7ed90..6c80c3e6546 100755 --- a/test/integration-tests/integration-test-wrapper.py +++ b/test/integration-tests/integration-test-wrapper.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # SPDX-License-Identifier: LGPL-2.1-or-later """Test wrapper command for driving integration tests.""" diff --git a/tools/analyze-dump-sort.py b/tools/analyze-dump-sort.py index cc9a9fcd379..a464a14bd12 100755 --- a/tools/analyze-dump-sort.py +++ b/tools/analyze-dump-sort.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # SPDX-License-Identifier: LGPL-2.1-or-later # pylint: disable=consider-using-with diff --git a/tools/check-efi-alignment.py b/tools/check-efi-alignment.py index 26d5f5e40d8..abdeb22fdbd 100755 --- a/tools/check-efi-alignment.py +++ b/tools/check-efi-alignment.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # SPDX-License-Identifier: LGPL-2.1-or-later # vi: set tw=110 sw=4 ts=4 et: diff --git a/tools/dump-auxv.py b/tools/dump-auxv.py index d6dbcb1f075..1abacda9c1f 100644 --- a/tools/dump-auxv.py +++ b/tools/dump-auxv.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # SPDX-License-Identifier: LGPL-2.1-or-later # # Note: the no-value-for-parameter here is expected, as the click module From 8aedfd979f7ef275f1535adafa10f9d1458ffea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 25 Jul 2025 12:12:08 +0200 Subject: [PATCH 4/6] tools: make all .py program files executable All those files are standalone programs that can be executed directly. Some .py files were marked executable, others weren't, probably accidentally. Mark them all as executable in preparation for subsequent changes. --- man/check-os-release-simple.py | 0 man/check-os-release.py | 0 man/notify-selfcontained-example.py | 0 src/boot/generate-hwids-section.py | 0 src/fuzz/fuzz-bootspec-gen.py | 0 src/include/override/sys/generate-syscall.py | 0 src/shared/ethtool-link-mode.py | 0 test/fuzz/generate-directives.py | 0 test/sd-script.py | 0 tools/check-version-history.py | 0 tools/chromiumos/gen_autosuspend_rules.py | 0 tools/dump-auxv.py | 0 tools/gdb-sd_dump_hashmaps.py | 0 tools/list-discoverable-partitions.py | 0 14 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 man/check-os-release-simple.py mode change 100644 => 100755 man/check-os-release.py mode change 100644 => 100755 man/notify-selfcontained-example.py mode change 100644 => 100755 src/boot/generate-hwids-section.py mode change 100644 => 100755 src/fuzz/fuzz-bootspec-gen.py mode change 100644 => 100755 src/include/override/sys/generate-syscall.py mode change 100644 => 100755 src/shared/ethtool-link-mode.py mode change 100644 => 100755 test/fuzz/generate-directives.py mode change 100644 => 100755 test/sd-script.py mode change 100644 => 100755 tools/check-version-history.py mode change 100644 => 100755 tools/chromiumos/gen_autosuspend_rules.py mode change 100644 => 100755 tools/dump-auxv.py mode change 100644 => 100755 tools/gdb-sd_dump_hashmaps.py mode change 100644 => 100755 tools/list-discoverable-partitions.py diff --git a/man/check-os-release-simple.py b/man/check-os-release-simple.py old mode 100644 new mode 100755 diff --git a/man/check-os-release.py b/man/check-os-release.py old mode 100644 new mode 100755 diff --git a/man/notify-selfcontained-example.py b/man/notify-selfcontained-example.py old mode 100644 new mode 100755 diff --git a/src/boot/generate-hwids-section.py b/src/boot/generate-hwids-section.py old mode 100644 new mode 100755 diff --git a/src/fuzz/fuzz-bootspec-gen.py b/src/fuzz/fuzz-bootspec-gen.py old mode 100644 new mode 100755 diff --git a/src/include/override/sys/generate-syscall.py b/src/include/override/sys/generate-syscall.py old mode 100644 new mode 100755 diff --git a/src/shared/ethtool-link-mode.py b/src/shared/ethtool-link-mode.py old mode 100644 new mode 100755 diff --git a/test/fuzz/generate-directives.py b/test/fuzz/generate-directives.py old mode 100644 new mode 100755 diff --git a/test/sd-script.py b/test/sd-script.py old mode 100644 new mode 100755 diff --git a/tools/check-version-history.py b/tools/check-version-history.py old mode 100644 new mode 100755 diff --git a/tools/chromiumos/gen_autosuspend_rules.py b/tools/chromiumos/gen_autosuspend_rules.py old mode 100644 new mode 100755 diff --git a/tools/dump-auxv.py b/tools/dump-auxv.py old mode 100644 new mode 100755 diff --git a/tools/gdb-sd_dump_hashmaps.py b/tools/gdb-sd_dump_hashmaps.py old mode 100644 new mode 100755 diff --git a/tools/list-discoverable-partitions.py b/tools/list-discoverable-partitions.py old mode 100644 new mode 100755 From c5dcbd073e4501578359734926b6501ab88e9ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 25 Jul 2025 12:18:19 +0200 Subject: [PATCH 5/6] meson: use files() not find_program() for helper scripts We went back and forth between 'prog.sh', files('prog.sh'), and find_program('prog.sh'). We want to use files() or find_program() so that we get a good error message if the file is missing. Behaviour of meson changed over time, and in the past not all forms could be used in all places. For example 0f4c4f3824891aea6a76b2e861f38a6045b2a246 added find_program() in many places to avoid repeated messages. But it seems that all recent meson versions work fine with files(). find_program prints silly messages: Program tools/make-man-index.py found: YES (/home/zbyszek/src/systemd/tools/make-man-index.py) Program tools/meson-render-jinja2.py found: YES (/home/zbyszek/src/systemd/tools/meson-render-jinja2.py) ... We know that those files will be found, they are part of the git checkout. With files() this is gone and the meson output is easier to read. --- hwdb.d/meson.build | 3 +- meson.build | 50 ++++++++++++++-------------- src/basic/meson.build | 11 +++--- src/boot/meson.build | 5 ++- src/include/override/sys/meson.build | 6 ++-- src/kernel-install/meson.build | 2 +- src/resolve/meson.build | 7 ++-- src/shared/meson.build | 3 +- src/test/meson.build | 20 ++++++++--- test/fuzz/meson.build | 2 +- test/integration-tests/meson.build | 2 +- test/meson.build | 30 +++++++---------- 12 files changed, 71 insertions(+), 70 deletions(-) diff --git a/hwdb.d/meson.build b/hwdb.d/meson.build index 7173c8b5e25..5eb8c4218b0 100644 --- a/hwdb.d/meson.build +++ b/hwdb.d/meson.build @@ -63,9 +63,8 @@ if conf.get('ENABLE_HWDB') == 1 endif if want_tests != 'false' - parse_hwdb_py = find_program('parse_hwdb.py') test('parse-hwdb', - parse_hwdb_py, + files('parse_hwdb.py'), suite : 'dist', args : [hwdb_files_test, auto_suspend_rules], diff --git a/meson.build b/meson.build index bb1fa37f4b3..dda7b8d9fe2 100644 --- a/meson.build +++ b/meson.build @@ -345,7 +345,7 @@ cc = meson.get_compiler('c') userspace_c_args = [] userspace_c_ld_args = [] userspace_sources = [] -meson_build_sh = find_program('tools/meson-build.sh') +meson_build_sh = files('tools/meson-build.sh') want_tests = get_option('tests') want_slow_tests = want_tests != 'false' and get_option('slow-tests') @@ -1887,7 +1887,7 @@ conf.set10('ENABLE_UKIFY', want_ukify) ##################################################################### -check_efi_alignment_py = find_program('tools/check-efi-alignment.py') +check_efi_alignment_py = files('tools/check-efi-alignment.py') ##################################################################### @@ -1960,21 +1960,21 @@ conf.set10('HAVE_VMLINUX_H', use_provided_vmlinux_h or use_generated_vmlinux_h) ##################################################################### -check_version_history_py = find_program('tools/check-version-history.py') -elf2efi_py = find_program('tools/elf2efi.py') -export_dbus_interfaces_py = find_program('tools/dbus_exporter.py') -generate_gperfs = find_program('tools/generate-gperfs.py') -make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py') -make_directive_index_py = find_program('tools/make-directive-index.py') -sync_docs_py = find_program('tools/sync-docs.py') -make_man_index_py = find_program('tools/make-man-index.py') -meson_render_jinja2 = find_program('tools/meson-render-jinja2.py') -update_dbus_docs_py = find_program('tools/update-dbus-docs.py') -update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh') -update_hwdb_sh = find_program('tools/update-hwdb.sh') -update_man_rules_py = find_program('tools/update-man-rules.py') -update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh') -xml_helper_py = find_program('tools/xml_helper.py') +check_version_history_py = files('tools/check-version-history.py') +elf2efi_py = files('tools/elf2efi.py') +export_dbus_interfaces_py = files('tools/dbus_exporter.py') +generate_gperfs = files('tools/generate-gperfs.py') +make_autosuspend_rules_py = files('tools/make-autosuspend-rules.py') +make_directive_index_py = files('tools/make-directive-index.py') +sync_docs_py = files('tools/sync-docs.py') +make_man_index_py = files('tools/make-man-index.py') +meson_render_jinja2 = files('tools/meson-render-jinja2.py') +update_dbus_docs_py = files('tools/update-dbus-docs.py') +update_hwdb_autosuspend_sh = files('tools/update-hwdb-autosuspend.sh') +update_hwdb_sh = files('tools/update-hwdb.sh') +update_man_rules_py = files('tools/update-man-rules.py') +update_syscall_tables_sh = files('tools/update-syscall-tables.sh') +xml_helper_py = files('tools/xml_helper.py') ##################################################################### @@ -2808,8 +2808,8 @@ endif ##################################################################### -check_help = find_program('tools/check-help.sh') -check_version = find_program('tools/check-version.sh') +check_help = files('tools/check-help.sh') +check_version = files('tools/check-version.sh') foreach exec : public_programs name = fs.name(exec.full_path()) @@ -2850,10 +2850,9 @@ if git.found() #################################################### - git_contrib_sh = find_program('tools/git-contrib.sh') run_target( 'git-contrib', - command : [git_contrib_sh]) + command : files('tools/git-contrib.sh')) #################################################### @@ -2911,11 +2910,12 @@ if meson.version().version_compare('>=1.4.0') endforeach endif -check_api_docs_sh = find_program('tools/check-api-docs.sh') run_target( 'check-api-docs', depends : [man, libsystemd, libudev], - command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()]) + command : [files('tools/check-api-docs.sh'), + libsystemd.full_path(), + libudev.full_path()]) alias_target('update-dbus-docs', update_dbus_docs) alias_target('update-man-rules', update_man_rules) @@ -2929,13 +2929,13 @@ if not meson.is_cross_build() command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs]) endif -meson_extract_unit_files = find_program('tools/meson-extract-unit-files.py') custom_target( output : 'installed-unit-files.txt', capture : true, install : want_tests != 'no' and install_tests, install_dir : testdata_dir, - command : [meson_extract_unit_files, meson.project_build_root()]) + command : [files('tools/meson-extract-unit-files.py'), + meson.project_build_root()]) ##################################################################### diff --git a/src/basic/meson.build b/src/basic/meson.build index 82f50d6d06f..923f332fcf8 100644 --- a/src/basic/meson.build +++ b/src/basic/meson.build @@ -168,11 +168,12 @@ basic_sources += generated_gperf_headers ############################################################ -check_filesystems = find_program('check-filesystems.sh') r = run_command( [ 'env', '--chdir', meson.project_build_root(), - check_filesystems, cpp, files('filesystems-gperf.gperf'), + files('check-filesystems.sh'), + cpp, + files('filesystems-gperf.gperf'), system_include_args, ], check: false, @@ -186,19 +187,17 @@ filesystems_gperf_h = custom_target( output : 'filesystems-gperf.h', command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@']) -generate_filesystem_list = find_program('generate-filesystem-list.py') filesystem_list_inc = custom_target( input : 'filesystems-gperf.gperf', output : 'filesystem-list.inc', - command : [generate_filesystem_list, + command : [files('generate-filesystem-list.py'), '@INPUT@'], capture : true) -generate_filesystem_switch_case_inc = find_program('generate-filesystem-switch-case.py') filesystem_switch_case_inc = custom_target( input : 'filesystems-gperf.gperf', output : 'filesystem-switch-case.inc', - command : [generate_filesystem_switch_case_inc, + command : [files('generate-filesystem-switch-case.py'), '@INPUT@'], capture : true) diff --git a/src/boot/meson.build b/src/boot/meson.build index 7cb500fac08..ba0b309acff 100644 --- a/src/boot/meson.build +++ b/src/boot/meson.build @@ -27,13 +27,12 @@ efitest_base = { efi_test_template = test_template + efitest_base efi_fuzz_template = fuzz_template + efitest_base -generate_hwids_section_py = find_program('generate-hwids-section.py') - if conf.get('ENABLE_UKIFY') == 1 test_hwids_section_c = custom_target( input : ['hwids/device1.json', 'hwids/device2.json', 'hwids/device3.json', 'hwids/device4.json'], output : 'test-hwids-section.c', - command : [generate_hwids_section_py, meson.current_source_dir()/'hwids'], + command : [files('generate-hwids-section.py'), + meson.current_source_dir()/'hwids'], capture : true, build_by_default : want_tests != 'false') else diff --git a/src/include/override/sys/meson.build b/src/include/override/sys/meson.build index b66f9d055fd..194a57f278f 100644 --- a/src/include/override/sys/meson.build +++ b/src/include/override/sys/meson.build @@ -34,8 +34,8 @@ foreach arch: arch_list syscall_lists += files('syscalls-@0@.txt'.format(arch)) endforeach -generate_syscall_py = find_program('generate-syscall.py') - run_target( 'update-syscall-header', - command : [generate_syscall_py, files('syscall.h')] + syscall_lists) + command : [files('generate-syscall.py'), + files('syscall.h'), + syscall_lists]) diff --git a/src/kernel-install/meson.build b/src/kernel-install/meson.build index cd2a611c66e..716fffb46b0 100644 --- a/src/kernel-install/meson.build +++ b/src/kernel-install/meson.build @@ -51,4 +51,4 @@ if want_kernel_install endif endif -test_kernel_install_sh = find_program('test-kernel-install.sh') +test_kernel_install_sh = files('test-kernel-install.sh') diff --git a/src/resolve/meson.build b/src/resolve/meson.build index dfe49702356..8dc3bb45705 100644 --- a/src/resolve/meson.build +++ b/src/resolve/meson.build @@ -52,12 +52,13 @@ dns_type_list_txt = custom_target( command : [sed, '-n', '-r', '-f', '@INPUT0@', '@INPUT1@'], capture : true) -generate_dns_type_gperf = find_program('generate-dns_type-gperf.py') - gperf_file = custom_target( input : dns_type_list_txt, output : 'dns_type-from-name.gperf', - command : [generate_dns_type_gperf, 'dns_type', 'DNS_TYPE_', '@INPUT@'], + command : [files('generate-dns_type-gperf.py'), + 'dns_type', + 'DNS_TYPE_', + '@INPUT@'], capture : true) dns_type_from_name_inc = custom_target( diff --git a/src/shared/meson.build b/src/shared/meson.build index 9466a1742e1..d4330874591 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -231,11 +231,10 @@ if get_option('tests') != 'false' shared_sources += files('tests.c') endif -generate_syscall_list = find_program('generate-syscall-list.py') syscall_list_inc = custom_target( input : syscall_list_txt, output : 'syscall-list.inc', - command : [generate_syscall_list, + command : [files('generate-syscall-list.py'), '@INPUT@'], capture : true) diff --git a/src/test/meson.build b/src/test/meson.build index 111fe541ba9..c65e73f487d 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -23,19 +23,29 @@ endif ############################################################ -generate_sym_test_py = find_program('generate-sym-test.py') +generate_sym_test_py = files('generate-sym-test.py') test_libsystemd_sym_c = custom_target( - input : [libsystemd_sym_path] + systemd_headers + libsystemd_sources, + input : [libsystemd_sym_path, + systemd_headers, + libsystemd_sources], output : 'test-libsystemd-sym.c', - command : [generate_sym_test_py, libsystemd_sym_path, libsystemd_dir_path] + systemd_headers, + command : [generate_sym_test_py, + libsystemd_sym_path, + libsystemd_dir_path, + systemd_headers], capture : true, build_by_default : want_tests != 'false') test_libudev_sym_c = custom_target( - input : [libudev_sym_path, libudev_h_path] + libudev_sources, + input : [libudev_sym_path, + libudev_h_path, + libudev_sources], output : 'test-libudev-sym.c', - command : [generate_sym_test_py, libudev_sym_path, libudev_dir_path, libudev_h_path], + command : [generate_sym_test_py, + libudev_sym_path, + libudev_dir_path, + libudev_h_path], capture : true, build_by_default : want_tests != 'false') diff --git a/test/fuzz/meson.build b/test/fuzz/meson.build index 48d962b520d..1af3ec99339 100644 --- a/test/fuzz/meson.build +++ b/test/fuzz/meson.build @@ -1,6 +1,6 @@ # SPDX-License-Identifier: LGPL-2.1-or-later -generate_directives_py = find_program('generate-directives.py') +generate_directives_py = files('generate-directives.py') fuzz_regression_tests = {} diff --git a/test/integration-tests/meson.build b/test/integration-tests/meson.build index 08eb724dd28..f28be9e24ea 100644 --- a/test/integration-tests/meson.build +++ b/test/integration-tests/meson.build @@ -4,7 +4,7 @@ add_test_setup('integration') add_test_setup('shell', env : {'TEST_SHELL' : '1'}) -integration_test_wrapper = find_program('integration-test-wrapper.py') +integration_test_wrapper = files('integration-test-wrapper.py') integration_tests = [] integration_test_template = { 'mkosi-args' : [], diff --git a/test/meson.build b/test/meson.build index cd5f747c9fe..48e0ba7f925 100644 --- a/test/meson.build +++ b/test/meson.build @@ -38,10 +38,9 @@ endif ############################################################ if want_tests != 'false' and conf.get('ENABLE_HWDB') == 1 - hwdb_test_sh = find_program('hwdb-test.sh') exe = executables_by_name.get('systemd-hwdb') test('hwdb-test', - hwdb_test_sh, + files('hwdb-test.sh'), suite : 'dist', args : exe.full_path(), depends : exe, @@ -51,11 +50,10 @@ endif ############################################################ if want_tests != 'false' - test_systemctl_enable_sh = find_program('test-systemctl-enable.sh') systemctl = executables_by_name.get('systemctl') systemd_id128 = executables_by_name.get('systemd-id128') test('test-systemctl-enable', - test_systemctl_enable_sh, + files('test-systemctl-enable.sh'), # https://github.com/mesonbuild/meson/issues/2681 args : [systemctl.full_path(), systemd_id128.full_path()], @@ -66,10 +64,9 @@ endif ############################################################ if want_tests != 'false' and conf.get('HAVE_SYSV_COMPAT') == 1 - sysv_generator_test_py = find_program('sysv-generator-test.py') exe = executables_by_name.get('systemd-sysv-generator') test('sysv-generator-test', - sysv_generator_test_py, + files('sysv-generator-test.py'), depends : exe, suite : 'sysv') endif @@ -77,10 +74,9 @@ endif ############################################################ if want_tests != 'false' and conf.get('HAVE_BLKID') == 1 - test_bootctl_json_sh = find_program('test-bootctl-json.sh') exe = executables_by_name.get('bootctl') test('test-bootctl-json', - test_bootctl_json_sh, + files('test-bootctl-json.sh'), args : exe.full_path(), depends : exe, suite : 'boot') @@ -89,7 +85,7 @@ endif ############################################################ if want_tests != 'false' and conf.get('ENABLE_TMPFILES') == 1 - test_systemd_tmpfiles_py = find_program('test-systemd-tmpfiles.py') + test_systemd_tmpfiles_py = files('test-systemd-tmpfiles.py') exe = executables_by_name.get('systemd-tmpfiles') test('test-systemd-tmpfiles', test_systemd_tmpfiles_py, @@ -125,10 +121,9 @@ endif ############################################################ -rule_syntax_check_py = find_program('rule-syntax-check.py') if want_tests != 'false' test('rule-syntax-check', - rule_syntax_check_py, + files('rule-syntax-check.py'), suite : 'dist', args : all_rules) @@ -153,7 +148,7 @@ endif ############################################################ -test_fstab_generator_sh = find_program('test-fstab-generator.sh') +test_fstab_generator_sh = files('test-fstab-generator.sh') if want_tests != 'false' exe = executables_by_name.get('systemd-fstab-generator') test('test-fstab-generator', @@ -165,14 +160,14 @@ if want_tests != 'false' suite : 'fstab') endif if install_tests - install_data('test-fstab-generator.sh', + install_data(test_fstab_generator_sh, install_mode : 'rwxr-xr-x', install_dir : unittestsdir) endif ############################################################ -test_network_generator_conversion_sh = find_program('test-network-generator-conversion.sh') +test_network_generator_conversion_sh = files('test-network-generator-conversion.sh') if want_tests != 'false' exe = executables_by_name.get('systemd-network-generator') test('test-network-generator-conversion', @@ -183,7 +178,7 @@ if want_tests != 'false' suite : 'network') endif if install_tests - install_data('test-network-generator-conversion.sh', + install_data(test_network_generator_conversion_sh, install_mode : 'rwxr-xr-x', install_dir : unittestsdir) endif @@ -213,12 +208,11 @@ endif rpm = find_program('rpm', required : false) rpmspec = find_program('rpmspec', required : false) -test_rpm_macros = find_program('test-rpm-macros.sh') if rpm.found() and rpmspec.found() if want_tests != 'false' test('test-rpm-macros', - test_rpm_macros, + files('test-rpm-macros.sh'), suite : 'dist', args : [meson.project_build_root()], depends : rpm_depends) @@ -230,7 +224,7 @@ endif ############################################################ if want_tests != 'false' and conf.get('HAVE_DMI') == 1 - udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh') + udev_dmi_memory_id_test = files('udev-dmi-memory-id-test.sh') exe = executables_by_name.get('dmi_memory_id') if git.found() and fs.is_dir(meson.project_source_root() / '.git') From 4c4a63a87680f3fde80fa5aae3bca4d0fe150627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 25 Jul 2025 12:18:40 +0200 Subject: [PATCH 6/6] meson: indent find_program() calls for readability --- meson.build | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index dda7b8d9fe2..c416bb4b605 100644 --- a/meson.build +++ b/meson.build @@ -610,20 +610,20 @@ endforeach ##################################################################### -awk = find_program('awk') -diff = find_program('diff') -echo = find_program('echo') -env = find_program('env') -find = find_program('find') +awk = find_program('awk') +diff = find_program('diff') +echo = find_program('echo') +env = find_program('env') +find = find_program('find') getent = find_program('getent', required : false) -git = find_program('git', required : false) -gperf = find_program('gperf') -id = find_program('id', required : false) -ln = find_program('ln') -rsync = find_program('rsync', required : false) -sed = find_program('sed') -sh = find_program('sh') -stat = find_program('stat') +git = find_program('git', required : false) +gperf = find_program('gperf') +id = find_program('id', required : false) +ln = find_program('ln') +rsync = find_program('rsync', required : false) +sed = find_program('sed') +sh = find_program('sh') +stat = find_program('stat') ln_s = ln.full_path() + ' -frsT -- "${DESTDIR:-}@0@" "${DESTDIR:-}@1@"'