giscanner: Allow passing additional include dirs when parsing a gir
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>
Mon, 15 Aug 2011 15:45:09 +0000 (17:45 +0200)
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>
Mon, 15 Aug 2011 15:48:45 +0000 (17:48 +0200)
giscanner/docmain.py
giscanner/transformer.py

index 9bca4c85abe62ca602c7352988b44aa5b83a3447..e6ae8b604351dd245235e4a12a906563c9145de1 100644 (file)
@@ -18,6 +18,7 @@
 # 02110-1301, USA.
 #
 
+import os
 import optparse
 
 from .docbookwriter import DocBookWriter
@@ -31,7 +32,13 @@ from .transformer import Transformer
 class GIDocGenerator(object):
 
     def parse(self, filename):
-        self.transformer = Transformer.parse_from_gir(filename)
+        if 'UNINSTALLED_INTROSPECTION_SRCDIR' in os.environ:
+            top_srcdir = os.environ['UNINSTALLED_INTROSPECTION_SRCDIR']
+            top_builddir = os.environ['UNINSTALLED_INTROSPECTION_BUILDDIR']
+            extra_include_dirs = [os.path.join(top_srcdir, 'gir'), top_builddir]
+        else:
+            extra_include_dirs = []
+        self.transformer = Transformer.parse_from_gir(filename, extra_include_dirs)
 
     def generate(self, writer, output):
         writer.add_transformer(self.transformer)
index 565d996e77665c2deaf5c52079a730f5670fc347..74985ffebe455a4d07a7999b44b7aa1c07c112dc 100644 (file)
@@ -179,8 +179,10 @@ None."""
         sys.exit(1)
 
     @classmethod
-    def parse_from_gir(cls, filename):
+    def parse_from_gir(cls, filename, extra_include_dirs=None):
         self = cls(None)
+        if extra_include_dirs is not None:
+            self.set_include_paths(extra_include_dirs)
         self.set_passthrough_mode()
         self._parse_include(filename)
         parser = self._cachestore.load(filename)