blob: a8206a4507012ae97d53c53a06362e21dfdfa862 [file] [log] [blame]
William A. Kennington IIIac69b482021-06-02 12:28:27 -07001From ba73bb0f3d2023839bc3b681c49b7ec1192cceb4 Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Sat, 8 May 2021 21:58:54 +0200
4Subject: [PATCH] Add use_prebuilt_tools option
5
6This allows using the gdk-pixbuf tools from the host to
7build and install tests in a cross-compile scenarion.
8
9Upstream-Status: Submitted [https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/119]
10Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
11
12---
13 gdk-pixbuf/meson.build | 11 +++++++++--
14 meson.build | 6 +++---
15 meson_options.txt | 4 ++++
16 tests/meson.build | 16 ++++++++--------
17 thumbnailer/meson.build | 24 ++++++++++++++++++------
18 5 files changed, 42 insertions(+), 19 deletions(-)
19
20diff --git a/gdk-pixbuf/meson.build b/gdk-pixbuf/meson.build
21index 8b0590b..7331491 100644
22--- a/gdk-pixbuf/meson.build
23+++ b/gdk-pixbuf/meson.build
24@@ -342,13 +342,20 @@ foreach bin: gdkpixbuf_bin
25 include_directories: [ root_inc, gdk_pixbuf_inc ],
26 c_args: common_cflags + gdk_pixbuf_cflags,
27 install: true)
28- meson.override_find_program(bin_name, bin)
29+ if not get_option('use_prebuilt_tools')
30+ meson.override_find_program(bin_name, bin)
31+ endif
32
33 # Used in tests
34 set_variable(bin_name.underscorify(), bin)
35 endforeach
36
37-if not meson.is_cross_build()
38+if get_option('use_prebuilt_tools')
39+ gdk_pixbuf_query_loaders = find_program('gdk-pixbuf-query-loaders', required: true)
40+ gdk_pixbuf_pixdata = find_program('gdk-pixbuf-pixdata', required: true)
41+endif
42+
43+if not meson.is_cross_build() or get_option('use_prebuilt_tools')
44 # The 'loaders.cache' used for testing, so we don't accidentally
45 # load the installed cache; we always build it by default
46 loaders_cache = custom_target('loaders.cache',
47diff --git a/meson.build b/meson.build
48index 7a1409b..0bc73eb 100644
49--- a/meson.build
50+++ b/meson.build
51@@ -403,16 +403,16 @@ subdir('gdk-pixbuf')
52 # i18n
53 subdir('po')
54
55-if not meson.is_cross_build()
56+if not meson.is_cross_build() or get_option('use_prebuilt_tools')
57 subdir('tests')
58- subdir('thumbnailer')
59 endif
60+subdir('thumbnailer')
61
62 # Documentation
63 build_docs = get_option('gtk_doc') or get_option('docs')
64 subdir('docs')
65
66-if not meson.is_cross_build()
67+if not meson.is_cross_build() or get_option('use_prebuilt_tools')
68 meson.add_install_script('build-aux/post-install.py',
69 gdk_pixbuf_bindir,
70 gdk_pixbuf_libdir,
71diff --git a/meson_options.txt b/meson_options.txt
72index 0ee6718..cc29855 100644
73--- a/meson_options.txt
74+++ b/meson_options.txt
75@@ -49,4 +49,8 @@ option('gio_sniffing',
76 description: 'Perform file type detection using GIO (Unused on MacOS and Windows)',
77 type: 'boolean',
78 value: true)
79+option('use_prebuilt_tools',
80+ description: 'Use prebuilt gdk-pixbuf tools from the host for cross-compilation',
81+ type: 'boolean',
82+ value: false)
83
84diff --git a/tests/meson.build b/tests/meson.build
85index 7c6cb11..1029e6a 100644
86--- a/tests/meson.build
87+++ b/tests/meson.build
88@@ -5,6 +5,12 @@
89 # $PATH. Ideally we should use gnome.compile_resources() and let Meson deal with
90 # this problem: See https://github.com/mesonbuild/meson/issues/8266.
91 if enabled_loaders.contains('png') and host_system != 'windows'
92+
93+ resources_deps = [loaders_cache,]
94+ if not get_option('use_prebuilt_tools')
95+ resources_deps += [gdk_pixbuf_pixdata,]
96+ endif
97+
98 # Resources; we cannot use gnome.compile_resources() here, because we need to
99 # override the environment in order to use the utilities we just built instead
100 # of the system ones
101@@ -21,10 +27,7 @@ if enabled_loaders.contains('png') and host_system != 'windows'
102 '@INPUT@',
103 '@OUTPUT@',
104 ],
105- depends: [
106- gdk_pixbuf_pixdata,
107- loaders_cache,
108- ],
109+ depends: resources_deps,
110 )
111
112 resources_h = custom_target('resources.h',
113@@ -40,10 +43,7 @@ if enabled_loaders.contains('png') and host_system != 'windows'
114 '@INPUT@',
115 '@OUTPUT@',
116 ],
117- depends: [
118- gdk_pixbuf_pixdata,
119- loaders_cache,
120- ],
121+ depends: resources_deps,
122 )
123 no_resources = false
124 else
125diff --git a/thumbnailer/meson.build b/thumbnailer/meson.build
126index b6a206d..9336c21 100644
127--- a/thumbnailer/meson.build
128+++ b/thumbnailer/meson.build
129@@ -6,13 +6,29 @@ bin = executable('gdk-pixbuf-thumbnailer',
130 ],
131 dependencies: gdk_pixbuf_deps + [ gdkpixbuf_dep ],
132 install: true)
133-meson.override_find_program('gdk-pixbuf-thumbnailer', bin)
134+if not get_option('use_prebuilt_tools')
135+ meson.override_find_program('gdk-pixbuf-thumbnailer', bin)
136+endif
137
138 gdk_pixbuf_print_mime_types = executable('gdk-pixbuf-print-mime-types',
139 'gdk-pixbuf-print-mime-types.c',
140+ install: true,
141 c_args: common_cflags,
142 dependencies: gdk_pixbuf_deps + [ gdkpixbuf_dep ])
143
144+if get_option('use_prebuilt_tools')
145+ gdk_pixbuf_print_mime_types = find_program('gdk-pixbuf-print-mime-types', required: true)
146+endif
147+
148+thumbnailer_deps = [loaders_cache,]
149+
150+if not get_option('use_prebuilt_tools')
151+ thumbnailer_deps += [
152+ gdk_pixbuf_print_mime_types,
153+ gdk_pixbuf_pixdata,
154+ ]
155+endif
156+
157 custom_target('thumbnailer',
158 input: 'gdk-pixbuf-thumbnailer.thumbnailer.in',
159 output: 'gdk-pixbuf-thumbnailer.thumbnailer',
160@@ -25,10 +41,6 @@ custom_target('thumbnailer',
161 '@INPUT@',
162 '@OUTPUT@',
163 ],
164- depends: [
165- gdk_pixbuf_print_mime_types,
166- gdk_pixbuf_pixdata,
167- loaders_cache,
168- ],
169+ depends: thumbnailer_deps,
170 install: true,
171 install_dir: join_paths(gdk_pixbuf_datadir, 'thumbnailers'))