diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index d71cae308e1b..6b1c76f5bd80 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -718,7 +718,7 @@ def rpaths_for_bundled_shared_libraries(self, target: build.BuildTarget, exclude for dep in target.external_deps: if not isinstance(dep, (dependencies.ExternalLibrary, dependencies.PkgConfigDependency)): continue - la = dep.link_args + la = dep.get_link_args(raw=True) if len(la) != 1 or not os.path.isabs(la[0]): continue # The only link argument is an absolute path to a library file. diff --git a/test cases/unit/80 global-rpath/meson.build b/test cases/unit/80 global-rpath/meson.build index c67d9e08b984..267e7edd8194 100644 --- a/test cases/unit/80 global-rpath/meson.build +++ b/test cases/unit/80 global-rpath/meson.build @@ -1,3 +1,5 @@ project('global-rpath', 'cpp') -yonder_dep = dependency('yonder') +cpp = meson.get_compiler('cpp') +yonder_libdir = get_option('yonder_libdir') +yonder_dep = cpp.find_library('yonder', dirs: [yonder_libdir]) executable('rpathified', 'rpathified.cpp', dependencies: [yonder_dep], install: true) diff --git a/test cases/unit/80 global-rpath/meson_options.txt b/test cases/unit/80 global-rpath/meson_options.txt new file mode 100644 index 000000000000..19bf25569595 --- /dev/null +++ b/test cases/unit/80 global-rpath/meson_options.txt @@ -0,0 +1 @@ +option('yonder_libdir', type: 'string') diff --git a/test cases/unit/80 global-rpath/yonder/meson.build b/test cases/unit/80 global-rpath/yonder/meson.build index e32f3833019c..a3ee7f595ea0 100644 --- a/test cases/unit/80 global-rpath/yonder/meson.build +++ b/test cases/unit/80 global-rpath/yonder/meson.build @@ -1,5 +1,3 @@ project('yonder', 'cpp') yonder = shared_library('yonder', 'yonder.cpp', install: true) install_headers('yonder.h') -pkgconfig = import('pkgconfig') -pkgconfig.generate(yonder) diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py index 2bcf5c933a4a..0f96738b2eb6 100644 --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -247,13 +247,15 @@ def test_pkgconfig_uninstalled(self): self.init(testdir) self.build() + libdir = self.builddir os.environ['PKG_CONFIG_LIBDIR'] = os.path.join(self.builddir, 'meson-uninstalled') if is_cygwin(): - os.environ['PATH'] += os.pathsep + self.builddir + os.environ['PATH'] += os.pathsep + libdir self.new_builddir() + meson_args = [f'-Dc_link_args=-Wl,-rpath,{libdir}'] testdir = os.path.join(self.common_test_dir, '44 pkgconfig-gen', 'dependencies') - self.init(testdir) + self.init(testdir, extra_args=meson_args) self.build() self.run_tests() @@ -929,9 +931,9 @@ def test_global_rpath(self): oldinstalldir = self.installdir # Build and install an external library without DESTDIR. - # The external library generates a .pc file without an rpath. yonder_dir = os.path.join(testdir, 'yonder') yonder_prefix = os.path.join(oldinstalldir, 'yonder') + yonder_includedir = os.path.join(yonder_prefix, 'include') yonder_libdir = os.path.join(yonder_prefix, self.libdir) self.prefix = yonder_prefix self.installdir = yonder_prefix @@ -955,13 +957,15 @@ def test_global_rpath(self): # (as systems like buildroot and guix are wont to do) # and verify install preserves that rpath. self.new_builddir() - env = {'LDFLAGS': rpath_format + yonder_libdir, + meson_args = [f'-Dyonder_libdir={yonder_libdir}'] + env = {'CPPFLAGS': '-I' + yonder_includedir, + 'LDFLAGS': rpath_format + yonder_libdir, 'PKG_CONFIG_PATH': os.path.join(yonder_libdir, 'pkgconfig')} if exception: with self.assertRaises(subprocess.CalledProcessError): - self.init(testdir, override_envvars=env) + self.init(testdir, extra_args=meson_args, override_envvars=env) continue - self.init(testdir, override_envvars=env) + self.init(testdir, extra_args=meson_args, override_envvars=env) self.build() self.install(use_destdir=False) got_rpath = get_rpath(os.path.join(yonder_prefix, 'bin/rpathified')) @@ -1526,7 +1530,7 @@ def test_static_link(self): # Test that installed libraries works self.new_builddir() self.prefix = oldprefix - meson_args = [f'-Dc_link_args=-L{libdir}', + meson_args = [f'-Dc_link_args=-L{libdir} -Wl,-rpath,{libdir}', '--fatal-meson-warnings'] testdir = os.path.join(self.unit_test_dir, '67 static link') env = {'PKG_CONFIG_LIBDIR': os.path.join(libdir, 'pkgconfig')}