From: Daan De Meyer Date: Wed, 26 Mar 2025 12:57:33 +0000 (+0100) Subject: meson: Drop project_source_root and project_build_root variables X-Git-Tag: v258-rc1~999^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b4b1d94a094a5cc71e22e36e6cdbe008200c03b9;p=thirdparty%2Fsystemd.git meson: Drop project_source_root and project_build_root variables We can now rely on meson.project_source_root() and meson.project_build_root() which do the same thing. --- diff --git a/hwdb.d/meson.build b/hwdb.d/meson.build index e7dfd0bea2d..a564cc4bf72 100644 --- a/hwdb.d/meson.build +++ b/hwdb.d/meson.build @@ -80,4 +80,4 @@ run_target( run_target( 'update-hwdb-autosuspend', - command : [update_hwdb_autosuspend_sh, project_source_root]) + command : [update_hwdb_autosuspend_sh, meson.project_source_root()]) diff --git a/man/meson.build b/man/meson.build index 90c6fef4d6c..c12b7e6dde9 100644 --- a/man/meson.build +++ b/man/meson.build @@ -212,7 +212,7 @@ endif ############################################################ buildroot_substs = configuration_data() -buildroot_substs.set_quoted('BUILD_ROOT', project_build_root) +buildroot_substs.set_quoted('BUILD_ROOT', meson.project_build_root()) configure_file( input : 'man.in', @@ -229,7 +229,7 @@ configure_file( update_dbus_docs = custom_target( 'update-dbus-docs-impl', output : 'update-dbus-docs', - command : [update_dbus_docs_py, '--build-dir', project_build_root, '@INPUT@'], + command : [update_dbus_docs_py, '--build-dir', meson.project_build_root(), '@INPUT@'], input : dbus_docs, depends : dbus_programs) @@ -237,7 +237,7 @@ if conf.get('BUILD_MODE_DEVELOPER') == 1 test('dbus-docs-fresh', update_dbus_docs_py, suite : 'dist', - args : ['--build-dir', project_build_root, '--test', dbus_docs], + args : ['--build-dir', meson.project_build_root(), '--test', dbus_docs], depends : dbus_programs) test('check-version-history', @@ -250,7 +250,7 @@ update_man_rules = custom_target( 'update-man-rules-impl', output : 'update-man-rules', command : [update_man_rules_py, - '@0@/man/*.xml'.format(project_source_root), + '@0@/man/*.xml'.format(meson.project_source_root()), '@0@/rules/meson.build'.format(meson.current_source_dir())], depends : man_page_depends) diff --git a/meson.build b/meson.build index 48d4f0027c0..52dc6d06201 100644 --- a/meson.build +++ b/meson.build @@ -29,13 +29,9 @@ conf.set('PROJECT_VERSION', project_major_version, description : 'Numerical project version (used where a simple number is expected)') conf.set_quoted('PROJECT_VERSION_FULL', meson.project_version(), description : 'Full project version') -# This is to be used instead of meson.source_root(), as the latter will return -# the wrong result when systemd is being built as a meson subproject -project_source_root = meson.current_source_dir() -project_build_root = meson.current_build_dir() relative_source_path = run_command('realpath', - '--relative-to=@0@'.format(project_build_root), - project_source_root, + '--relative-to=@0@'.format(meson.project_build_root()), + meson.project_source_root(), check : true).stdout().strip() conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) @@ -2172,8 +2168,8 @@ runtest_env = custom_target( output : 'systemd-runtest.env', command : [sh, '-c', '{ echo SYSTEMD_TEST_DATA=@0@; echo SYSTEMD_CATALOG_DIR=@1@; } >@OUTPUT@'.format( - project_source_root / 'test', - project_build_root / 'catalog')], + meson.project_source_root() / 'test', + meson.project_build_root() / 'catalog')], depends : catalogs, build_by_default : true) @@ -2746,8 +2742,8 @@ if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found( jekyll, suite : 'dist', args : ['build', - '--source', project_source_root / 'docs', - '--destination', project_build_root / '_site']) + '--source', meson.project_source_root() / 'docs', + '--destination', meson.project_build_root() / '_site']) endif ##################################################################### @@ -2824,7 +2820,7 @@ endforeach if git.found() all_files = run_command( env, '-u', 'GIT_WORK_TREE', - git, '--git-dir=@0@/.git'.format(project_source_root), + git, '--git-dir=@0@/.git'.format(meson.project_source_root()), 'ls-files', ':/*.[ch]', ':/*.cc', check : false) if all_files.returncode() == 0 @@ -2833,10 +2829,10 @@ if git.found() custom_target( 'tags', output : 'tags', - command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files) + command : [env, 'etags', '-o', '@0@/TAGS'.format(meson.project_source_root())] + all_files) run_target( 'ctags', - command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(project_source_root)] + all_files) + command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(meson.project_source_root())] + all_files) ############################################ @@ -2844,7 +2840,7 @@ if git.found() test('check-includes', files('tools/check-includes.py'), args: all_files, - env : ['PROJECT_SOURCE_ROOT=@0@'.format(project_source_root)], + env : ['PROJECT_SOURCE_ROOT=@0@'.format(meson.project_source_root())], suite : 'headers') endif endif @@ -2859,18 +2855,18 @@ if git.found() #################################################### git_head = run_command( - git, '--git-dir=@0@/.git'.format(project_source_root), + git, '--git-dir=@0@/.git'.format(meson.project_source_root()), 'rev-parse', 'HEAD', check : false).stdout().strip() git_head_short = run_command( - git, '--git-dir=@0@/.git'.format(project_source_root), + git, '--git-dir=@0@/.git'.format(meson.project_source_root()), 'rev-parse', '--short=7', 'HEAD', check : false).stdout().strip() run_target( 'git-snapshot', command : [git, 'archive', - '-o', '@0@/systemd-@1@.tar.gz'.format(project_source_root, + '-o', '@0@/systemd-@1@.tar.gz'.format(meson.project_source_root(), git_head_short), '--prefix', 'systemd-@0@/'.format(git_head), 'HEAD']) @@ -2902,7 +2898,7 @@ custom_target('installed-unit-files.txt', capture : true, install : want_tests != 'no' and install_tests, install_dir : testdata_dir, - command : [meson_extract_unit_files, project_build_root]) + command : [meson_extract_unit_files, meson.project_build_root()]) ##################################################################### diff --git a/src/test/meson.build b/src/test/meson.build index 14d813fee10..a4c33cb50ca 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -12,8 +12,8 @@ test_hashmap_ordered_c = custom_target( path = run_command(sh, '-c', 'echo "$PATH"', check: true).stdout().strip() test_env = environment() test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map) -test_env.set('PATH', project_build_root + ':' + path) -test_env.set('PROJECT_BUILD_ROOT', project_build_root) +test_env.set('PATH', meson.project_build_root() + ':' + path) +test_env.set('PROJECT_BUILD_ROOT', meson.project_build_root()) test_env.set('SYSTEMD_SLOW_TESTS', want_slow_tests ? '1' : '0') if efi_addon != '' diff --git a/test/TEST-24-CRYPTSETUP/meson.build b/test/TEST-24-CRYPTSETUP/meson.build index ccf6f1ede86..4d65e1d9abb 100644 --- a/test/TEST-24-CRYPTSETUP/meson.build +++ b/test/TEST-24-CRYPTSETUP/meson.build @@ -15,7 +15,7 @@ integration_tests += [ 'luks.options=0d318174-56b0-4d6e-a324-ac1e7e7d235d=x-initrd.attach', ], 'qemu-args' : [ - '-drive', 'id=keydev,if=none,format=raw,cache=unsafe,file=@0@'.format(project_build_root / 'mkosi.output/keydev.raw'), + '-drive', 'id=keydev,if=none,format=raw,cache=unsafe,file=@0@'.format(meson.project_build_root() / 'mkosi.output/keydev.raw'), '-device', 'scsi-hd,drive=keydev,serial=keydev', ], 'mkosi-args' : integration_test_template['mkosi-args'] + [ diff --git a/test/fuzz/meson.build b/test/fuzz/meson.build index d88d6218d2f..db1dcb291c9 100644 --- a/test/fuzz/meson.build +++ b/test/fuzz/meson.build @@ -55,7 +55,7 @@ sanitize_address_undefined = custom_target( 'sanitize-address-undefined-fuzzers', output : 'sanitize-address-undefined-fuzzers', command : [meson_build_sh, - project_source_root, + meson.project_source_root(), '@OUTPUT@', 'fuzzers', ' '.join(fuzz_c_args + '-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION'), @@ -71,13 +71,13 @@ sanitize_address_undefined = custom_target( fuzz_sanitizers = [['address,undefined', sanitize_address_undefined]] fuzz_testsdir = 'test/fuzz' -if git.found() and fs.is_dir(project_source_root / '.git') +if git.found() and fs.is_dir(meson.project_source_root() / '.git') out = run_command(env, '-u', 'GIT_WORK_TREE', - git, '--git-dir=@0@/.git'.format(project_source_root), + git, '--git-dir=@0@/.git'.format(meson.project_source_root()), 'ls-files', ':/@0@/*/*'.format(fuzz_testsdir), check: true) else - out = run_command(sh, '-c', 'cd "@0@"; echo @1@/*/*'.format(project_source_root, fuzz_testsdir), check: true) + out = run_command(sh, '-c', 'cd "@0@"; echo @1@/*/*'.format(meson.project_source_root(), fuzz_testsdir), check: true) endif # Add crafted fuzz inputs we have in the repo diff --git a/test/meson.build b/test/meson.build index e2d10a38868..f5f4d8d85ec 100644 --- a/test/meson.build +++ b/test/meson.build @@ -220,7 +220,7 @@ if rpm.found() and rpmspec.found() test('test-rpm-macros', test_rpm_macros, suite : 'dist', - args : [project_build_root]) + args : [meson.project_build_root()]) endif else message('Skipping test-rpm-macros since rpm and/or rpmspec are not available') @@ -232,20 +232,20 @@ if want_tests != 'false' and conf.get('HAVE_DMI') == 1 udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh') exe = executables_by_name.get('dmi_memory_id') - if git.found() and fs.is_dir(project_source_root / '.git') + if git.found() and fs.is_dir(meson.project_source_root() / '.git') out = run_command( env, '-u', 'GIT_WORK_TREE', - git, '--git-dir=@0@/.git'.format(project_source_root), + git, '--git-dir=@0@/.git'.format(meson.project_source_root()), 'ls-files', ':/test/dmidecode-dumps/*.bin', check: true) else out = run_command( - sh, '-c', 'cd "$1"; echo test/dmidecode-dumps/*.bin', '_', project_source_root, + sh, '-c', 'cd "$1"; echo test/dmidecode-dumps/*.bin', '_', meson.project_source_root(), check: true) endif foreach p : out.stdout().split() - source = project_source_root / p + source = meson.project_source_root() / p test('dmidecode_' + fs.stem(p), udev_dmi_memory_id_test, suite : 'udev',