mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-28 05:02:10 +01:00
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:
parent
6e771f0e84
commit
fe32c3f5c5
@ -472,7 +472,7 @@ else
|
|||||||
install_headers(gio_win32_include_headers, subdir : 'gio-win32-2.0/gio')
|
install_headers(gio_win32_include_headers, subdir : 'gio-win32-2.0/gio')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
gio_sources = files(
|
gio_base_sources = files(
|
||||||
'gappinfo.c',
|
'gappinfo.c',
|
||||||
'gasynchelper.c',
|
'gasynchelper.c',
|
||||||
'gasyncinitable.c',
|
'gasyncinitable.c',
|
||||||
@ -603,6 +603,8 @@ gio_sources = files(
|
|||||||
'gliststore.c',
|
'gliststore.c',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
gio_sources = gio_base_sources
|
||||||
|
|
||||||
if glib_build_shared
|
if glib_build_shared
|
||||||
gio_sources += files ('../glib/gtrace.c')
|
gio_sources += files ('../glib/gtrace.c')
|
||||||
endif
|
endif
|
||||||
@ -1101,6 +1103,58 @@ if multiarch_bindir != get_option('bindir')
|
|||||||
endforeach
|
endforeach
|
||||||
endif
|
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
|
if build_tests
|
||||||
subdir('tests')
|
subdir('tests')
|
||||||
endif
|
endif
|
||||||
|
@ -253,7 +253,7 @@ glib_sub_headers = files(
|
|||||||
|
|
||||||
install_headers(glib_sub_headers, install_dir : glib_sub_includedir)
|
install_headers(glib_sub_headers, install_dir : glib_sub_includedir)
|
||||||
|
|
||||||
deprecated_sources = files(
|
glib_deprecated_sources = files(
|
||||||
'deprecated/gallocator.c',
|
'deprecated/gallocator.c',
|
||||||
'deprecated/gcache.c',
|
'deprecated/gcache.c',
|
||||||
'deprecated/gcompletion.c',
|
'deprecated/gcompletion.c',
|
||||||
@ -407,7 +407,7 @@ endif
|
|||||||
glib_c_args = ['-DG_LOG_DOMAIN="GLib"'] + glib_c_args_internal + pcre2_static_args
|
glib_c_args = ['-DG_LOG_DOMAIN="GLib"'] + glib_c_args_internal + pcre2_static_args
|
||||||
libglib = library('glib-2.0',
|
libglib = library('glib-2.0',
|
||||||
glib_dtrace_obj, glib_dtrace_hdr,
|
glib_dtrace_obj, glib_dtrace_hdr,
|
||||||
sources : [deprecated_sources, glib_sources],
|
sources : [glib_deprecated_sources, glib_sources],
|
||||||
version : library_version,
|
version : library_version,
|
||||||
soversion : soversion,
|
soversion : soversion,
|
||||||
darwin_versions : darwin_versions,
|
darwin_versions : darwin_versions,
|
||||||
|
@ -147,6 +147,31 @@ meson.override_dependency('gmodule-no-export-2.0', libgmodule_dep)
|
|||||||
meson.override_dependency('gmodule-export-2.0', libgmodule_dep)
|
meson.override_dependency('gmodule-export-2.0', libgmodule_dep)
|
||||||
meson.override_dependency('gmodule-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
|
if build_tests
|
||||||
subdir('tests')
|
subdir('tests')
|
||||||
endif
|
endif
|
||||||
|
@ -163,6 +163,58 @@ pkg.generate(libgobject,
|
|||||||
description : 'GLib Type, Object, Parameter and Signal Library',
|
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,
|
libgobject_dep = declare_dependency(link_with : libgobject,
|
||||||
include_directories : [gobjectinc],
|
include_directories : [gobjectinc],
|
||||||
sources : [gobject_visibility_h, glib_enumtypes_h],
|
sources : [gobject_visibility_h, glib_enumtypes_h],
|
||||||
|
15
meson.build
15
meson.build
@ -2456,8 +2456,22 @@ if want_systemtap and enable_dtrace
|
|||||||
enable_systemtap = true
|
enable_systemtap = true
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# introspection
|
||||||
|
gir_scanner = find_program('g-ir-scanner', required: get_option('introspection'))
|
||||||
|
enable_gir = get_option('introspection').allowed() and gir_scanner.found() and meson.can_run_host_binaries()
|
||||||
|
|
||||||
|
if get_option('introspection').enabled() and not meson.can_run_host_binaries()
|
||||||
|
error('Running binaries on the build host needs to be supported to build with -Dintrospection=enabled')
|
||||||
|
endif
|
||||||
|
|
||||||
|
gir_args = [
|
||||||
|
'--quiet',
|
||||||
|
]
|
||||||
|
|
||||||
pkg = import('pkgconfig')
|
pkg = import('pkgconfig')
|
||||||
windows = import('windows')
|
windows = import('windows')
|
||||||
|
gnome = import('gnome')
|
||||||
|
|
||||||
subdir('tools')
|
subdir('tools')
|
||||||
subdir('glib')
|
subdir('glib')
|
||||||
subdir('gobject')
|
subdir('gobject')
|
||||||
@ -2579,4 +2593,5 @@ summary({
|
|||||||
'glib_checks' : get_option('glib_checks'),
|
'glib_checks' : get_option('glib_checks'),
|
||||||
'libelf' : get_option('libelf'),
|
'libelf' : get_option('libelf'),
|
||||||
'multiarch' : get_option('multiarch'),
|
'multiarch' : get_option('multiarch'),
|
||||||
|
'introspection' : enable_gir,
|
||||||
}, section: 'Options')
|
}, section: 'Options')
|
||||||
|
@ -125,3 +125,8 @@ option('multiarch',
|
|||||||
type : 'boolean',
|
type : 'boolean',
|
||||||
value : false,
|
value : false,
|
||||||
description : 'Install some helper executables in per-architecture locations')
|
description : 'Install some helper executables in per-architecture locations')
|
||||||
|
|
||||||
|
option('introspection',
|
||||||
|
type: 'feature',
|
||||||
|
value: 'auto',
|
||||||
|
description: 'Enable generating introspection data (requires gobject-introspection)')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user