Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | From f81b60ebcbbfd9548c8aa1e388662c429068d1e3 Mon Sep 17 00:00:00 2001 |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> |
| 3 | Date: Sat, 8 May 2021 21:58:54 +0200 |
| 4 | Subject: [PATCH] Add use_prebuilt_tools option |
| 5 | |
| 6 | This allows using the gdk-pixbuf tools from the host to |
| 7 | build and install tests in a cross-compile scenarion. |
| 8 | |
| 9 | Upstream-Status: Submitted [https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/119] |
| 10 | Signed-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 | |
| 20 | diff --git a/gdk-pixbuf/meson.build b/gdk-pixbuf/meson.build |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 21 | index 54ff9dd..2e321cf 100644 |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 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', |
| 47 | diff --git a/meson.build b/meson.build |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 48 | index 813bd43..a93e6f7 100644 |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 49 | --- a/meson.build |
| 50 | +++ b/meson.build |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 51 | @@ -369,18 +369,18 @@ subdir('gdk-pixbuf') |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 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') |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 57 | if get_option('tests') |
| 58 | subdir('tests') |
| 59 | endif |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 60 | - 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, |
| 73 | diff --git a/meson_options.txt b/meson_options.txt |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 74 | index d198d99..1c899e9 100644 |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 75 | --- a/meson_options.txt |
| 76 | +++ b/meson_options.txt |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 77 | @@ -53,4 +53,8 @@ option('gio_sniffing', |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 78 | 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 | |
| 86 | diff --git a/tests/meson.build b/tests/meson.build |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 87 | index 28c2525..d97c02d 100644 |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 88 | --- 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 |
| 127 | diff --git a/thumbnailer/meson.build b/thumbnailer/meson.build |
| 128 | index 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')) |