[gobject-introspection] giscanner: Allow passing additional include dirs when parsing a gir



commit 684bc3384e23b8168b06c480de09f6650a7ddd63
Author: Tomeu Vizoso <tomeu vizoso collabora co uk>
Date:   Mon Aug 15 17:45:09 2011 +0200

    giscanner: Allow passing additional include dirs when parsing a gir

 giscanner/docmain.py     |    9 ++++++++-
 giscanner/transformer.py |    4 +++-
 2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/giscanner/docmain.py b/giscanner/docmain.py
index 9bca4c8..e6ae8b6 100644
--- a/giscanner/docmain.py
+++ b/giscanner/docmain.py
@@ -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)
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 565d996..74985ff 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -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)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]