[amtk/gi.conditional] meson: Build introspection conditionally




commit 3180e07a0d39abdfe42e64d9c622eef937b31828
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Jan 8 11:17:45 2021 +0800

    meson: Build introspection conditionally
    
    There are occasions where one may not wish to build the introspection data, or
    is unable to do so, such as during a cross-compilation scenario.
    
    This adds a configure time option to disable building introspection data and
    improves the check for G-I to make it optional depending on whether we really
    want to build the introspection data, and to just disable building the
    introspection during a cross-build scenario, like what GTK does.

 amtk/meson.build  | 42 ++++++++++++++++++++++++------------------
 meson_options.txt |  6 ++++++
 2 files changed, 30 insertions(+), 18 deletions(-)
---
diff --git a/amtk/meson.build b/amtk/meson.build
index d0471a9..a3fab09 100644
--- a/amtk/meson.build
+++ b/amtk/meson.build
@@ -103,21 +103,27 @@ PKG_CONFIG.generate(amtk_lib,
   libraries: AMTK_DEPS,
 )
 
-GNOME.generate_gir(
-  amtk_lib,
-  export_packages: 'amtk-@0@'.format(AMTK_API_VERSION),
-  header: 'amtk/amtk.h',
-  identifier_prefix: 'Amtk',
-  include_directories: ROOT_INCLUDE_DIR,
-  includes: ['Gtk-3.0'],
-  install: true,
-  namespace: 'Amtk',
-  nsversion: AMTK_API_VERSION,
-  sources: [
-    amtk_public_headers,
-    amtk_public_c_files,
-    amtk_enum_types
-  ],
-  # Support for deps being built as subprojects:
-  dependencies: AMTK_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(
+    amtk_lib,
+    export_packages: 'amtk-@0@'.format(AMTK_API_VERSION),
+    header: 'amtk/amtk.h',
+    identifier_prefix: 'Amtk',
+    include_directories: ROOT_INCLUDE_DIR,
+    includes: ['Gtk-3.0'],
+    install: true,
+    namespace: 'Amtk',
+    nsversion: AMTK_API_VERSION,
+    sources: [
+      amtk_public_headers,
+      amtk_public_c_files,
+      amtk_enum_types
+    ],
+    # Support for deps being built as subprojects:
+    dependencies: AMTK_DEPS,
+  )
+endif
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)')


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