GNOME Bugzilla – Bug 663049
Add gobject introspection bindings
Last modified: 2011-11-01 22:12:52 UTC
Created attachment 200280 [details] [review] patch to add gobject introspection bindings Patch attached. Needed for using librsvg from python with pygi/GTK3. We'll be using this from Sugar. Requires recent pango version and gobject-introspection fix from bug #200279
Sorry, I meant gobject-introspection fix from bug #663048
+INTROSPECTION_GIRS = Rsvg-@RSVG_API_MAJOR_VERSION@.0.gir [...] +Rsvg-@RSVG_API_MAJOR_VERSION@_0.gir: librsvg-@RSVG_API_MAJOR_VERSION@.la Shouldn't hardcode the 0, but should define RSVG_API_MINOR_VERSION=0 in configure.in and use that instead. +Rsvg_@RSVG_API_MAJOR_VERSION@_0_gir_FILES = $(addprefix $(srcdir)/, $(introspection_files)) This is wrong, not all files in $introspection_files exist in srcdir.
Thanks for the quick review. All of the files are in srcdir according to my eyes - what am I missing?
librsvg-feature.h and librsvg-enum-types.[ch] are in builddir. I think using ..._gir_FILES = $(librsvg_@RSVG_API_MAJOR_VERSION@_la_SOURCES) directly (and adding the include headers to that variable, which is the correct thing to do anyway) should work. I've done that on the 'introspection' branch; can you check that this works (I don't have introspection buildable here). Why is libxml-2.0 in the INCLUDES? librsvg exposes no API with it; it's only used internally. ..._gir_CFLAGS had $(INCLUDES) in it which is not used in librsvg's Makefile.am at all; did you mean to put $(librsvg_@RSVG_API_MAJOR_VERSION@_la_CFLAGS) (and/or _CPPFLAGS) instead, or is it ok to just omit that (as I have done) ?
Without libxml2 stuff, this happens: GISCAN Rsvg-2.0.gir In file included from /home/dsd/projects/librsvg/rsvg-css.h:31:0, from <stdin>:5: /home/dsd/projects/librsvg/rsvg-private.h:33:24: fatal error: libxml/SAX.h: No such file or directory compilation terminated. Error while processing the source. make[2]: *** [Rsvg-2.0.gir] Error 1
Created attachment 200359 [details] [review] fixup patch Here is a patch for your introspection branch which makes it work for me. I also added some extra annotations needed by Sugar. I'll also attach a python test case which uses these functions.
Created attachment 200360 [details] python test app
-Rsvg_@RSVG_API_VERSION_U@_gir_NAMESPACE = RSVG +Rsvg_@RSVG_API_VERSION_U@_gir_NAMESPACE = Rsvg Is that just a preference, or required? (I don't really care if it's capitalised or not, just curious.) Could you also attach the generated .gir file, for inspection? (In reply to comment #5) > Without libxml2 stuff, this happens: > > GISCAN Rsvg-2.0.gir > In file included from /home/dsd/projects/librsvg/rsvg-css.h:31:0, > from <stdin>:5: > /home/dsd/projects/librsvg/rsvg-private.h:33:24: fatal error: libxml/SAX.h: No > such file or directory > compilation terminated. > Error while processing the source. > make[2]: *** [Rsvg-2.0.gir] Error 1 Hmm. Maybe this is a case for _gir_PACKAGES instead of _gir_INCLUDES ?
The NAMESPACE change is required. Otherwise the error is: GISCAN Rsvg-2.0.gir Namespace is empty; likely causes are: * Not including .h files to be scanned * Broken --identifier-prefix I can put libxml2 in PACKAGES rather than INCLUDES and indeed it works - nice. So I guess the following is correct: Rsvg_@RSVG_API_VERSION_U@_gir_PACKAGES = \ libxml-2.0 \ pango \ $(NULL) Rsvg_@RSVG_API_VERSION_U@_gir_INCLUDES = \ GLib-2.0 \ Gio-2.0 \ GdkPixbuf-2.0 \ cairo-1.0 \ $(NULL) That is, Requires specified by librsvg-2.0.pc are listed in INCLUDES, and the other stuff required for g-ir-scanner to work is listed in PACKAGES.
Created attachment 200364 [details] output gir file
Thanks, looks ok to me. I've squashed the commits and pushed to master; please verify I got everything right :-)
Thanks! Almost but not quite - g-ir-scanner fails: GISCAN Rsvg-2.0.gir Package libxml2-2.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `libxml2-2.0.pc' to the PKG_CONFIG_PATH environment variable No package 'libxml2-2.0' found Package Pango-1.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `Pango-1.0.pc' to the PKG_CONFIG_PATH environment variable No package 'Pango-1.0' found Please check the PACKAGES and INCLUDES lines against the ones I suggested above.
Hmm, that's a bad trap. Should be fixed on master now.
Thanks for being so responsive here and for cleaning up my work - its now working fine! Looking forward to using this in Sugar very soon :)