blob: 7250fa3f623b84fb0f3ec0594c061f2731684df5 [file] [log] [blame]
Patrick Williamsb9af8752023-01-30 13:28:01 -06001From 9d3b374e75692da3d1d05344a1693c85a3098f47 Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex@linutronix.de>
3Date: Thu, 26 Jan 2023 20:29:46 +0100
4Subject: [PATCH] meson.build: allow (a subset of) tests in cross compile
5 settings
6
7There is no need to completely disable tests: most of them
8do not require running target executables at build time,
9and so can be built and installed.
10
11This requires inserting a couple of specific guards around
12items that do require running target executables.
13
14Upstream-Status: Submitted [https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/150]
15Signed-off-by: Alexander Kanavin <alex@linutronix.de>
16---
17 meson.build | 6 +++---
18 tests/meson.build | 10 ++++++----
19 2 files changed, 9 insertions(+), 7 deletions(-)
20
21diff --git a/meson.build b/meson.build
22index 8a16c8f..7c8b20f 100644
23--- a/meson.build
24+++ b/meson.build
25@@ -369,10 +369,10 @@ subdir('gdk-pixbuf')
26 # i18n
27 subdir('po')
28
29+if get_option('tests')
30+ subdir('tests')
31+endif
32 if not meson.is_cross_build()
33- if get_option('tests')
34- subdir('tests')
35- endif
36 subdir('thumbnailer')
37 endif
38
39diff --git a/tests/meson.build b/tests/meson.build
40index 28c2525..c45e765 100644
41--- a/tests/meson.build
42+++ b/tests/meson.build
43@@ -4,7 +4,7 @@
44 # gdk-pixbuf-pixdata from build directory because it needs all DLL locations in
45 # $PATH. Ideally we should use gnome.compile_resources() and let Meson deal with
46 # this problem: See https://github.com/mesonbuild/meson/issues/8266.
47-if enabled_loaders.contains('png') and host_system != 'windows'
48+if enabled_loaders.contains('png') and host_system != 'windows' and not meson.is_cross_build()
49 # Resources; we cannot use gnome.compile_resources() here, because we need to
50 # override the environment in order to use the utilities we just built instead
51 # of the system ones
52@@ -166,9 +166,11 @@ endif
53 test_deps = gdk_pixbuf_deps + [ gdkpixbuf_dep, ]
54 test_args = [ '-k' ]
55 test_env = environment()
56-test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
57-test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
58-test_env.set('GDK_PIXBUF_MODULE_FILE', loaders_cache.full_path())
59+if not meson.is_cross_build()
60+ test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
61+ test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
62+ test_env.set('GDK_PIXBUF_MODULE_FILE', loaders_cache.full_path())
63+endif
64
65 foreach test_name, test_data: installed_tests
66 test_sources = [ test_name + '.c', 'test-common.c' ]