From 2d1b65bd1272ad63b7fbd4babd9a8e8c296d15b5 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Fri, 22 Feb 2019 13:22:06 +0100
Subject: [PATCH] (target only) Work-around thumbnailer and pixdata
 cross-compile failure

Use native gdk-pixbuf-print-mime-types and gdk-pixbuf-pixdata
when generating the thumbnail metadata and resources.

This works but the mime types will come from native
loader.cache (which will only contain in-tree loaders), not from the
target loader.cache.

The upstream issue is https://bugzilla.gnome.org/show_bug.cgi?id=779057

Upstream-Status: Inappropriate [workaround]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>

---
 build-aux/gen-thumbnailer.py |  2 --
 tests/meson.build            | 11 +++++++++--
 thumbnailer/meson.build      |  5 +----
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/build-aux/gen-thumbnailer.py b/build-aux/gen-thumbnailer.py
index 05ac821..c5b99ab 100644
--- a/build-aux/gen-thumbnailer.py
+++ b/build-aux/gen-thumbnailer.py
@@ -20,8 +20,6 @@ argparser.add_argument('output', help='Output file')
 args = argparser.parse_args()
 
 newenv = os.environ.copy()
-newenv['GDK_PIXBUF_PIXDATA'] = args.pixdata
-newenv['GDK_PIXBUF_MODULE_FILE'] = args.loaders
 # 'nt': NT-based Windows, see https://docs.python.org/3/library/os.html
 if os.name == 'nt':
     gdk_pixbuf_dll_buildpath = os.path.dirname(args.pixdata)
diff --git a/tests/meson.build b/tests/meson.build
index 8ed7cc1..e011b77 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,12 +1,19 @@
 # Resources; we cannot use gnome.compile_resources() here, because we need to
 # override the environment in order to use the utilities we just built instead
 # of the system ones
+
+if not meson.is_cross_build()
+pixdata_binary = gdk_pixbuf_pixdata.full_path()
+else
+pixdata_binary = 'gdk-pixbuf-pixdata'
+endif
+
 resources_c = custom_target('resources.c',
   input: 'resources.gresource.xml',
   output: 'resources.c',
   command: [
     gen_resources,
-    '--pixdata=@0@'.format(gdk_pixbuf_pixdata.full_path()),
+    '--pixdata=@0@'.format(pixdata_binary),
     '--loaders=@0@'.format(loaders_cache.full_path()),
     '--sourcedir=@0@'.format(meson.current_source_dir()),
     '--source',
@@ -24,7 +31,7 @@ resources_h = custom_target('resources.h',
   output: 'resources.h',
   command: [
     gen_resources,
-    '--pixdata=@0@'.format(gdk_pixbuf_pixdata.full_path()),
+    '--pixdata=@0@'.format(pixdata_binary),
     '--loaders=@0@'.format(loaders_cache.full_path()),
     '--sourcedir=@0@'.format(meson.current_source_dir()),
     '--header',
diff --git a/thumbnailer/meson.build b/thumbnailer/meson.build
index aaafec8..71bd61b 100644
--- a/thumbnailer/meson.build
+++ b/thumbnailer/meson.build
@@ -18,9 +18,7 @@ custom_target('thumbnailer',
               output: 'gdk-pixbuf-thumbnailer.thumbnailer',
               command: [
                 gen_thumbnailer,
-                '--printer=@0@'.format(gdk_pixbuf_print_mime_types.full_path()),
-                '--pixdata=@0@'.format(gdk_pixbuf_pixdata.full_path()),
-                '--loaders=@0@'.format(loaders_cache.full_path()),
+                '--printer=gdk-pixbuf-print-mime-types',
                 '--bindir=@0@'.format(gdk_pixbuf_bindir),
                 '@INPUT@',
                 '@OUTPUT@',
@@ -28,7 +26,6 @@ custom_target('thumbnailer',
               depends: [
                 gdk_pixbuf_print_mime_types,
                 gdk_pixbuf_pixdata,
-                loaders_cache,
               ],
               install: true,
               install_dir: join_paths(gdk_pixbuf_datadir, 'thumbnailers'))
