build: Move gir generation to an introspection folder

Generating gir and typelib files has inter-dependencies that may depend
on other elements.

For example, glib requires gobject and gdump generated files require
gmodule, so we've a cyclic dependency because gmodule requires gobject,
that requires glib.

To prevent this, let's just generate the introspection files at once in
a different meson file so that we don't have to deal with this.

As per this we could even revert commit fa37ab6d0 since gio is now
compiled before the gir files.
This commit is contained in:
Marco Trevisan (Treviño) 2023-12-20 03:46:33 +01:00
parent 385ae1b964
commit 9c4ff01feb
7 changed files with 152 additions and 134 deletions

View File

@ -1094,58 +1094,6 @@ if multiarch_bindir != get_option('bindir')
endforeach
endif
if enable_gir
gio_gir_sources = [
gio_visibility_h,
gioenumtypes_h,
gnetworking_h,
gio_headers,
gio_base_sources,
application_sources,
gdbus_sources,
appinfo_sources,
contenttype_sources,
unix_sources,
win32_sources,
settings_sources,
]
gio_gir_packages = [ 'gio-2.0' ]
gio_gir_args = [
'-DGIO_COMPILATION',
'-DG_SETTINGS_ENABLE_BACKEND',
'--symbol-prefix=gio',
]
if host_system == 'windows'
gio_gir_sources += gio_win32_include_headers
foreach h: gio_win32_include_headers
gio_gir_args += '--c-include=@0@'.format(h)
endforeach
gio_gir_packages += 'gio-win32-2.0'
gio_gir_args += '--pkg=gio-win32-2.0'
else
gio_gir_sources += gio_unix_include_headers
foreach h: gio_unix_include_headers
gio_gir_args += '--c-include=@0@'.format(h)
endforeach
gio_gir_packages += 'gio-unix-2.0'
gio_gir_args += '--pkg=gio-unix-2.0'
endif
gio_gir = gnome.generate_gir(libgio,
sources: gio_gir_sources,
namespace: 'Gio',
nsversion: '2.0',
identifier_prefix: 'G',
symbol_prefix: 'g',
export_packages: gio_gir_packages,
header: 'gio/gio.h',
includes: [ glib_gir[0], gmodule_gir[0], gobject_gir[0] ],
install: true,
dependencies: [ libglib_dep, libgobject_dep, libgmodule_dep ],
extra_args: gir_args + gio_gir_args,
)
endif
if build_tests
subdir('tests')
endif

View File

@ -82,4 +82,4 @@ foreach test_name, extra_args : girepository_tests
suite: suite,
should_fail: extra_args.get('should_fail', false),
)
endforeach
endforeach

View File

@ -35,7 +35,7 @@ test_repository_basic (void)
g_test_summary ("Test basic opening of a repository and requiring a typelib");
gobject_typelib_dir = g_test_build_filename (G_TEST_BUILT, "..", "..", "gobject", NULL);
gobject_typelib_dir = g_test_build_filename (G_TEST_BUILT, "..", "..", "introspection", NULL);
g_test_message ("Using GI_TYPELIB_DIR = %s", gobject_typelib_dir);
gi_repository_prepend_search_path (gobject_typelib_dir);
@ -70,7 +70,7 @@ test_repository_info (void)
g_test_summary ("Test retrieving some basic info blobs from a typelib");
gobject_typelib_dir = g_test_build_filename (G_TEST_BUILT, "..", "..", "gobject", NULL);
gobject_typelib_dir = g_test_build_filename (G_TEST_BUILT, "..", "..", "introspection", NULL);
g_test_message ("Using GI_TYPELIB_DIR = %s", gobject_typelib_dir);
gi_repository_prepend_search_path (gobject_typelib_dir);
g_free (gobject_typelib_dir);

View File

