meson: Vala pkg-config dependency checks don't look for vapi files
Currently, our vala pkg-config support works like this:
- We use a simple pkg-config dependency check:
dependency('foo-2.4') - While compiling vala files for a target, we unconditionally add
--pkg=foo-2.4for each pkg-config dependency listed for that target
This is correct about 80% of the time. It breaks in the following cases:
a) There’s no foo-2.4.vapi file corresponding to the foo-2.4.pc file. This can happen because of one of two reasons:
- No
.vapifile is shipped with any vala package for that library (e.g.: uuid.pc) - The correct vala development package hasn’t been installed (e.g.: libosinfo-vala on Fedora)
b) We don’t actually want to use that dependency in the Vala sources. It is only used in the C sources. This is harmless if a vapi file for that dep actually exists, but if it doesn’t it will cause an unnecessary error.
c) The foo-2.4.vapi file corresponding to the foo-2.4.pc file is shipped with the source tree. (e.g. govirt-1.0.vapi is shipped with the Boxes source tree.
d) No foo-2.4.vapi file is needed because the information contained in the vapi file is embedded in the source (e.g. Boxes does this for libuuid).
I haven’t found any cases where the vapi file has a different basename than the pc file.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Comments: 19 (19 by maintainers)
I agree that we need a way to add a dependency to a target that does not imply a
--pkgflag. I would be more in favor of a language-specific option likehas_vapi:For private bindings, it’s effectively the best approach to add them directly to the sources, but for public ones, it’s better to keep the in standard/extended paths as you would expect them to be. We could use the
has_vapiflag with a private binding shipped with the sources.This is the error you get, which is not that cryptic:
Ideally we would be searching for all the VAPIs at configure-time, but that’s a non-trivial task. The search path depends on the API version of the compiler, the
*.depsfiles found alongside and GIR packages are also supported. I think it’s best to process them like we do for headers: use inclusion paths and explicit files directly on the target.No,
find_librarydoesn’t use any additional search paths fromadd_project_arguments. However,find_libraryhas a parameter calleddirsthat can be used to add additional search paths.gitguses this feature to include custom VAPI packages.@inigomartinez:
The
.metadatafile has to follow the name of the GIR, but the VAPI generated can be called whatever you like. In this case it should begsettings-desktop-schemas.vapi. Here is an example usingvapigenfor libvips:This produces a VAPI called
vips.vapi.vapigenuses the library name passed to it and adds the.vapiextension. Usinggnome.generate_vapi()in ameson.buildfile would be something like (untested):So you simply need to change
gdesktop-enums-3.0.vapitogsettings-desktop-schemas.vapiin your build.I would question though why
gitgis carrying several third party VAPIs: https://git.gnome.org/browse/gitg/tree/vapi I haven’t checked all, but bindings likelibsoup-2.4are carried upstream and are likely to be removed from the Vala distribution itself shortly - see https://bugzilla.gnome.org/show_bug.cgi?id=773197 Having these VAPIs also distributed withgitgdoesn’t make sense.So for
gdesktop-enums-3.0.vapiyou should ideally generate this as part of the gsettings-desktop-schemas project and rename the VAPI togsettings-desktop-schemas.vapi. So it is then distributed with the development files.Your example is more to do with how the Vala community manage distribution of bindings than it is to do with Meson working around any problems. If you can’t get this upstream then
gnome.generate_vapishould be enough to generate a correctly named VAPI.