summaryrefslogtreecommitdiff
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
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.
-rw-r--r--docs/g-ir-scanner.112
-rw-r--r--giscanner/scannermain.py8
-rw-r--r--giscanner/transformer.py19
3 files changed, 31 insertions, 8 deletions
diff --git a/docs/g-ir-scanner.1 b/docs/g-ir-scanner.1
index cb5a50a1..7108dda6 100644
--- a/docs/g-ir-scanner.1
+++ b/docs/g-ir-scanner.1
@@ -32,10 +32,14 @@ This parameters decides which the resulting format will be used.
The default value is gir.
.TP
.B \--include=NAME
-Parses another metadata file. The format is determined by looking
-at the file suffix. If a library depends on another the corresponding
-metadata file should be included so references to external types are
-correctly specified.
+Add the specified introspection dependency to the scanned namespace.
+NAME is of the form NAMESPACE-VERSION, like Gtk-3.0.
+.TP
+.B \--include-uninstalled=PATH
+Add the specified introspection dependency to the scanned namespace.
+This differs from \--include in that it takes a file path, and
+does not process the pkg-config dependencies (since they may not
+be installed yet).
.TP
.B \--add-include-path=PATH
Add a directory to the path which the scanner uses to find GIR files.
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index d2bd8766..9146a12e 100644
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -55,7 +55,11 @@ def _get_option_parser():
help="format to use, one of gidl, gir")
parser.add_option("-i", "--include",
action="append", dest="includes", default=[],
- help="include types for other gidls")
+ help="Add specified gir file as dependency")
+ parser.add_option("", "--include-uninstalled",
+ action="append", dest="includes_uninstalled", default=[],
+ help="""A file path to a dependency; only use this when building multiple .gir files
+inside a single module.""")
parser.add_option("", "--add-include-path",
action="append", dest="include_paths", default=[],
help="include paths for other GIR files")
@@ -281,6 +285,8 @@ def scanner_main(args):
except:
_error("Malformed include %r\n" % (include, ))
transformer.register_include(include_obj)
+ for include_path in options.includes_uninstalled:
+ transformer.register_include_uninstalled(include_path)
packages = set(options.packages)
packages.update(transformer.get_pkgconfig_packages())
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