Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2009-02-19 22:52:22 (GMT)
committer Colin Walters <walters@verbum.org>2009-02-20 14:10:46 (GMT)
commitff4628ced457a5460f854abb8cdf923cd67c4e6e (patch)
treea9ea00be6333511b7ea1232b039523731f1fe0b8
parentc86b12154bda14294dddf58bf3026c487566e3af (diff)
Bug 572423 - Support --c-include argument for specifying C headers
This option is for specifying inside the .gir what C header files should be included by C consumers (as opposed to parsed by the scanner).
-rw-r--r--gir/Makefile.am31
-rw-r--r--giscanner/girwriter.py14
-rw-r--r--tests/scanner/Makefile.am1
-rw-r--r--tests/scanner/foo-1.0-expected.gir1
-rwxr-xr-xtools/g-ir-scanner5
5 files changed, 35 insertions, 17 deletions
diff --git a/gir/Makefile.am b/gir/Makefile.am
index 9b1b7c6..f2dee10 100644
--- a/gir/Makefile.am
+++ b/gir/Makefile.am
@@ -31,7 +31,8 @@ GLib-2.0.gir: $(SCANNER_BIN) $(SCANNER_LIBS) Makefile glib-2.0.c
--noclosure \
--output $@ \
--strip-prefix=g \
- --libtool="$(LIBTOOL)" \
+ --libtool="$(LIBTOOL)" \
+ --c-include="glib.h" \
--library=$(GLIB_LIBRARY) \
--pkg glib-2.0 \
$(CPPFLAGS) \
@@ -63,13 +64,14 @@ GObject-2.0.gir: GLib-2.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile
--noclosure \
--output $@ \
--strip-prefix=g \
- --libtool="$(LIBTOOL)" \
- --include=GLib-2.0 \
+ --libtool="$(LIBTOOL)" \
+ --c-include="glib-object.h" \
+ --include=GLib-2.0 \
--library=$(GOBJECT_LIBRARY) \
-I$(GOBJECT_INCLUDEDIR) \
-I$(GOBJECT_LIBDIR)/glib-2.0/include \
-DGOBJECT_COMPILATION \
- --pkg gobject-2.0 \
+ --pkg gobject-2.0 \
$(GLIB_INCLUDEDIR)/gobject/*.h
$(SCANNER) $(SCANNER_ARGS) \
--xpath-assertions=$(srcdir)/GObject-2.0.xpath GObject-2.0.gir
@@ -92,12 +94,13 @@ GModule-2.0.gir: GLib-2.0.gir $(SCANNER_BIN) $(SCANNER_LIBS)
--noclosure \
--output $@ \
--strip-prefix=g \
- --libtool="$(LIBTOOL)" \
- --include=GLib-2.0 \
+ --libtool="$(LIBTOOL)" \
+ --c-include="gmodule.h" \
+ --include=GLib-2.0 \
--library=$(GMODULE_LIBRARY) \
-I$(GMODULE_INCLUDEDIR) \
-I$(GMODULE_LIBDIR)/glib-2.0/include \
- --pkg gmodule-2.0 \
+ --pkg gmodule-2.0 \
$(GLIB_INCLUDEDIR)/gmodule.h
BUILT_GIRSOURCES += GModule-2.0.gir
@@ -124,8 +127,9 @@ Gio-2.0.gir: GObject-2.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile $(srcdir)/g
--noclosure \
--output $@ \
--strip-prefix=g \
- --libtool="$(LIBTOOL)" \
- --include=GObject-2.0 \
+ --libtool="$(LIBTOOL)" \
+ --c-include="gio/gio.h" \
+ --include=GObject-2.0 \
--library=$(GIO_LIBRARY) \
-I$(GIO_INCLUDEDIR) \
-I$(GIO_LIBDIR)/glib-2.0/include \
@@ -148,12 +152,13 @@ GIRepository-2.0.gir: GObject-2.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) $(GIREPOSIT
--noclosure \
--output $@ \
--strip-prefix=g \
- --libtool="$(LIBTOOL)" \
- --include=GObject-2.0 \
+ --libtool="$(LIBTOOL)" \
+ --c-include="girepository.h" \
+ --include=GObject-2.0 \
--library=girepository-1.0 \
-I$(srcdir)/girepository \
- --pkg glib-2.0 \
- --pkg gobject-2.0 \
+ --pkg glib-2.0 \
+ --pkg gobject-2.0 \
$(GIREPOSITORY_FILES)
BUILT_GIRSOURCES += GIRepository-2.0.gir
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 116681a..4742840 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -33,20 +33,22 @@ from .xmlwriter import XMLWriter
class GIRWriter(XMLWriter):
- def __init__(self, namespace, shlibs, includes, pkgs):
+ def __init__(self, namespace, shlibs, includes, pkgs, c_includes):
super(GIRWriter, self).__init__()
self.write_comment(
'''This file was automatically generated from C sources - DO NOT EDIT!
To affect the contents of this file, edit the original C definitions,
and/or use gtk-doc annotations. ''')
- self._write_repository(namespace, shlibs, includes, pkgs)
+ self._write_repository(namespace, shlibs, includes, pkgs, c_includes)
def _write_repository(self, namespace, shlibs, includes=None,
- packages=None):
+ packages=None, c_includes=None):
if includes is None:
includes = frozenset()
if packages is None:
packages = frozenset()
+ if c_includes is None:
+ c_includes = frozenset()
attrs = [
('version', '1.0'),
('xmlns', 'http://www.gtk.org/introspection/core/1.0'),
@@ -58,6 +60,8 @@ and/or use gtk-doc annotations. ''')
self._write_include(include)
for pkg in sorted(set(packages)):
self._write_pkgconfig_pkg(pkg)
+ for c_include in sorted(set(c_includes)):
+ self._write_c_include(c_include)
self._write_namespace(namespace, shlibs)
def _write_include(self, include):
@@ -68,6 +72,10 @@ and/or use gtk-doc annotations. ''')
attrs = [('name', package)]
self.write_tag('package', attrs)
+ def _write_c_include(self, c_include):
+ attrs = [('name', c_include)]
+ self.write_tag('c:include', attrs)
+
def _write_namespace(self, namespace, shlibs):
libraries = []
for l in shlibs:
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am
index ec7b2b5..e3c0393 100644
--- a/tests/scanner/Makefile.am
+++ b/tests/scanner/Makefile.am
@@ -68,6 +68,7 @@ foo-1.0.gir: libfoo.la foo.c foo.h utility-1.0.gir $(SCANNER_BIN) $(SCANNER_LIBS
$(CHECK_DEBUG) $(SCANNER) \
--include=GObject-2.0 \
--include=utility-1.0 \
+ --c-include="foo.h" \
--libtool="$(LIBTOOL)" \
--library=foo \
--namespace=foo \
diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir
index c0fa2aa..6a1d8a4 100644
--- a/tests/scanner/foo-1.0-expected.gir
+++ b/tests/scanner/foo-1.0-expected.gir
@@ -10,6 +10,7 @@ and/or use gtk-doc annotations. -->
<include name="GObject" version="2.0"/>
<include name="utility" version="1.0"/>
<package name="gobject-2.0"/>
+ <c:include name="foo.h"/>
<namespace name="foo" version="1.0" shared-library="foo">
<alias name="List" target="GLib.SList" c:type="FooList"/>
<alias name="ObjectCookie" target="any" c:type="FooObjectCookie"/>
diff --git a/tools/g-ir-scanner b/tools/g-ir-scanner
index f53f7fc..8205828 100755
--- a/tools/g-ir-scanner
+++ b/tools/g-ir-scanner
@@ -111,6 +111,9 @@ def _get_option_parser():
parser.add_option("", "--xpath-assertions",
action="store", dest="xpath_assertions",
help="Use given file to create assertions on GIR content")
+ parser.add_option("", "--c-include",
+ action="append", dest="c_includes", default=[],
+ help="headers which should be included in C programs")
group = optparse.OptionGroup(parser, "Preprocessor options")
group.add_option("-I", help="Pre-processor include file",
@@ -345,7 +348,7 @@ def main(args):
# Write out AST
writer = Writer(namespace, libraries, transformer.get_includes(),
- options.packages)
+ options.packages, options.c_includes)
data = writer.get_xml()
if options.output:
fd = open(options.output, "w")