summaryrefslogtreecommitdiff
path: root/giscanner/transformer.py
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-09-02 11:47:08 -0400
committerColin Walters <walters@verbum.org>2010-09-02 14:19:33 -0400
commit8591b8ad20b9dc8636ef6350693520099974f267 (patch)
treead70c511ceba165bf9b78e0c2ef4466501bd816c /giscanner/transformer.py
parent95883d357b9205094ea285ffb64b508e6317a823 (diff)
downloadgobject-introspection-8591b8ad20b9dc8636ef6350693520099974f267.tar.gz
scanner: Add --include-uninstalled
We need a way to add a .gir file, without also attempting to load the pkg-config file for it (since it may not be installed yet). Example: clutter builds multiple .gir files, Cally-1.0 depends on Clutter-1.0.
Diffstat (limited to 'giscanner/transformer.py')
-rw-r--r--giscanner/transformer.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 735c153b..b3660b0d 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -117,6 +117,18 @@ class Transformer(object):
self._parse_include(filename)
self._include_names.add(include)
+ def register_include_uninstalled(self, include_path):
+ basename = os.path.basename(include_path)
+ if not basename.endswith('.gir'):
+ raise SystemExit(
+"Include path %r must be a filename path ending in .gir" % (include_path, ))
+ girname = basename[:-4]
+ include = ast.Include.from_string(girname)
+ if girname in self._include_names:
+ return
+ self._parse_include(include_path, uninstalled=True)
+ self._include_names.add(include)
+
def lookup_giname(self, name):
"""Given a name of the form Foo or Bar.Foo,
return the corresponding ast.Node, or None if none
@@ -156,7 +168,7 @@ None."""
% (girname, searchdirs))
sys.exit(1)
- def _parse_include(self, filename):
+ def _parse_include(self, filename, uninstalled=False):
parser = self._cachestore.load(filename)
if parser is None:
parser = GIRParser()
@@ -166,8 +178,9 @@ None."""
for include in parser.get_includes():
self.register_include(include)
- for pkg in parser.get_pkgconfig_packages():
- self._pkg_config_packages.add(pkg)
+ if not uninstalled:
+ for pkg in parser.get_pkgconfig_packages():
+ self._pkg_config_packages.add(pkg)
namespace = parser.get_namespace()
self._includes[namespace.name] = namespace