Generate introspection data

Currently, the introspection data for GLib and its sub-libraries is
generated by gobject-introspection, to avoid the cyclic dependency
between the two projects.

Since gobject-introspection is generally available on installed systems,
we can check for its presence, and generate the introspection data
directly from GLib.

This does introduce a cyclic dependency, which is why it's possible to
build GLib without introspection, then build gobject-introspection, and
finally rebuild GLib.

By having introspection data available during the GLib build, we can do
things like generating documentation; validating newly added API; and
close the loop between adding new API and it becoming available to non-C
consumers of the C ABI (i.e. language bindings).
This commit is contained in:
Emmanuele Bassi
2023-10-13 12:57:57 +01:00
committed by Philip Withnall
parent 6e771f0e84
commit fe32c3f5c5
6 changed files with 154 additions and 3 deletions

View File

@@ -163,6 +163,58 @@ pkg.generate(libgobject,
description : 'GLib Type, Object, Parameter and Signal Library',
)
if enable_gir
# We generate GLib-2.0 here, as we need various GTypes
glib_gir = gnome.generate_gir(libglib,
sources: [
glibconfig_h,
gversionmacros_h,
glib_visibility_h,
glib_headers,
glib_deprecated_headers,
glib_sub_headers,
glib_enumtypes_h,
glib_types_h,
glib_deprecated_sources,
glib_sources,
],
namespace: 'GLib',
nsversion: '2.0',
identifier_prefix: 'G',
symbol_prefix: 'g',
export_packages: 'glib-2.0',
header: 'glib.h',
install: true,
dependencies: libglib_dep,
extra_args: gir_args + [
'-DGLIB_COMPILATION',
'-DGETTEXT_PACKAGE="dummy"',
'--symbol-prefix=glib',
'--library=gobject-2.0',
],
)
gobject_gir = gnome.generate_gir(libgobject,
sources: [
gobject_visibility_h,
gobject_install_headers,
gobject_sources,
],
namespace: 'GObject',
nsversion: '2.0',
identifier_prefix: 'G',
symbol_prefix: 'g',
export_packages: 'gobject-2.0',
header: 'glib-object.h',
includes: [ glib_gir[0] ],
install: true,
extra_args: gir_args + [
'-DGOBJECT_COMPILATION',
'--symbol-prefix=gobject',
],
)
endif
libgobject_dep = declare_dependency(link_with : libgobject,
include_directories : [gobjectinc],
sources : [gobject_visibility_h, glib_enumtypes_h],