GNOME Bugzilla – Bug 693471
Problems using it in vala: gir does not contain proper .h file; there is no .vapi file
Last modified: 2021-06-09 21:05:47 UTC
There are a few problems when trying to use libgweather in vala: 1) the gir does not contain the proper .h file 2) there is no .vapi file I worked around in the following way: -GWeather_3_0_gir_SCANNERFLAGS = --identifier-prefix=GWeather --symbol-prefix=gweather --pkg-export=gweather-3.0 +GWeather_3_0_gir_SCANNERFLAGS = --identifier-prefix=GWeather --symbol-prefix=gweather --pkg-export=gweather-3.0 --c-include "libgweather/gweather-weather.h,libgweather/location-entry.h" in the libgweather makefile and then generated a vapi with vapigen --pkg gio-2.0 --pkg gtk+-3.0 --library gweather-3.0 GWeather-3.0.gir I think that 1) it would be better to have a single <libgweather/gweather.h> header file 2) we should fix the gir generation to include that header 3) we should ship the vapi file either in libgweather itself or in vala
(In reply to comment #0) > There are a few problems when trying to use libgweather in vala: > > 1) the gir does not contain the proper .h file > 2) there is no .vapi file > > I worked around in the following way: > > -GWeather_3_0_gir_SCANNERFLAGS = --identifier-prefix=GWeather > --symbol-prefix=gweather --pkg-export=gweather-3.0 > +GWeather_3_0_gir_SCANNERFLAGS = --identifier-prefix=GWeather > --symbol-prefix=gweather --pkg-export=gweather-3.0 --c-include > "libgweather/gweather-weather.h,libgweather/location-entry.h" This should be --c-include "libgweather/gweather-weather.h" --c-include "libgweather/location-entry.h". > in the libgweather makefile and then generated a vapi with > vapigen --pkg gio-2.0 --pkg gtk+-3.0 --library gweather-3.0 GWeather-3.0.gir > > > I think that > > 1) it would be better to have a single <libgweather/gweather.h> header file From Vala's perspective, this is really important if the bindings are not distributed with gweather. Since G-I doesn't support per-type or per-symbol C headers we end up including all the library's headers. If gweather then adds a header we start adding that to all generated code, but gweather may be older than valac, in which case we are including a header which doesn't exist. Distributing the VAPI with gweather means that the VAPI is always targeted for the right version of gweather. I would also argue that a single include (or at least a small number) is nicer for C consumers as well. Most GNOME libraries are already using that convention. > 2) we should fix the gir generation to include that header > 3) we should ship the vapi file either in libgweather itself or in vala From Vala's point of view, shipping the file with gweather is preferred. Some reasons why are mentioned on https://live.gnome.org/Vala/UpstreamGuide I'm happy to help with maintenance just as I would if the bindings were distributed with Vala. If you're okay with distributing bindings with gweather I can throw together a patch.
I personally don't have an interest in Vala bindings for GWeather (although I care about PyGObject and gjs, so the GIR should be usable), thus if you can prepare a patch it would be very helpful. Otherwise I'll look at this soon.
Do you agree on a global gweather.h header file?
Yeah, that's fine, although I'd avoid forcing single includes, at least for the first stable release.
Created attachment 236356 [details] [review] Add a global gweather.h header file
Review of attachment 236356 [details] [review]: Looks good!
Comment on attachment 236356 [details] [review] Add a global gweather.h header file pushed. I'll try to get to the vapi stuff later or wait for Evan
Created attachment 253603 [details] [review] patch proposal for the vala support me and Paolo can take care of its maintenance in future.
Created attachment 253608 [details] [review] patch proposal for the vala support
Created attachment 253609 [details] [review] patch proposal for the vala support
Review of attachment 253609 [details] [review]: Looks good to me
With this patch Vala would have to be installed, even if you didn't want to build the VAPI, since it depends on vapigen.m4. Generally, people prefer to copy vapigen.m4 to their macro directory. vapigen.m4 code is at https://git.gnome.org/browse/vala/tree/vapigen/vapigen.m4
(In reply to comment #12) > With this patch Vala would have to be installed, even if you didn't want to > build the VAPI, since it depends on vapigen.m4. Generally, people prefer to > copy vapigen.m4 to their macro directory. > > vapigen.m4 code is at https://git.gnome.org/browse/vala/tree/vapigen/vapigen.m4 Nah, vala is part of the default installation of gnome, and is available in ostree and jhbuild. Also, it's a dependency only for git builds, so I'm fine with not having vapigen.m4 (and not having to keep it up to date)
(In reply to comment #12) > With this patch Vala would have to be installed, even if you didn't want to > build the VAPI, since it depends on vapigen.m4. Generally, people prefer to > copy vapigen.m4 to their macro directory. > > vapigen.m4 code is at https://git.gnome.org/browse/vala/tree/vapigen/vapigen.m4 Hmm, I do not understand, why it would require vala to be installed anyway. I thought, that I have a m4_ifdef([VAPIGEN_CHECK] check added for that case. I have just for fun uninstalled vala everywhere, and libgweather builds fine anyway, without generating any vapi file of course:-) libgweather-3.9.91 configure summary: Prefix: /home/ibqn/opt/gnome Source code location: . Compiler: gcc Introspection support: yes Build Vala bindings: auto That is why I am a bit confused?!:-/
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/libgweather/-/issues/117.