meson: add support for gobject-introspection
authorMike Gorse <mgorse@linux-e5s4.suse>
Tue, 8 Aug 2017 00:01:18 +0000 (19:01 -0500)
committerMike Gorse <mgorse@linux-e5s4.suse>
Tue, 8 Aug 2017 00:01:18 +0000 (19:01 -0500)
Not 100% sure that this is done. The shared-library line seems wrong.

atspi/meson.build
meson.build
meson_options.txt

index 8b48093..aa1a0a9 100644 (file)
@@ -76,3 +76,37 @@ atspi_dep = declare_dependency(link_with: atspi,
                                sources: atspi_enum_h,
                                include_directories: root_inc,
                                dependencies: [ libdbus_dep, gobject_dep, ])
+
+if have_gir
+  gir_sources = atspi_sources + atspi_enums + atspi_headers
+
+  gir_incs = [
+    'DBus-1.0',
+    'GLib-2.0',
+    'GObject-2.0'
+  ]
+
+  gir_extra_args = [
+    '--c-include=atspi/atspi.h',
+    '--pkg-export=atspi-2'
+  ]
+
+  gir_dir = join_paths(atspi_datadir, 'gir-1.0')
+  typelib_dir = join_paths(get_option('libdir'), 'girepository-1.0')
+
+  libatspi_gir = gnome.generate_gir(
+    atspi,
+    sources: gir_sources,
+    nsversion: '2.0',
+    namespace: atspi_gir_ns,
+    symbol_prefix: atspi_gir_ns.to_lower(),
+    identifier_prefix: atspi_gir_ns,
+    includes: gir_incs,
+    include_directories: root_inc,
+    install: true,
+    install_dir_gir: gir_dir,
+    install_dir_typelib: typelib_dir,
+    extra_args: gir_extra_args
+  )
+endif
+
index 81abd73..1a94a7f 100644 (file)
@@ -10,6 +10,8 @@ project('at-spi2-core', 'c',
 
 add_project_arguments([ '-D_POSIX_C_SOURCE', '-D_DEFAULT_SOURCE' ], language: 'c')
 
+atspi_gir_ns = 'Atspi'
+
 cc = meson.get_compiler('c')
 host_system = host_machine.system()
 
@@ -86,6 +88,18 @@ endforeach
 at_spi_conf.set('ALIGNOF_DBIND_POINTER', cc.alignment('dbind_pointer', prefix: 'typedef void *dbind_pointer;'))
 at_spi_conf.set('ALIGNOF_DBIND_STRUCT', cc.alignment('dbind_struct', prefix: 'typedef struct { char s1; } dbind_struct;'))
 
+# introspection support
+have_gir = false
+
+introspection_option = get_option('enable-introspection')
+if introspection_option != 'no'
+  gir_dep = dependency('gobject-introspection-1.0', version: '>= 0.6.7', required: false)
+
+  if gir_dep.found()
+    have_gir = true
+  endif
+endif
+
 configure_file(output: 'config.h', configuration: at_spi_conf)
 
 # Compat variables for pkgconfig
index e26c303..305fc8c 100644 (file)
@@ -14,3 +14,5 @@ option('enable_docs',
        description: 'Generate API reference for atspi (requires GTK-Doc)',
        type: 'boolean',
        value: false)
+
+option('enable-introspection', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto', description: 'Enable GObject Introspection (depends on GObject)')