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.
This commit is contained in:
vad
2026-05-24 22:38:07 +01:00
committed by Luca Boccassi
parent d60cf3702a
commit e32656c2a9
+11 -5
View File
@@ -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