[tepl/tepl-5-0-msvc: 2/2] meson: Add option to disable introspection




commit 03947bce819bccdfdaaec0d52228dfed524dc611
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Jul 14 15:10:15 2020 +0800

    meson: Add option to disable introspection
    
    There are cases where one might need or want to disable introspection builds,
    such as when performing a cross-compilation where the generated binaries could
    not be run on the build system

 meson_options.txt |  6 ++++++
 tepl/meson.build  | 42 ++++++++++++++++++++++++------------------
 2 files changed, 30 insertions(+), 18 deletions(-)
---
diff --git a/meson_options.txt b/meson_options.txt
index cad97dd..11d061d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -3,3 +3,9 @@ option(
   type: 'boolean', value: false,
   description: 'Build API reference (requires gtk-doc)'
 )
+
+option('introspection',
+       type: 'feature',
+       value: 'auto',
+       yield: true,
+       description : 'Build introspection data (requires gobject-introspection)')
diff --git a/tepl/meson.build b/tepl/meson.build
index 93ca1c5..09fd9ef 100644
--- a/tepl/meson.build
+++ b/tepl/meson.build
@@ -166,21 +166,27 @@ PKG_CONFIG.generate(tepl_lib,
   libraries: TEPL_PUBLIC_DEPS,
 )
 
-GNOME.generate_gir(
-  tepl_lib,
-  export_packages: 'tepl-@0@'.format(TEPL_API_VERSION),
-  header: 'tepl/tepl.h',
-  identifier_prefix: 'Tepl',
-  include_directories: ROOT_INCLUDE_DIR,
-  includes: ['Gtk-3.0', 'GtkSource-4', 'Amtk-5'],
-  install: true,
-  namespace: 'Tepl',
-  nsversion: TEPL_API_VERSION,
-  sources: [
-    tepl_public_headers,
-    tepl_public_c_files,
-    tepl_enum_types
-  ],
-  # Support for deps being built as subprojects:
-  dependencies: TEPL_DEPS,
-)
+# Introspection
+gir = find_program('g-ir-scanner', required : get_option('introspection'))
+build_gir = gir.found() and (not meson.is_cross_build() or get_option('introspection').enabled())
+
+if build_gir
+  GNOME.generate_gir(
+    tepl_lib,
+    export_packages: 'tepl-@0@'.format(TEPL_API_VERSION),
+    header: 'tepl/tepl.h',
+    identifier_prefix: 'Tepl',
+    include_directories: ROOT_INCLUDE_DIR,
+    includes: ['Gtk-3.0', 'GtkSource-4', 'Amtk-5'],
+    install: true,
+    namespace: 'Tepl',
+    nsversion: TEPL_API_VERSION,
+    sources: [
+      tepl_public_headers,
+      tepl_public_c_files,
+      tepl_enum_types
+    ],
+    # Support for deps being built as subprojects:
+    dependencies: TEPL_DEPS,
+  )
+endif


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