[polari/wip/fmuellner/meson: 2/4] build: Add back typelib checks
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/meson: 2/4] build: Add back typelib checks
- Date: Sun, 5 Mar 2017 01:31:14 +0000 (UTC)
commit 87f2ebdf6a178203b2ffb466b4680643eb8ac07f
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Oct 18 01:51:22 2016 +0200
build: Add back typelib checks
The AX_CHECK_GIR* macros are a nice way to catch runtime bugs that
are triggered by users not updating dependencies. Unfortunately
the meson developers rejected this functionality for their build
system, so we have to implement the checks ourselves to not lose
the feature.
This is still somewhat inferior to the autoconf macros as it uses
meson's built-in testing ability, which is only executed when
explicitly requested by the user; still, getting into the habit
of asking users to run the tests when debugging their issues should
be a workable compromise ...
https://bugzilla.gnome.org/show_bug.cgi?id=779599
build-aux/meson/check-gir.js | 46 ++++++++++++++++++++++++++++++++++++++++++
meson.build | 29 ++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/build-aux/meson/check-gir.js b/build-aux/meson/check-gir.js
new file mode 100644
index 0000000..03ea778
--- /dev/null
+++ b/build-aux/meson/check-gir.js
@@ -0,0 +1,46 @@
+let Lib = null;
+
+function checkSymbols(symbols) {
+ try {
+ symbols.reduce((prev, cur) => {
+ if (typeof prev[cur] === 'undefined')
+ throw 1;
+ return prev[cur];
+ }, Lib);
+ return true;
+ } catch(e) {
+ if (e === 1)
+ return false;
+ throw e;
+ }
+}
+
+function main(args) {
+ if (args.length < 2) {
+ log('Usave: check-girs.js [NAME] [VERSION] <SYMBOL>');
+ return 1;
+ }
+
+ let [lib, version, symbol] = args;
+ imports.gi.versions[lib] = version;
+
+ try {
+ Lib = imports.gi[lib];
+ } catch(e) {
+ return 1;
+ }
+
+ if (symbol) {
+ let symbolList = symbol.split('.');
+ if (!checkSymbols(symbolList)) {
+ // For methods, we need to check the class' prototype
+ symbolList.splice(-1, 0, 'prototype');
+ if (!checkSymbols(symbolList))
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+main(ARGV)
diff --git a/meson.build b/meson.build
index 9960923..e5dc5e1 100644
--- a/meson.build
+++ b/meson.build
@@ -54,3 +54,32 @@ subdir('help')
if (not is_variable('DESTDIR'))
meson.add_install_script(join_paths(src_auxdir, 'meson-postinstall.sh'))
endif
+
+if (get_option('buildtype').startswith('debug'))
+ girs = [['GdkPixbuf', '2.0'],
+ ['Gio', '2.0', 'Application.send_notification'],
+ ['GLib', '2.0', 'log_variant'],
+ ['GObject', '2.0'],
+ ['Gspell', '1', 'Entry'],
+ ['Gtk', '3.0'],
+ ['Gtk', '3.0', 'ScrolledWindow.set_propagate_natural_width'],
+ ['Pango', '1.0'],
+ ['PangoCairo', '1.0'],
+ ['Secret', '1'],
+ ['Soup', '2.4'],
+ ['TelepathyGLib', '0.12'],
+ ['TelepathyLogger', '0.2']]
+
+ foreach g : girs
+ gir_name = '@0@-@1@'.format(g[0], g[1])
+ if (g.length() == 3)
+ msg = 'Checking for @0@ in @1@'.format(g[2], gir_name)
+ else
+ msg = 'Checking for @0@'.format(gir_name)
+ endif
+
+ test (msg,
+ gjs_console,
+ args: [join_paths(src_auxdir, 'check-gir.js')] + g)
+ endforeach
+endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]