summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 9b1b7c64..f2dee100 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 116681ae..4742840d 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 ec7b2b55..e3c03932 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 c0fa2aa5..6a1d8a44 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 f53f7fc3..8205828b 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")