summaryrefslogtreecommitdiff
path: root/giscanner/girwriter.py
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2009-02-05 17:36:35 -0500
committerColin Walters <walters@verbum.org>2009-02-11 15:03:16 -0500
commit44ea75378eb33fa6386e66e9e5a55f3122363fb8 (patch)
tree27385b5c523f7390193dba950df134540aabd838 /giscanner/girwriter.py
parent1b5e689fe2fc105725fe71051c184e0f1c461223 (diff)
downloadgobject-introspection-44ea75378eb33fa6386e66e9e5a55f3122363fb8.tar.gz
Bug 567906 - Put pkg-config dependencies in .gir files
When generating a .gir file, we now first parse all of our .gir includes to pick up their <package> headers. Then, we merge that with the set of --pkg arguments passed to us, run pkg-config to gather the arguments, and finally save the merged pkg-config list to our new .gir file. This is useful for software which needs to map from .gir to pkg-config in a programmatic way.
Diffstat (limited to 'giscanner/girwriter.py')
-rw-r--r--giscanner/girwriter.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 657063e6..35c9b35e 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -33,15 +33,20 @@ from .xmlwriter import XMLWriter
class GIRWriter(XMLWriter):
- def __init__(self, namespace, shlibs, includes):
+ def __init__(self, namespace, shlibs, includes, pkgs):
super(GIRWriter, self).__init__()
self.write_comment(
'''This file was automatically generated from C sources - DO NOT EDIT!
To affect the contents of this file, edit the original C definitions,
and/or use gtk-doc annotations. ''')
- self._write_repository(namespace, shlibs, includes)
-
- def _write_repository(self, namespace, shlibs, includes=set()):
+ self._write_repository(namespace, shlibs, includes, pkgs)
+
+ def _write_repository(self, namespace, shlibs, includes=None,
+ packages=None):
+ if includes is None:
+ includes = frozenset()
+ if packages is None:
+ packages = frozenset()
attrs = [
('version', '1.0'),
('xmlns', 'http://www.gtk.org/introspection/core/1.0'),
@@ -51,12 +56,18 @@ and/or use gtk-doc annotations. ''')
with self.tagcontext('repository', attrs):
for include in sorted(includes):
self._write_include(include)
+ for pkg in sorted(set(packages)):
+ self._write_pkgconfig_pkg(pkg)
self._write_namespace(namespace, shlibs)
def _write_include(self, include):
attrs = [('name', include.name), ('version', include.version)]
self.write_tag('include', attrs)
+ def _write_pkgconfig_pkg(self, package):
+ attrs = [('name', package)]
+ self.write_tag('package', attrs)
+
def _write_namespace(self, namespace, shlibs):
libraries = []
for l in shlibs: