blob: 02cc9a2a7046806a5729b6d12300187e2d23af94 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From f81b60ebcbbfd9548c8aa1e388662c429068d1e3 Mon Sep 17 00:00:00 2001
William A. Kennington IIIac69b482021-06-02 12:28:27 -07002From: 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
Patrick Williams92b42cb2022-09-03 06:53:57 -050021index 54ff9dd..2e321cf 100644
William A. Kennington IIIac69b482021-06-02 12:28:27 -070022--- 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
Patrick Williams92b42cb2022-09-03 06:53:57 -050048index 813bd43..a93e6f7 100644
William A. Kennington IIIac69b482021-06-02 12:28:27 -070049--- a/meson.build
50+++ b/meson.build
Patrick Williams92b42cb2022-09-03 06:53:57 -050051@@ -369,18 +369,18 @@ subdir('gdk-pixbuf')
William A. Kennington IIIac69b482021-06-02 12:28:27 -070052 # 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')
Patrick Williams92b42cb2022-09-03 06:53:57 -050057 if get_option('tests')
58 subdir('tests')
59 endif
William A. Kennington IIIac69b482021-06-02 12:28:27 -070060- subdir('thumbnailer')
61 endif
62+subdir('thumbnailer')
63
64 # Documentation
65 build_docs = get_option('gtk_doc') or get_option('docs')
66 subdir('docs')
67
68-if not meson.is_cross_build()
69+if not meson.is_cross_build() or get_option('use_prebuilt_tools')
70 meson.add_install_script('build-aux/post-install.py',
71 gdk_pixbuf_bindir,
72 gdk_pixbuf_libdir,
73diff --git a/meson_options.txt b/meson_options.txt
Patrick Williams92b42cb2022-09-03 06:53:57 -050074index d198d99..1c899e9 100644
William A. Kennington IIIac69b482021-06-02 12:28:27 -070075--- a/meson_options.txt
76+++ b/meson_options.txt
Patrick Williams92b42cb2022-09-03 06:53:57 -050077@@ -53,4 +53,8 @@ option('gio_sniffing',
William A. Kennington IIIac69b482021-06-02 12:28:27 -070078 description: 'Perform file type detection using GIO (Unused on MacOS and Windows)',
79 type: 'boolean',
80 value: true)
81+option('use_prebuilt_tools',
82+ description: 'Use prebuilt gdk-pixbuf tools from the host for cross-compilation',
83+ type: 'boolean',
84+ value: false)
85
86diff --git a/tests/meson.build b/tests/meson.build
Patrick Williams92b42cb2022-09-03 06:53:57 -050087index 28c2525..d97c02d 100644
William A. Kennington IIIac69b482021-06-02 12:28:27 -070088--- a/tests/meson.build
89+++ b/tests/meson.build
90@@ -5,6 +5,12 @@
91 # $PATH. Ideally we should use gnome.compile_resources() and let Meson deal with
92 # this problem: See https://github.com/mesonbuild/meson/issues/8266.
93 if enabled_loaders.contains('png') and host_system != 'windows'
94+
95+ resources_deps = [loaders_cache,]
96+ if not get_option('use_prebuilt_tools')
97+ resources_deps += [gdk_pixbuf_pixdata,]
98+ endif
99+
100 # Resources; we cannot use gnome.compile_resources() here, because we need to
101 # override the environment in order to use the utilities we just built instead
102 # of the system ones
103@@ -21,10 +27,7 @@ if enabled_loaders.contains('png') and host_system != 'windows'
104 '@INPUT@',
105 '@OUTPUT@',
106 ],
107- depends: [
108- gdk_pixbuf_pixdata,
109- loaders_cache,
110- ],
111+ depends: resources_deps,
112 )
113
114 resources_h = custom_target('resources.h',
115@@ -40,10 +43,7 @@ if enabled_loaders.contains('png') and host_system != 'windows'
116 '@INPUT@',
117 '@OUTPUT@',
118 ],
119- depends: [
120- gdk_pixbuf_pixdata,
121- loaders_cache,
122- ],
123+ depends: resources_deps,
124 )
125 no_resources = false
126 else
127diff --git a/thumbnailer/meson.build b/thumbnailer/meson.build
128index b6a206d..9336c21 100644
129--- a/thumbnailer/meson.build
130+++ b/thumbnailer/meson.build
131@@ -6,13 +6,29 @@ bin = executable('gdk-pixbuf-thumbnailer',
132 ],
133 dependencies: gdk_pixbuf_deps + [ gdkpixbuf_dep ],
134 install: true)
135-meson.override_find_program('gdk-pixbuf-thumbnailer', bin)
136+if not get_option('use_prebuilt_tools')
137+ meson.override_find_program('gdk-pixbuf-thumbnailer', bin)
138+endif
139
140 gdk_pixbuf_print_mime_types = executable('gdk-pixbuf-print-mime-types',
141 'gdk-pixbuf-print-mime-types.c',
142+ install: true,
143 c_args: common_cflags,
144 dependencies: gdk_pixbuf_deps + [ gdkpixbuf_dep ])
145
146+if get_option('use_prebuilt_tools')
147+ gdk_pixbuf_print_mime_types = find_program('gdk-pixbuf-print-mime-types', required: true)
148+endif
149+
150+thumbnailer_deps = [loaders_cache,]
151+
152+if not get_option('use_prebuilt_tools')
153+ thumbnailer_deps += [
154+ gdk_pixbuf_print_mime_types,
155+ gdk_pixbuf_pixdata,
156+ ]
157+endif
158+
159 custom_target('thumbnailer',
160 input: 'gdk-pixbuf-thumbnailer.thumbnailer.in',
161 output: 'gdk-pixbuf-thumbnailer.thumbnailer',
162@@ -25,10 +41,6 @@ custom_target('thumbnailer',
163 '@INPUT@',
164 '@OUTPUT@',
165 ],
166- depends: [
167- gdk_pixbuf_print_mime_types,
168- gdk_pixbuf_pixdata,
169- loaders_cache,
170- ],
171+ depends: thumbnailer_deps,
172 install: true,
173 install_dir: join_paths(gdk_pixbuf_datadir, 'thumbnailers'))