]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: Use `fs.relative_to()` instead of `realpath`
authorvad <vad.sol@proton.me>
Sun, 24 May 2026 17:57:15 +0000 (19:57 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sun, 24 May 2026 21:38:07 +0000 (22:38 +0100)
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.

meson.build

index 7294b9b70c3995c953eba075b87adc32034a221b..8fbf9bbff7880bcef5b4d5b8a4f8c2554ec482fd 100644 (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