summaryrefslogtreecommitdiff
path: root/giscanner/utils.py
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2009-08-13 23:06:51 -0400
committerColin Walters <walters@verbum.org>2009-08-17 00:22:19 -0400
commitfa71c815d441ab922b1e5501f534f2c3d1fceef8 (patch)
treea86335d50e2fe924969ca29c6ef40b6aecdb338e /giscanner/utils.py
parentaf6bcb48d777f683384d9b8497e1b0edba5b16e7 (diff)
downloadgobject-introspection-fa71c815d441ab922b1e5501f534f2c3d1fceef8.tar.gz
Support passing --library=lib<foo>.la
In addition to the current --library=<foo>, support --library=lib<foo>.la. This makes it unambiguous that we are referencing an uninstalled library and allows accurate extraction of the shared library name for the uninstalled library. * tests/scanner/Makefile.am tests/offsets/Makefile.am: Use the new form of --library=. Also some LD_LIBRARY_PATH frobbing as needed. *-expected.gir *-expected.tgir: We now pick out the shared library accurately, so fix shared-library="" in our reference girs. (The comparison may need some pre-sanitization now to work on non-ELF) http://bugzilla.gnome.org/show_bug.cgi?id=591669
Diffstat (limited to 'giscanner/utils.py')
-rw-r--r--giscanner/utils.py32
1 files changed, 27 insertions, 5 deletions
diff --git a/giscanner/utils.py b/giscanner/utils.py
index 3a26a1ee..29a55609 100644
--- a/giscanner/utils.py
+++ b/giscanner/utils.py
@@ -20,6 +20,7 @@
import re
import os
+import subprocess
# Copied from h2defs.py
_upperstr_pat1 = re.compile(r'([^A-Z])([A-Z])')
@@ -46,12 +47,33 @@ def to_underscores_noprefix(name):
_libtool_pat = re.compile("dlname='([A-z0-9\.\-\+]+)'\n")
+def _extract_dlname_field(la_file):
+ f = open(la_file)
+ data = f.read()
+ f.close()
+ m = _libtool_pat.search(data)
+ if m:
+ return m.groups()[0]
+ else:
+ return None
+
+# Returns the name that we would pass to dlopen() the library
+# corresponding to this .la file
+def extract_libtool_shlib(la_file):
+ dlname = _extract_dlname_field(la_file)
+ if dlname is None:
+ return None
+
+ # From the comments in extract_libtool(), older libtools had
+ # a path rather than the raw dlname
+ return os.path.basename(dlname)
-def extract_libtool(libname):
- data = open(libname).read()
- filename = _libtool_pat.search(data).groups()[0]
- libname = os.path.join(os.path.dirname(libname),
- '.libs', filename)
+def extract_libtool(la_file):
+ dlname = _extract_dlname_field(la_file)
+ if dlname is None:
+ raise ValueError("%s has no dlname. Not a shared library?" % la_file)
+ libname = os.path.join(os.path.dirname(la_file),
+ '.libs', dlname)
# FIXME: This hackish, but I'm not sure how to do this
# in a way which is compatible with both libtool 2.2
# and pre-2.2. Johan 2008-10-21