After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 663049 - Add gobject introspection bindings
Add gobject introspection bindings
Status: RESOLVED FIXED
Product: librsvg
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: librsvg maintainers
librsvg maintainers
Depends on:
Blocks:
 
 
Reported: 2011-10-30 15:19 UTC by Daniel Drake
Modified: 2011-11-01 22:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch to add gobject introspection bindings (3.35 KB, patch)
2011-10-30 15:19 UTC, Daniel Drake
none Details | Review
fixup patch (1.74 KB, patch)
2011-10-31 18:40 UTC, Daniel Drake
none Details | Review
python test app (297 bytes, text/plain)
2011-10-31 18:41 UTC, Daniel Drake
  Details
output gir file (171.60 KB, text/plain)
2011-10-31 19:06 UTC, Daniel Drake
  Details

Description Daniel Drake 2011-10-30 15:19:43 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
Comment 1 Daniel Drake 2011-10-30 15:20:03 UTC
Sorry, I meant gobject-introspection fix from bug #663048
Comment 2 Christian Persch 2011-10-30 15:30:37 UTC
+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.
Comment 3 Daniel Drake 2011-10-30 15:51:48 UTC
Thanks for the quick review. All of the files are in srcdir according to my eyes - what am I missing?
Comment 4 Christian Persch 2011-10-30 18:01:12 UTC
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) ?
Comment 5 Daniel Drake 2011-10-31 18:38:13 UTC
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
Comment 6 Daniel Drake 2011-10-31 18:40:40 UTC
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.
Comment 7 Daniel Drake 2011-10-31 18:41:08 UTC
Created attachment 200360 [details]
python test app
Comment 8 Christian Persch 2011-10-31 18:53:26 UTC
-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 ?
Comment 9 Daniel Drake 2011-10-31 19:05:42 UTC
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.
Comment 10 Daniel Drake 2011-10-31 19:06:30 UTC
Created attachment 200364 [details]
output gir file
Comment 11 Christian Persch 2011-10-31 19:56:22 UTC
Thanks, looks ok to me.

I've squashed the commits and pushed to master; please verify I got everything right :-)
Comment 12 Daniel Drake 2011-11-01 21:56:04 UTC
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.
Comment 13 Christian Persch 2011-11-01 22:01:48 UTC
Hmm, that's a bad trap. Should be fixed on master now.
Comment 14 Daniel Drake 2011-11-01 22:08:15 UTC
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 :)