summaryrefslogtreecommitdiff
path: root/giscanner/dumper.py
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2009-02-16 16:52:52 -0500
committerOwen W. Taylor <otaylor@fishsoup.net>2009-02-19 12:05:10 -0500
commitec3bcb29fb938ac3d0ea70c1b739a76970613403 (patch)
treeca9b66c1652fc85fd7421097a9886a285f6ba247 /giscanner/dumper.py
parent8b1299bec2c976420bc987daf25ad74d9b615d55 (diff)
downloadgobject-introspection-ec3bcb29fb938ac3d0ea70c1b739a76970613403.tar.gz
Bug 572075 - Make the scanner work with static and convenience libraries
We need to reference the get_type() functions we are going to dlsym or otherwise the linker may not include them in the introspection binary. giscanner/dumper.py: Accept a list of _get_type() functions and write an array referencing them into the introspection binary. giscanner/glibtransformer.py: Break parsing into too stages - the stage where we compute the _get_type() functions and the stage where we invoke the introspection binary. tools/g-ir-scanner: Pass _get_type() functions from the scanner when creating the introspection binary. http://bugzilla.gnome.org/show_bug.cgi?id=572075
Diffstat (limited to 'giscanner/dumper.py')
-rw-r--r--giscanner/dumper.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/giscanner/dumper.py b/giscanner/dumper.py
index 6b78568c..e487c125 100644
--- a/giscanner/dumper.py
+++ b/giscanner/dumper.py
@@ -73,8 +73,9 @@ class LinkerError(Exception):
class DumpCompiler(object):
- def __init__(self, options):
+ def __init__(self, options, get_type_functions):
self._options = options
+ self._get_type_functions = get_type_functions
self._tmpdir = tempfile.mkdtemp('', 'tmp-introspect')
self._compiler_cmd = os.environ.get('CC', 'gcc')
@@ -93,6 +94,22 @@ class DumpCompiler(object):
c_path = self._generate_tempfile('.c')
f = open(c_path, 'w')
f.write(_PROGRAM_TEMPLATE)
+
+ # We need to reference our get_type functions to make sure they are
+ # pulled in at the linking stage if the library is a static library
+ # rather than a shared library.
+ for func in self._get_type_functions:
+ f.write("extern GType " + func + "(void);\n")
+ f.write("GType (*GI_GET_TYPE_FUNCS_[])(void) = {\n")
+ first = True
+ for func in self._get_type_functions:
+ if first:
+ first = False
+ else:
+ f.write(",\n")
+ f.write(" " + func)
+ f.write("\n};\n")
+
f.close()
o_path = self._generate_tempfile('.o')
@@ -208,6 +225,6 @@ class DumpCompiler(object):
subprocess.check_call(args)
-def compile_introspection_binary(options):
- dc = DumpCompiler(options)
+def compile_introspection_binary(options, get_type_functions):
+ dc = DumpCompiler(options, get_type_functions)
return dc.run()