summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2021-10-12 12:44:19 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2021-10-13 13:01:56 +0100
commitf9736304c73282ccf1f5c3d8e6d1443fc3189799 (patch)
tree902d1c308bb58ab7bec963355a42c30893b5c66b
parentd9c3da480af59a51fec94524d21991f8fee39bb9 (diff)
downloadlibgweather-f9736304c73282ccf1f5c3d8e6d1443fc3189799.tar.gz
build: Add option to disable introspection
When building libgweather as a subproject or as a Flatpak module we may want to disable generating the introspection data if we know we're only ever going to consume the C API. Disabling introspection will disable the documentation and the VAPI file generation as a side effect.
-rw-r--r--doc/meson.build2
-rw-r--r--libgweather/meson.build53
-rw-r--r--meson.build10
-rw-r--r--meson_options.txt2
4 files changed, 39 insertions, 28 deletions
diff --git a/doc/meson.build b/doc/meson.build
index 6a98ba8..7e18715 100644
--- a/doc/meson.build
+++ b/doc/meson.build
@@ -1,4 +1,4 @@
-if get_option('gtk_doc')
+if get_option('gtk_doc') and get_option('introspection')
dependency('gi-docgen', version: '>= 2021.6',
fallback: ['gi-docgen', 'dummy_dep'],
)
diff --git a/libgweather/meson.build b/libgweather/meson.build
index 6851867..a534bfd 100644
--- a/libgweather/meson.build
+++ b/libgweather/meson.build
@@ -176,24 +176,39 @@ lib_libgweather = shared_library('gweather-3',
install: true,
)
-gweather_gir = gnome.generate_gir(lib_libgweather,
- sources: introspection_sources,
- dependencies: deps_libgweather,
- nsversion: '3.0',
- namespace: 'GWeather',
- includes: ['GObject-2.0', 'Gtk-3.0'],
- symbol_prefix: 'gweather',
- identifier_prefix: 'GWeather',
- export_packages: 'gweather-3.0',
- header: 'libgweather/gweather.h',
- extra_args: [
- '--warn-all',
- '--quiet',
- '-DGWEATHER_COMPILATION',
- ],
- fatal_warnings: get_option('werror'),
- install: true,
-)
+g_ir_scanner = find_program('g-ir-scanner', required: get_option('introspection'))
+build_gir = get_option('introspection') and g_ir_scanner.found() and not meson.is_cross_build()
+
+enable_vala = get_option('enable_vala')
+vapigen = find_program('vapigen', required: enable_vala == 'true')
+if enable_vala == 'auto' or enable_vala == 'true'
+ build_vapi = vapigen.found() and get_option('introspection')
+else
+ build_vapi = false
+endif
+
+if build_gir
+ gweather_gir = gnome.generate_gir(lib_libgweather,
+ sources: introspection_sources,
+ dependencies: deps_libgweather,
+ nsversion: '3.0',
+ namespace: 'GWeather',
+ includes: ['GObject-2.0', 'Gtk-3.0'],
+ symbol_prefix: 'gweather',
+ identifier_prefix: 'GWeather',
+ export_packages: 'gweather-3.0',
+ header: 'libgweather/gweather.h',
+ extra_args: [
+ '--warn-all',
+ '--quiet',
+ '-DGWEATHER_COMPILATION',
+ ],
+ fatal_warnings: get_option('werror'),
+ install: true,
+ )
+else
+ gweather_gir = []
+endif
libgweather_dep = declare_dependency(
sources: [gweather_enum_types[1], gweather_gir],
@@ -204,7 +219,7 @@ libgweather_dep = declare_dependency(
],
)
-if enable_vala
+if build_vapi and build_gir
gnome.generate_vapi('gweather-3.0',
sources: gweather_gir[0],
packages: ['gobject-2.0', 'gtk+-3.0'],
diff --git a/meson.build b/meson.build
index eca7b9d..136dcdc 100644
--- a/meson.build
+++ b/meson.build
@@ -65,13 +65,6 @@ else
endif
endif
-enable_vala = get_option('enable_vala')
-if enable_vala == 'auto'
- enable_vala = find_program('vapigen', required: false).found()
-else
- enable_vala = enable_vala != 'false'
-endif
-
gen_locations_variant = find_program('build-aux/meson/gen_locations_variant.py')
subdir('data')
@@ -114,7 +107,8 @@ summary({
'Debug': get_option('debug'),
'Optimization': get_option('optimization'),
'Glade catalog': enable_glade_catalog,
- 'Generate VAPI': enable_vala,
+ 'Introspection': build_gir,
+ 'Generate VAPI': build_vapi,
'API reference': get_option('gtk_doc'),
},
section: 'Build',
diff --git a/meson_options.txt b/meson_options.txt
index 19b2c6a..5385be0 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -8,3 +8,5 @@ option('enable_vala', type: 'combo', choices : ['true', 'false', 'auto'], value
description: 'Install vala bindings')
option('gtk_doc', type: 'boolean', value: false,
description: 'Whether to generate the API reference')
+option('introspection', type: 'boolean', value: true,
+ description: 'Whether to generate introspection data')