[ghex: 1/2] build: Added option to generate vapi




commit 412cba3b06f90ada4e3c1f5bdc79dcf5864fc94d
Author: JCWasmx86 <JCWasmx86 t-online de>
Date:   Fri Jul 15 08:30:56 2022 +0200

    build: Added option to generate vapi

 meson.build       |  7 +++++++
 meson_options.txt |  1 +
 src/meson.build   | 17 ++++++++++++++++-
 3 files changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index 0d9c452..fb2b2de 100644
--- a/meson.build
+++ b/meson.build
@@ -20,7 +20,14 @@ mmap_backend = get_option('mmap-buffer-backend')
 direct_backend = get_option('direct-buffer-backend')
 
 gir = find_program('g-ir-scanner', required : get_option('introspection'))
+vapigen = find_program('vapigen', required : get_option('vapi'))
 generate_gir = gir.found() and (not meson.is_cross_build() or get_option('introspection').enabled())
+
+if get_option('vapi')
+  assert (generate_gir, 'vapi requires GObject Introspection. Use -Dvapi=false to disable it')
+endif
+
+generate_vapi = generate_gir and vapigen.found() and get_option('vapi')
 build_gtk_doc = get_option('gtk_doc')
 
 # Directories, variables, etc.
diff --git a/meson_options.txt b/meson_options.txt
index e7276c6..3489d5d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -8,3 +8,4 @@ option('direct-buffer-backend', type : 'boolean', value: true, description: 'Bui
 option('introspection', type: 'feature', value: 'auto', description: 'Generate gir data (requires 
gobject-introspection)')
 option('gtk_doc', type: 'boolean', value: false, description: 'Build reference manual (requires gtk-doc)')
 option('static-html-help', type: 'boolean', value: false, description: 'Install static HTML help files (for 
systems without Yelp)')
+option('vapi', type: 'boolean', value: false, description: 'Generate VAPI files for Vala')
diff --git a/src/meson.build b/src/meson.build
index e0dd420..4d3e08b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -72,8 +72,9 @@ res = gnome.compile_resources(
   dependencies: app_ui
 )
 
+library_name = 'gtkhex-@0@'.format(libgtkhex_api_version)
 libgtkhex = library(
-  'gtkhex-@0@'.format(libgtkhex_api_version),
+  library_name,
   libgtkhex_sources + lib_res,
   version: '@0@.@1@.@2@'.format(
     libgtkhex_version_major, libgtkhex_version_minor, libgtkhex_version_micro),
@@ -164,4 +165,18 @@ if generate_gir
   install_dir_typelib: ghex_typelibdir,
            extra_args: [ '--warn-all' ],
   )
+
+  if generate_vapi
+    vapi_deps = [
+      'gmodule-2.0',
+      'glib-2.0',
+      'gio-2.0',
+      'gtk4',
+    ]
+    gnome.generate_vapi(library_name,
+                        install  : true,
+                        packages : vapi_deps,
+                        sources  : gtkhex_gir [0],
+    )
+  endif
 endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]