diff --git a/gio/meson.build b/gio/meson.build index f9fdf6ead..f8bcc4864 100644 --- a/gio/meson.build +++ b/gio/meson.build @@ -472,7 +472,7 @@ else install_headers(gio_win32_include_headers, subdir : 'gio-win32-2.0/gio') endif -gio_sources = files( +gio_base_sources = files( 'gappinfo.c', 'gasynchelper.c', 'gasyncinitable.c', @@ -603,6 +603,8 @@ gio_sources = files( 'gliststore.c', ) +gio_sources = gio_base_sources + if glib_build_shared gio_sources += files ('../glib/gtrace.c') endif @@ -1101,6 +1103,58 @@ 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 diff --git a/glib/meson.build b/glib/meson.build index c26a35e42..12fb12ff2 100644 --- a/glib/meson.build +++ b/glib/meson.build @@ -253,7 +253,7 @@ glib_sub_headers = files( install_headers(glib_sub_headers, install_dir : glib_sub_includedir) -deprecated_sources = files( +glib_deprecated_sources = files( 'deprecated/gallocator.c', 'deprecated/gcache.c', 'deprecated/gcompletion.c', @@ -407,7 +407,7 @@ endif glib_c_args = ['-DG_LOG_DOMAIN="GLib"'] + glib_c_args_internal + pcre2_static_args libglib = library('glib-2.0', glib_dtrace_obj, glib_dtrace_hdr, - sources : [deprecated_sources, glib_sources], + sources : [glib_deprecated_sources, glib_sources], version : library_version, soversion : soversion, darwin_versions : darwin_versions, diff --git a/gmodule/meson.build b/gmodule/meson.build index da4d06cfb..0d1ff9522 100644 --- a/gmodule/meson.build +++ b/gmodule/meson.build @@ -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-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 diff --git a/gobject/meson.build b/gobject/meson.build index 2129aaf8a..b7b693890 100644 --- a/gobject/meson.build +++ b/gobject/meson.build @@ -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], diff --git a/meson.build b/meson.build index 6084471f8..d788cdfe1 100644 --- a/meson.build +++ b/meson.build @@ -2456,8 +2456,22 @@ if want_systemtap and enable_dtrace enable_systemtap = true 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') windows = import('windows') +gnome = import('gnome') + subdir('tools') subdir('glib') subdir('gobject') @@ -2579,4 +2593,5 @@ summary({ 'glib_checks' : get_option('glib_checks'), 'libelf' : get_option('libelf'), 'multiarch' : get_option('multiarch'), + 'introspection' : enable_gir, }, section: 'Options') diff --git a/meson_options.txt b/meson_options.txt index 517d5757c..c2c9e3427 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -125,3 +125,8 @@ option('multiarch', type : 'boolean', value : false, description : 'Install some helper executables in per-architecture locations') + +option('introspection', + type: 'feature', + value: 'auto', + description: 'Enable generating introspection data (requires gobject-introspection)')