[gobject-introspection] scanner: Support --header-only flag



commit 80de6648b5be315c9f2b73b3f04282e42517568e
Author: Colin Walters <walters verbum org>
Date:   Wed Oct 19 14:44:48 2011 -0400

    scanner: Support --header-only flag
    
    This is useful for someone who just wants a set of constants from a .h
    file accessible by introspection.

 giscanner/scannermain.py  |   12 ++++++++++--
 tests/scanner/Makefile.am |    5 ++++-
 2 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 6dc56ef..bcacd0f 100755
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -108,6 +108,9 @@ def _get_option_parser():
     parser.add_option("-L", "--library-path",
                       action="append", dest="library_paths", default=[],
                       help="directories to search for libraries")
+    parser.add_option("", "--header-only",
+                      action="store_true", dest="header_only", default=[],
+                      help="If specified, just generate a GIR for the given header files")
     parser.add_option("-n", "--namespace",
                       action="store", dest="namespace_name",
                       help=("name of namespace for this unit, also "
@@ -389,7 +392,9 @@ def scanner_main(args):
     else:
         _error("Unknown format: %s" % (options.format, ))
 
-    if not (options.libraries or options.program):
+    if not (options.libraries
+            or options.program
+            or options.header_only):
         _error("Must specify --program or --library")
 
     namespace = create_namespace(options)
@@ -413,7 +418,10 @@ def scanner_main(args):
     transformer.set_annotations(blocks)
     transformer.parse(ss.get_symbols())
 
-    shlibs = create_binary(transformer, options, args)
+    if not options.header_only:
+        shlibs = create_binary(transformer, options, args)
+    else:
+        shlibs = []
 
     main = MainTransformer(transformer, blocks)
     main.transform()
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am
index 0b28709..38e1cd0 100644
--- a/tests/scanner/Makefile.am
+++ b/tests/scanner/Makefile.am
@@ -115,7 +115,10 @@ Bar_1_0_gir_SCANNERFLAGS = --accept-unprefixed
 GIRS += Bar-1.0.gir
 endif
 
+Headeronly-1.0.gir: headeronly.h
+	$(AM_V_GEN) $(INTROSPECTION_SCANNER) $(INTROSPECTION_SCANNER_ARGS) --warn-all --warn-error --reparse-validate --namespace=Headeronly --nsversion=1.0 --header-only --output=$@ $<
+
 %.gir.check: %.gir
 	@diff -u -U 10 $(srcdir)/$*-expected.gir $*.gir && echo "  TEST  $*.gir"
 
-check-local: $(CHECKGIRS) $(TYPELIBS)
+check-local: Headeronly-1.0.gir $(CHECKGIRS) $(TYPELIBS)



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