@ -65,6 +65,7 @@ gmoduleconf_h = configure_file(input : 'gmoduleconf.h.in',
# when it includes GLib as a subproject
gmodule_h = files('gmodule.h')
gmodule_c = files('gmodule.c')
gmodule_deprecated_c = files('gmodule-deprecated.c')
install_headers([gmodule_h], install_dir : glib_includedir)
@ -77,7 +78,7 @@ gmodule_visibility_h = custom_target(
install_tag: 'devel',
)
gmodule_sources = [gmodule_c, gmodule_visibility_h, 'gmodule-deprecated.c']
gmodule_sources = [gmodule_c, gmodule_visibility_h, gmodule_deprecated_c]
if host_system == 'windows'
gmodule_win_rc = configure_file(
@ -147,31 +148,6 @@ meson.override_dependency('gmodule-no-export-2.0', libgmodule_dep)
meson.override_dependency('gmodule-export-2.0', libgmodule_dep)
meson.override_dependency('gmodule-2.0', libgmodule_dep)
if enable_gir
gmodule_gir = gnome.generate_gir(libgmodule,
sources: [
gmoduleconf_h,
gmodule_h,
gmodule_c,
'gmodule-deprecated.c',
],
namespace: 'GModule',
nsversion: '2.0',
identifier_prefix: 'G',
symbol_prefix: 'g',
export_packages: 'gmodule-2.0',
header: 'gmodule.h',
includes: [ glib_gir[0] ],
install: true,
dependencies: libglib_dep,
extra_args: gir_args + [
'-DGMODULE_COMPILATION',
'-DGETTEXT_PACKAGE="dummy"',
'--symbol-prefix=gmodule',
],
)
endif
if build_tests
subdir('tests')
endif

View File

@ -170,59 +170,6 @@ libgobject_dep = declare_dependency(link_with : libgobject,
)
meson.override_dependency('gobject-2.0', libgobject_dep)
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: libgobject_dep,
extra_args: gir_args + [
'-DGLIB_COMPILATION',
'-DGETTEXT_PACKAGE="dummy"',
'--symbol-prefix=glib',
'--library-path=' + meson.current_build_dir(),
'--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
gobject_query = executable('gobject-query', 'gobject-query.c',
install : true,
install_tag : 'bin-devel',

144
introspection/meson.build Normal file
View File

@ -0,0 +1,144 @@
# GLib
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,
# Required to compile gdump
gmodule_visibility_h,
],
namespace: 'GLib',
nsversion: '2.0',
identifier_prefix: 'G',
symbol_prefix: 'g',
export_packages: 'glib-2.0',
header: 'glib.h',
install: true,
dependencies: [
libgobject_dep,
],
extra_args: gir_args + [
'-DGLIB_COMPILATION',
'-DGETTEXT_PACKAGE="dummy"',
'--symbol-prefix=glib',
'--library-path=' + meson.current_build_dir(),
'--library=gobject-2.0',
],
)
# GObject
gobject_gir = gnome.generate_gir(libgobject,
sources: [
gobject_visibility_h,
gobject_install_headers,
gobject_sources,
# Required to compile gdump
gmodule_visibility_h,
],
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',
],
)
# GModule
gmodule_gir = gnome.generate_gir(libgmodule,
sources: [
gmoduleconf_h,
gmodule_h,
gmodule_c,
gmodule_deprecated_c,
gmodule_visibility_h,
],
namespace: 'GModule',
nsversion: '2.0',
identifier_prefix: 'G',
symbol_prefix: 'g',
export_packages: 'gmodule-2.0',
header: 'gmodule.h',
includes: [ glib_gir[0] ],
install: true,
dependencies: [
libglib_dep,
],
extra_args: gir_args + [
'-DGMODULE_COMPILATION',
'-DGETTEXT_PACKAGE="dummy"',
'--symbol-prefix=gmodule',
],
)
# Gio
gio_gir_sources = [
gio_visibility_h,
gioenumtypes_h,
gnetworking_h,
gio_headers,
gio_base_sources,
application_sources,
gdbus_sources,
appinfo_sources,
contenttype_sources,
unix_sources,
win32_sources,
settings_sources,
# Required to compile gdump
gmodule_visibility_h,
]
gio_gir_packages = [ 'gio-2.0' ]
gio_gir_args = [
'-DGIO_COMPILATION',
'-DG_SETTINGS_ENABLE_BACKEND',
'--symbol-prefix=gio',
]
if host_system == 'windows'
gio_gir_sources += gio_win32_include_headers
foreach h: gio_win32_include_headers
gio_gir_args += '--c-include=@0@'.format(h)
endforeach
gio_gir_packages += 'gio-win32-2.0'
gio_gir_args += '--pkg=gio-win32-2.0'
else
gio_gir_sources += gio_unix_include_headers
foreach h: gio_unix_include_headers
gio_gir_args += '--c-include=@0@'.format(h)
endforeach
gio_gir_packages += 'gio-unix-2.0'
gio_gir_args += '--pkg=gio-unix-2.0'
endif
gio_gir = gnome.generate_gir(libgio,
sources: gio_gir_sources,
namespace: 'Gio',
nsversion: '2.0',
identifier_prefix: 'G',
symbol_prefix: 'g',
export_packages: gio_gir_packages,
header: 'gio/gio.h',
includes: [ glib_gir[0], gmodule_gir[0], gobject_gir[0] ],
install: true,
dependencies: [
libglib_dep,
libgobject_dep,
libgmodule_dep,
],
extra_args: gir_args + gio_gir_args,
)

View File

@ -2528,6 +2528,9 @@ subdir('gobject')
subdir('gthread')
subdir('gmodule')
subdir('gio')
if enable_gir
subdir('introspection')
endif
subdir('girepository')
subdir('fuzzing')