meson: add tools/meson.build

Previously, we looked for scripts in the tools/ directory ad hoc,
wherever they were needed. Let's do those checks in one place.
The main meson.build file is shrunk somewhat, which is always nice.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-12-01 16:09:43 +01:00
parent 963bebd7b0
commit 322f6adbcd
3 changed files with 47 additions and 47 deletions

View File

@@ -79,17 +79,6 @@ summary({
##################################################################### #####################################################################
# Try to install the git pre-commit hook
git_setup_sh = find_program('tools/git-setup.sh', required : false)
if git_setup_sh.found()
git_hook = run_command(git_setup_sh, check : false)
if git_hook.returncode() == 0
message(git_hook.stdout().strip())
endif
endif
#####################################################################
fs = import('fs') fs = import('fs')
if get_option('split-bin') == 'auto' if get_option('split-bin') == 'auto'
split_bin = not fs.is_symlink('/usr/sbin') split_bin = not fs.is_symlink('/usr/sbin')
@@ -351,7 +340,6 @@ cc = meson.get_compiler('c')
userspace_c_args = [] userspace_c_args = []
userspace_c_ld_args = [] userspace_c_ld_args = []
userspace_sources = [] userspace_sources = []
meson_build_sh = files('tools/meson-build.sh')
want_tests = get_option('tests') want_tests = get_option('tests')
want_slow_tests = want_tests != 'false' and get_option('slow-tests') want_slow_tests = want_tests != 'false' and get_option('slow-tests')
@@ -1952,10 +1940,6 @@ conf.set10('ENABLE_UKIFY', want_ukify)
##################################################################### #####################################################################
check_efi_alignment_py = files('tools/check-efi-alignment.py')
#####################################################################
use_provided_vmlinux_h = false use_provided_vmlinux_h = false
use_generated_vmlinux_h = false use_generated_vmlinux_h = false
provided_vmlinux_h_path = get_option('vmlinux-h-path') provided_vmlinux_h_path = get_option('vmlinux-h-path')
@@ -2027,24 +2011,6 @@ conf.set10('ENABLE_SYSCTL_BPF', conf.get('HAVE_VMLINUX_H') == 1 and libbpf.versi
##################################################################### #####################################################################
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')
#####################################################################
version_tag = get_option('version-tag') version_tag = get_option('version-tag')
if version_tag == '' if version_tag == ''
version_tag = meson.project_version() version_tag = meson.project_version()
@@ -2052,6 +2018,7 @@ endif
conf.set_quoted('VERSION_TAG', version_tag) conf.set_quoted('VERSION_TAG', version_tag)
subdir('tools')
subdir('src/version') subdir('src/version')
shared_lib_tag = get_option('shared-lib-tag') shared_lib_tag = get_option('shared-lib-tag')
@@ -2071,7 +2038,7 @@ config_h = configure_file(
userspace_c_args += ['-include', 'config.h'] userspace_c_args += ['-include', 'config.h']
jinja2_cmdline = [meson_render_jinja2, config_h] jinja2_cmdline = [meson_render_jinja2_py, config_h]
userspace = declare_dependency( userspace = declare_dependency(
compile_args : userspace_c_args, compile_args : userspace_c_args,
@@ -2906,20 +2873,17 @@ endif
##################################################################### #####################################################################
check_help = files('tools/check-help.sh')
check_version = files('tools/check-version.sh')
foreach exec : public_programs foreach exec : public_programs
name = fs.name(exec.full_path()) name = fs.name(exec.full_path())
if want_tests != 'false' if want_tests != 'false'
test('check-help-' + name, test('check-help-' + name,
check_help, check_help_sh,
suite : 'dist', suite : 'dist',
args : exec.full_path(), args : exec.full_path(),
depends: exec) depends: exec)
test('check-version-' + name, test('check-version-' + name,
check_version, check_version_sh,
suite : 'dist', suite : 'dist',
args : [exec.full_path(), args : [exec.full_path(),
project_major_version], project_major_version],
@@ -2950,7 +2914,7 @@ if git.found()
run_target( run_target(
'git-contrib', 'git-contrib',
command : files('tools/git-contrib.sh')) command : git_contrib_sh)
#################################################### ####################################################
@@ -3013,10 +2977,9 @@ foreach name, exe : executables_by_name
symbol_analysis_exes += exe symbol_analysis_exes += exe
endforeach endforeach
find_unused_library_symbols = find_program('tools/find-unused-library-symbols.py')
test( test(
'libshared-unused-symbols', 'libshared-unused-symbols',
find_unused_library_symbols, find_unused_library_symbols_py,
suite : 'unused-symbols', suite : 'unused-symbols',
args : [libshared, libcore] + nss_targets + pam_targets + symbol_analysis_exes, args : [libshared, libcore] + nss_targets + pam_targets + symbol_analysis_exes,
) )
@@ -3024,7 +2987,7 @@ test(
run_target( run_target(
'check-api-docs', 'check-api-docs',
depends : [man, libsystemd, libudev], depends : [man, libsystemd, libudev],
command : [files('tools/check-api-docs.sh'), command : [check_api_docs_sh,
libsystemd.full_path(), libsystemd.full_path(),
libudev.full_path()]) libudev.full_path()])
@@ -3039,7 +3002,7 @@ if not meson.is_cross_build()
output : fs.name(dbus_interfaces_dir), output : fs.name(dbus_interfaces_dir),
install : dbus_interfaces_dir != 'no', install : dbus_interfaces_dir != 'no',
install_dir : fs.parent(dbus_interfaces_dir), install_dir : fs.parent(dbus_interfaces_dir),
command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs]) command : [dbus_exporter_py, '@OUTPUT@', dbus_programs])
endif endif
custom_target( custom_target(
@@ -3047,7 +3010,7 @@ custom_target(
capture : true, capture : true,
install : want_tests != 'no' and install_tests, install : want_tests != 'no' and install_tests,
install_dir : testdata_dir, install_dir : testdata_dir,
command : [files('tools/meson-extract-unit-files.py'), command : [meson_extract_unit_files_py,
meson.project_build_root()]) meson.project_build_root()])
##################################################################### #####################################################################

View File

@@ -7,7 +7,7 @@ version_h = custom_target('version',
output : 'version.h', output : 'version.h',
capture : true, capture : true,
command : [ command : [
meson.project_source_root() / 'tools/vcs-tag.sh', vcs_tag_sh,
'@INPUT@', '@INPUT@',
get_option('mode'), get_option('mode'),
vcs_tag ? '1' : '0', vcs_tag ? '1' : '0',

37
tools/meson.build Normal file
View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
check_api_docs_sh = files('check-api-docs.sh')
check_efi_alignment_py = files('check-efi-alignment.py')
check_help_sh = files('check-help.sh')
check_version_history_py = files('check-version-history.py')
check_version_sh = files('check-version.sh')
elf2efi_py = files('elf2efi.py')
dbus_exporter_py = files('dbus_exporter.py')
find_unused_library_symbols_py = files('find-unused-library-symbols.py')
generate_gperfs = files('generate-gperfs.py')
git_contrib_sh = files('git-contrib.sh')
make_autosuspend_rules_py = files('make-autosuspend-rules.py')
make_directive_index_py = files('make-directive-index.py')
make_man_index_py = files('make-man-index.py')
meson_build_sh = files('meson-build.sh')
meson_extract_unit_files_py = files('meson-extract-unit-files.py')
meson_render_jinja2_py = files('meson-render-jinja2.py')
sync_docs_py = files('sync-docs.py')
update_dbus_docs_py = files('update-dbus-docs.py')
update_hwdb_autosuspend_sh = files('update-hwdb-autosuspend.sh')
update_hwdb_sh = files('update-hwdb.sh')
update_man_rules_py = files('update-man-rules.py')
update_syscall_tables_sh = files('update-syscall-tables.sh')
vcs_tag_sh = files('vcs-tag.sh')
xml_helper_py = files('xml_helper.py')
#####################################################################
# Try to install the git pre-commit hook
git_setup_sh = find_program('./git-setup.sh', required : false)
if git_setup_sh.found()
git_hook = run_command(git_setup_sh, check : false)
if git_hook.returncode() == 0
message(git_hook.stdout().strip())
endif
endif