diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-06-18 19:23:10 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-06-18 19:23:10 +0300 |
commit | e72f9b2312439c21d029b05648a9058fdadf0076 (patch) | |
tree | 9d13ef7da86fe4952a8d34c74795e5f816a677ce | |
parent | c4885ea0a553e9ba05c90088e5f454142c726ac1 (diff) | |
download | meson-e72f9b2312439c21d029b05648a9058fdadf0076.zip meson-e72f9b2312439c21d029b05648a9058fdadf0076.tar.gz meson-e72f9b2312439c21d029b05648a9058fdadf0076.tar.bz2 |
Rework pkgconfig and add missing method. Fixes #153.
-rw-r--r-- | dependencies.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/dependencies.py b/dependencies.py index 5173526..b4f59ee 100644 --- a/dependencies.py +++ b/dependencies.py @@ -141,7 +141,7 @@ class PkgConfigDependency(Dependency): self.libs = [] for lib in out.decode().split(): if lib.endswith(".la"): - shared_libname = self.__extract_libtool_shlib(lib) + 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) @@ -195,33 +195,36 @@ 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_field(self, la_file, fieldname): + for line in open(la_file): + arr = line.strip().split('=') + if arr[0] == fieldname: + return arr[1][1:-1] + return None + + def extract_dlname_field(self, la_file): + return self.extract_field(la_file, 'dlname') - def __extract_libtool_shlib(self, la_file): + def extract_libdir_field(self, la_file): + return self.extract_field(la_file, 'libdir') + + 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) + 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': + if mesonlib.is_osx(): dlbasename = os.path.basename(dlname) - libdir = self._extract_libdir_field(la_file) + libdir = self.extract_libdir_field(la_file) if libdir is None: return dlbasename - return libdir + '/' + dlbasename + return os.path.join(libdir, dlbasename) # From the comments in extract_libtool(), older libtools had # a path rather than the raw dlname return os.path.basename(dlname) |