From: vad Date: Sun, 24 May 2026 17:57:15 +0000 (+0200) Subject: meson: Use `fs.relative_to()` instead of `realpath` X-Git-Tag: v261-rc2~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e32656c2a97b2f28a659dd38f9d9db22062ecf3a;p=thirdparty%2Fsystemd.git meson: Use `fs.relative_to()` instead of `realpath` When building with Meson >=1.3.0, use the native `fs.relative_to()` helper instead of shelling out to `realpath`. This is more portable: BusyBox `realpath` does not support the `--relative-to` option. --- diff --git a/meson.build b/meson.build index 7294b9b70c3..8fbf9bbff78 100644 --- a/meson.build +++ b/meson.build @@ -38,10 +38,17 @@ conf.set_quoted('PROJECT_VERSION_STR', project_major_version, description: 'Stringified project version (used where a simple string is expected)') conf.set_quoted('PROJECT_VERSION_FULL', meson.project_version(), description : 'Full project version') -relative_source_path = run_command('realpath', - '--relative-to=@0@'.format(meson.project_build_root()), - meson.project_source_root(), - check : true).stdout().strip() +fs = import('fs') + +if meson.version().version_compare('>=1.3.0') + relative_source_path = fs.relative_to(meson.project_source_root(), + meson.project_build_root()) +else + relative_source_path = run_command('realpath', + '--relative-to=@0@'.format(meson.project_build_root()), + meson.project_source_root(), + check : true).stdout().strip() +endif conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path) conf.set10('BUILD_MODE_DEVELOPER', get_option('mode') == 'developer', @@ -80,7 +87,6 @@ summary({ ##################################################################### -fs = import('fs') if get_option('split-bin') == 'auto' split_bin = not fs.is_symlink('/usr/sbin') else