Skip to content

Support GTK GObject Introspection database format support

Context

Debian bug #1035669 describes a problem where a user cannot convert a .typelib file that magic identifies[1] as a G-IR binary database into a corresponding XML serialization format.

That format is part of the GTK GObject Introspection framework, and the failure occurs because a constant declared in the source code of the affected package is identified as an interface type (possibly incorrectly) that the serializer does not support.

Why the feature request?

I've found a possible fix in the package source code, but it's difficult for me to determine what the practical effects of that are on the resulting .typelib binary database file (other than knowing that it can be serialized to XML successfully by the existing GI tooling). Understanding the effects could be important in order to check that I haven't broken other parts of the interface, and/or figure out what the impact could be on dependencies of the package.

Existing utilities

There do not seem to be many existing tools that support this GTK GObject Introspection .typelib file format. However, I did learn of some community-supported, Apache-licensed code for JetBrains' Integrated Development Environments that handles this.

In particular: there is support for generating Python library code from an input .typelib file. The output of that might not be ideal for diffoscope comparison purposes, because there is a level-of-indirection involved there, but the fact that the repository provides support for generating code indicates that it can read the database format.

If relevant, it might require some extraction and refactoring since there's a lot of other unrelated functionality; either way, it could offer a starting point (it has in this one-off investigation I've been doing).

For reference, the command that I used to generate a Python library from the .typelib file was:

# from the source directory that contains the typelib file, filter to inferred-module-name gi.repository.HarfBuzz
intellij-community/python/helpers$ python3 -m generator3 -s /usr/lib/x86_64-linux-gnu/girepository-1.0/ --name-pattern gi.repository.HarfBuzz  -d harfbuzz-output-dir

[1] -

$ file /usr/lib/x86_64-linux-gnu/girepository-1.0/HarfBuzz-0.0.typelib
/usr/lib/x86_64-linux-gnu/girepository-1.0/HarfBuzz-0.0.typelib: G-IR binary database, v4.0, 502 entries/494 local
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information