Add rpath entries for all found libraries outside of system libraries.

pull/2397/head
Jussi Pakkanen 7 years ago
parent 4e42861467
commit ec45c29c9d
  1. 13
      docs/markdown/snippets/prebuilt.md
  2. 11
      mesonbuild/backend/backends.py

@ -1,9 +1,14 @@
# Better support for prebuilt shared libraries # Better support for shared libraries in non-system paths
Meson has had support for prebuilt object files and static libraries. Meson has had support for prebuilt object files and static libraries.
This release adds feature parity to shared libraries. This means This release adds feature parity to shared libraries that are either
that e.g. shipping prebuilt libraries as subprojects now can in non-standard system paths or shipped as part of your project. On
be as simple as writing a definition file that looks like this. systems that support rpath, Meson automatically adds rpath entries
to built targets using manually found external libraries.
This means that e.g. supporting prebuilt libraries shipped with your
source or provided by subprojects or wrap definitions by writing a
build file like this:
project('myprebuiltlibrary', 'c') project('myprebuiltlibrary', 'c')

@ -303,13 +303,16 @@ class Backend:
for dep in target.external_deps: for dep in target.external_deps:
if isinstance(dep, dependencies.ExternalLibrary): if isinstance(dep, dependencies.ExternalLibrary):
la = dep.link_args 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. # The only link argument is an absolute path to a library file.
libpath = la[0] 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']: if os.path.splitext(libpath)[1] not in ['.dll', '.lib', '.so']:
continue continue
absdir = os.path.split(libpath)[0] 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)) assert(not os.path.isabs(rel_to_src))
paths.append(os.path.join(self.build_to_src, rel_to_src)) paths.append(os.path.join(self.build_to_src, rel_to_src))
return paths return paths
@ -321,7 +324,9 @@ class Backend:
prospective = self.get_target_dir(ld) prospective = self.get_target_dir(ld)
if prospective not in result: if prospective not in result:
result.append(prospective) 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 return result
def object_filename_from_source(self, target, source, is_unity): def object_filename_from_source(self, target, source, is_unity):

Loading…
Cancel
Save