aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@gnome.org>2015-05-15 19:07:42 +0200
committerThibault Saunier <tsaunier@gnome.org>2015-05-16 13:21:08 +0200
commitfea0609c13d5c2de5071a83846aa6de01c31cf42 (patch)
tree0ebe4deefb8d1a1aee94e5636784aee80773e294
parent28476aa719845094b20c9ebb58506da7b514b789 (diff)
downloadmeson-fea0609c13d5c2de5071a83846aa6de01c31cf42.zip
meson-fea0609c13d5c2de5071a83846aa6de01c31cf42.tar.gz
meson-fea0609c13d5c2de5071a83846aa6de01c31cf42.tar.bz2
dependencies: Handle .la lib files returned by pkgconfig in uninstalled setups
When building against software that is being built uninstalled, pkg-config returns values from the -uninstalled.pc variant which might contain .la files as --libs. This patch opens the .la files to figure out where the actual shared library are. Some part of this is inspired by what is done in the gobject-introspection giscanner/utils.py code
-rw-r--r--authors.txt2
-rw-r--r--dependencies.py52
2 files changed, 52 insertions, 2 deletions
diff --git a/authors.txt b/authors.txt
index e963f51..b3f0ddc 100644
--- a/authors.txt
+++ b/authors.txt
@@ -15,4 +15,4 @@ Hemmo Nieminen
mfrischknecht
Matthew Bekkema
Afief Halumi
-
+Thibault Saunier
diff --git a/dependencies.py b/dependencies.py
index 6ba3453..d57df5e 100644
--- a/dependencies.py
+++ b/dependencies.py
@@ -19,6 +19,8 @@
# Currently one file, should probably be split into a
# package before this gets too big.
+import re
+import platform
import os, stat, glob, subprocess, shutil
from coredata import MesonException
import mlog
@@ -59,6 +61,9 @@ class Dependency():
class PkgConfigDependency(Dependency):
pkgconfig_found = None
+ __libtool_pat = re.compile("dlname='([A-z0-9\.\-\+]+)'\n")
+
+
def __init__(self, name, kwargs):
required = kwargs.get('required', True)
Dependency.__init__(self)
@@ -109,7 +114,21 @@ class PkgConfigDependency(Dependency):
out = p.communicate()[0]
if p.returncode != 0:
raise RuntimeError('Could not generate libs for %s.' % name)
- self.libs = out.decode().split()
+ self.libs = []
+ for lib in out.decode().split():
+ if lib.endswith(".la"):
+ shared_libname = self.__extract_libtool_shlib(lib)
+ shared_lib = os.path.join(os.path.dirname(lib), shared_libname)
+ if not os.path.exists(shared_lib):
+ shared_lib = os.path.join(os.path.dirname(lib), ".libs", shared_libname)
+
+ if not os.path.exists(shared_lib):
+ raise RuntimeError('Got a libtools specific "%s" dependencies'
+ 'but we could not compute the actual shared'
+ 'library path' % lib)
+ lib = shared_lib
+
+ self.libs.append(lib)
def get_modversion(self):
return self.modversion
@@ -138,6 +157,37 @@ class PkgConfigDependency(Dependency):
def found(self):
return self.is_found
+ def __extract_dlname_field(self, la_file):
+ f = open(la_file)
+ data = f.read()
+ f.close()
+ m = self.__libtool_pat.search(data)
+ if m:
+ return m.groups()[0]
+ else:
+ return None
+
+ def __extract_libtool_shlib(self, la_file):
+ '''
+ Returns the path to the shared library
+ corresponding to this .la file
+ '''
+ dlname = self.__extract_dlname_field(la_file)
+ if dlname is None:
+ return None
+
+ # Darwin uses absolute paths where possible; since the libtool files never
+ # contain absolute paths, use the libdir field
+ if platform.system() == 'Darwin':
+ dlbasename = os.path.basename(dlname)
+ libdir = self._extract_libdir_field(la_file)
+ if libdir is None:
+ return dlbasename
+ return libdir + '/' + dlbasename
+ # From the comments in extract_libtool(), older libtools had
+ # a path rather than the raw dlname
+ return os.path.basename(dlname)
+
class WxDependency(Dependency):
wx_found = None