From a655b64989ecdce507567d9cd729a2cefaf91942 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 30 Sep 2017 18:03:56 +0300 Subject: Add an rpath entry to shared libraries that are linked from the source tree. --- mesonbuild/backend/backends.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'mesonbuild/backend/backends.py') diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 12fb3eb..562e467 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -298,6 +298,22 @@ class Backend: raise MesonException(m.format(target.name)) return l + def rpaths_for_bundled_shared_libraries(self, target): + paths = [] + for dep in target.external_deps: + if isinstance(dep, dependencies.ExternalLibrary): + la = dep.link_args + if len(la) == 1 and la[0].startswith(self.environment.get_source_dir()): + # The only link argument is an absolute path to a library file. + libpath = la[0] + if not(libpath.lower().endswith('.dll') or libpath.lower().endswith('.so')): + continue + absdir = os.path.split(libpath)[0] + rel_to_src = absdir[len(self.environment.get_source_dir())+1:] + assert(not os.path.isabs(rel_to_src)) + paths.append(os.path.join(self.build_to_src, rel_to_src)) + return paths + def determine_rpath_dirs(self, target): link_deps = target.get_all_link_deps() result = [] @@ -305,6 +321,7 @@ class Backend: prospective = self.get_target_dir(ld) if prospective not in result: result.append(prospective) + result += self.rpaths_for_bundled_shared_libraries(target) return result def object_filename_from_source(self, target, source, is_unity): -- cgit v1.1 From cb64a3f07a91c01c84f80d5303aaf5f0fe5ee100 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 1 Oct 2017 01:11:02 +0300 Subject: Fix MSVC builds. --- mesonbuild/backend/backends.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mesonbuild/backend/backends.py') diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 562e467..c737d49 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -306,7 +306,7 @@ class Backend: if len(la) == 1 and la[0].startswith(self.environment.get_source_dir()): # The only link argument is an absolute path to a library file. libpath = la[0] - if not(libpath.lower().endswith('.dll') or libpath.lower().endswith('.so')): + if os.path.splitext(libpath)[1] not in ['.dll', '.lib', '.so']: continue absdir = os.path.split(libpath)[0] rel_to_src = absdir[len(self.environment.get_source_dir())+1:] @@ -530,6 +530,8 @@ class Backend: dirseg = os.path.join(self.environment.get_build_dir(), self.get_target_dir(ld)) if dirseg not in result: result.append(dirseg) + for deppath in self.rpaths_for_bundled_shared_libraries(target): + result.append(os.path.normpath(os.path.join(self.environment.get_build_dir(), deppath))) return result def write_benchmark_file(self, datafile): -- cgit v1.1 From ec45c29c9ddd5d848eb1555cdc09246d8900afec Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 2 Oct 2017 00:56:38 +0300 Subject: Add rpath entries for all found libraries outside of system libraries. --- mesonbuild/backend/backends.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'mesonbuild/backend/backends.py') diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index c737d49..e0e2abc 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -303,13 +303,16 @@ class Backend: for dep in target.external_deps: if isinstance(dep, dependencies.ExternalLibrary): la = dep.link_args - if len(la) == 1 and la[0].startswith(self.environment.get_source_dir()): + if len(la) == 1 and os.path.isabs(la[0]): # The only link argument is an absolute path to a library file. libpath = la[0] + if libpath.startswith(('/usr/lib', '/lib')): + # No point in adding system paths. + continue if os.path.splitext(libpath)[1] not in ['.dll', '.lib', '.so']: continue absdir = os.path.split(libpath)[0] - rel_to_src = absdir[len(self.environment.get_source_dir())+1:] + rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] assert(not os.path.isabs(rel_to_src)) paths.append(os.path.join(self.build_to_src, rel_to_src)) return paths @@ -321,7 +324,9 @@ class Backend: prospective = self.get_target_dir(ld) if prospective not in result: result.append(prospective) - result += self.rpaths_for_bundled_shared_libraries(target) + for rp in self.rpaths_for_bundled_shared_libraries(target): + if rp not in result: + result += [rp] return result def object_filename_from_source(self, target, source, is_unity): -- cgit v1.1