如何获取介子依赖的库路径?

How to get the library paths of a meson dependency?

用例: 我有一个回退到子项目的依赖项:

./
./subprojects/
./subprojects/mylib.wrap

src/meson.build 包含:

mylib_dep = dependency('mylib')  # Searches for mylib with pkg-config then fall backs to mylib.wrap.
myexec_exe = executable ('myexec', 'myexec.c', dependencies : mylib_dep)

Dependency mylib_dep 提供库,如果没有安装在系统上,会使我的项目的主要可执行文件无法使用:

$ meson build && cd build && meson compile src/my_exec
...snip'd...
$ src/my_exec
src/my_exec: error while loading shared libraries: libmylib.so: cannot open shared object file: No such file or directory

我的测试脚本 build/tests/mytests.shconfigure_filed 来自 tests/mytests.sh.in 以指示 myexec 的位置,我想将库路径传递给它,以便它可以调整 LD_LIBRARY_PATH 和 运行 可执行文件。例如,在 tests/meson.build:

conf_data = configuration_data ()
conf_data.set_quoted ('MYEXEC_PATH', myexec_exe.full_path ())
conf_data.set_quoted ('MYLIB_PATH', mylib_dep.??????)
mytest_exe = configure_file (input : 'mytests.sh.in', output : 'mytests.sh', configuration : conf_data)

并在 tests/mytests.sh.in 中:

MYEXEC_PATH=@MYEXEC_PATH@
MYLIB_PATH=@MYLIB_PATH@
export LD_LIBRARY_PATH=$(dirname "$MYLIB_PATH"):$LD_LIBRARY_PATH
$MYEXEC_PATH

问题:上面的??????应该放什么?换句话说,给定一个依赖对象,我如何提取其中的库,并获取它们的完整路径?

通常在介子中你不会 configure_file 这个,你会将 library/executable(s) 作为测试命令中的参数传递给脚本:

test(
  'mytest',
  find_program('mytest.sh')
  args : [executable_target, library_target, ...],
)