diff options
-rw-r--r-- | authors.txt | 2 | ||||
-rw-r--r-- | dependencies.py | 52 | ||||
-rwxr-xr-x | meson.py | 5 | ||||
-rw-r--r-- | modules/gnome.py | 11 |
4 files changed, 67 insertions, 3 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 @@ -144,6 +144,11 @@ itself as required.''' pickle.dump(b, open(dumpfile, 'wb')) def run(args): + if sys.version_info < (3, 4): + print('Meson works correctly only with python 3.4+.') + print('You have python %s.' % sys.version) + print('Please update your environment') + return 1 if args[-1] == 'secret-handshake': args = args[:-1] handshake = True diff --git a/modules/gnome.py b/modules/gnome.py index afd07a0..55eec17 100644 --- a/modules/gnome.py +++ b/modules/gnome.py @@ -55,10 +55,16 @@ class GnomeModule: nsversion = kwargs.pop('nsversion') libsources = kwargs.pop('sources') girfile = '%s-%s.gir' % (ns, nsversion) + scan_command = ['g-ir-scanner', '@INPUT@'] scan_command += pkgargs scan_command += ['--namespace='+ns, '--nsversion=' + nsversion, '--warn-all', '--output', '@OUTPUT@'] + + for incdirs in girtarget.include_dirs: + for incdir in incdirs.get_incdirs(): + scan_command += ['-I%s' % os.path.join(state.environment.get_source_dir(), incdir)] + if 'includes' in kwargs: includes = kwargs.pop('includes') if isinstance(includes, str): @@ -99,7 +105,10 @@ class GnomeModule: if isinstance(girtarget, build.Executable): scan_command += ['--program', girtarget] elif isinstance(girtarget, build.SharedLibrary): - scan_command += ['--library', girtarget.get_basename()] + libname = girtarget.get_basename() + if girtarget.soversion: + libname += "-%s" % girtarget.soversion + scan_command += ['--library', libname] scankwargs = {'output' : girfile, 'input' : libsources, 'command' : scan_command} |