]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/test/meson.build
basic: add "build path" logic
authorLennart Poettering <lennart@poettering.net>
Tue, 20 Feb 2024 10:30:27 +0000 (11:30 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 21 Feb 2024 08:25:46 +0000 (09:25 +0100)
commit91d149cfb45fc2fad7ce18fb651297ee50ecc1f8
tree0e41f789e898487f3066052d3455e5f12677bbfd
parent3c6d9d1c3972f0577cc22ddb0cab5995a3f96776
basic: add "build path" logic

We have a number of components these days that are split into multiple
binaries, i.e. a primary one, and a worker callout usually. These
binaries are closely related, they typically speak a protocol that is
internal, and not safe to mix and match. Examples for this:

- homed and its worker binary homework
- userdbd and its worker binary userwork
- import and the various pull/import/export handlers
- sysupdate the same
- the service manager and the executor binary

Running any of these daemons directly from the meson build tree is
messy, since the implementations will typically invoke the installed
callout binaries, not the ones from the build tree. This is very
annoying, and not obvious at first.

Now, we could always invoke relevant binaries from $(dirname
/proc/self/exe) first, before using the OS installed ones. But that's
typically not what is desired, because this means in the installed case
(i.e. the usual one) we'll look for these callout binaries at a place
they typically will not be found (because these callouts generally are
located in libexecdir, not bindir when installed).

Hence, let's try to do things a bit smarter, and follow what build
systems such as meson have already been doing to make sure dynamic
library discovery works correctly when binaries are run from a build
directory: let's start looking at rpath/runpath in the main binary that
is executed: if there's an rpath/runpath set, then we'll look for the
callout binaries next to the main binary, otherwise we won't. This
should generally be the right thing to do as meson strips the rpath
during installation, and thus we'll look for the callouts in the build
dir if in build dir mode, and in the OS otherwise.
src/basic/build-path.c [new file with mode: 0644]
src/basic/build-path.h [new file with mode: 0644]
src/basic/meson.build
src/test/meson.build
src/test/test-build-path.c [new file with mode: 0644]