diff options
author | Emmanuele Bassi <ebassi@gmail.com> | 2021-04-08 19:02:15 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gmail.com> | 2021-04-08 19:02:15 +0000 |
commit | 09ebed75d5680dcb72cdcec6ced469773399bdd7 (patch) | |
tree | ec93b4cc99605a63b25ae648296de0fd963921b0 | |
parent | 7bea10fd61f708805657a5a44fca548bd31ebbe9 (diff) | |
parent | a3bc66abbda5cbbbb2d64786783f920fa9099618 (diff) | |
download | gdk-pixbuf-09ebed75d5680dcb72cdcec6ced469773399bdd7.tar.gz |
Merge branch 'ebassi/for-master' into 'master'
Build system clean up
See merge request GNOME/gdk-pixbuf!112
-rw-r--r-- | .gitlab-ci.yml | 2 | ||||
-rw-r--r-- | .gitlab/ci/fedora.Dockerfile | 2 | ||||
-rw-r--r-- | build-aux/post-install.bat | 24 | ||||
-rw-r--r-- | build-aux/post-install.py | 26 | ||||
-rw-r--r-- | build-aux/post-install.sh | 18 | ||||
-rw-r--r-- | docs/meson.build | 2 | ||||
-rw-r--r-- | gdk-pixbuf/meson.build | 125 | ||||
-rw-r--r-- | meson.build | 100 | ||||
-rw-r--r-- | meson_options.txt | 7 | ||||
-rw-r--r-- | subprojects/libpng.wrap | 3 |
10 files changed, 170 insertions, 139 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2379cc9a9..19f7516d3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ variables: COMMON_MESON_FLAGS: "-Dwerror=true -Dglib:werror=false" LOADERS_FLAGS: "-Dpng=true -Djpeg=true -Dtiff=true" MESON_TEST_TIMEOUT_MULTIPLIER: 3 - FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gdk-pixbuf/fedora:v2" + FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gdk-pixbuf/fedora:v3" .only-default: only: diff --git a/.gitlab/ci/fedora.Dockerfile b/.gitlab/ci/fedora.Dockerfile index 804024823..6ae97559c 100644 --- a/.gitlab/ci/fedora.Dockerfile +++ b/.gitlab/ci/fedora.Dockerfile @@ -34,7 +34,7 @@ RUN dnf -y install \ which \ && dnf clean all -RUN pip3 install meson==0.55.3 +RUN pip3 install meson==0.56.0 ARG HOST_USER_ID=5555 ENV HOST_USER_ID ${HOST_USER_ID} diff --git a/build-aux/post-install.bat b/build-aux/post-install.bat deleted file mode 100644 index 6994d49e1..000000000 --- a/build-aux/post-install.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off - -set bindir=%1 -set libdir=%2 -set binary_version=%3 - -set libdir_windows=%libdir:/=\% - -if not "%DESTDIR%" == "" goto warn_msg -if not exist %libdir_windows%\gdk-pixbuf-2.0\%binary_version%\ mkdir %libdir_windows%\gdk-pixbuf-2.0\%binary_version% -%bindir%\gdk-pixbuf-query-loaders > %libdir_windows%\gdk-pixbuf-2.0\%binary_version%\loaders.cache - -goto end - -:warn_msg -echo *** -echo *** Warning: loaders.cache not built -echo *** -echo *** You should generate this file manually on the host system -echo *** using: -echo *** gdk-pixbuf-query-loaders ^> %libdir_windows%\gdk-pixbuf-2.0\%binary_version%\loaders.cache -echo *** - -:end diff --git a/build-aux/post-install.py b/build-aux/post-install.py new file mode 100644 index 000000000..d532ddf73 --- /dev/null +++ b/build-aux/post-install.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess + +if 'DESTDIR' not in os.environ: + bindir = sys.argv[1] + libdir = sys.argv[2] + binary_version = sys.argv[3] + + query_loaders = os.path.join(bindir, "gdk-pixbuf-query-loaders") + loaders_dir = os.path.join(libdir, "gdk-pixbuf-2.0", binary_version) + loaders_cache = os.path.join(loaders_dir, "loaders.cache") + + os.makedirs(loaders_dir, exist_ok=True) + + cmd = [query_loaders] + with subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True) as p: + data = p.stdout.read() + + with open(loaders_cache, "wb") as f: + f.write(data) +else: + print("*** Warning: loaders.cache not built because DESTDIR is set") + print("*** You will need to manually call gdk-pixbuf-query-loaders") diff --git a/build-aux/post-install.sh b/build-aux/post-install.sh deleted file mode 100644 index 661bceeef..000000000 --- a/build-aux/post-install.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -bindir="$1" -libdir="$2" -binary_version="$3" - -if [ -z "$DESTDIR" ]; then - mkdir -p "$libdir/gdk-pixbuf-2.0/$binary_version" - $bindir/gdk-pixbuf-query-loaders > "$libdir/gdk-pixbuf-2.0/$binary_version/loaders.cache" -else - echo "***" - echo "*** Warning: loaders.cache not built" - echo "***" - echo "*** You should generate this file manually on the host system" - echo "*** using:" - echo "*** gdk-pixbuf-query-loaders > $libdir/gdk-pixbuf-2.0/$binary_version/loaders.cache" - echo "***" -fi diff --git a/docs/meson.build b/docs/meson.build index c9a16a49b..9c065f7c4 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -12,7 +12,7 @@ pixdata_toml = configure_file(input: 'gdk-pixdata.toml.in', output: 'gdk-pixdata gidocgen = find_program('gi-docgen', required: get_option('gtk_doc')) -docs_dir = gdk_pixbuf_datadir / 'doc/gdk-pixbuf/reference' +docs_dir = gdk_pixbuf_datadir / 'doc' expand_content_md_files = [ 'scaling-compositing.md', diff --git a/gdk-pixbuf/meson.build b/gdk-pixbuf/meson.build index 2bbf4ca09..49c7d4a95 100644 --- a/gdk-pixbuf/meson.build +++ b/gdk-pixbuf/meson.build @@ -1,27 +1,64 @@ subdir('pixops') -# Loader libs -# - name -# - sources -# - conditional, otherwise always built - -# We need to disable the in-house loaders for BMP, GIF and ICO -# when native_windows_loaders is true -loaders = [ - [ 'png', [ 'io-png.c' ], enabled_loaders.contains('png') ], - [ 'bmp', [ 'io-bmp.c' ], not native_windows_loaders ], - [ 'gif', [ 'io-gif.c', 'io-gif-animation.c', 'lzw.c' ], not native_windows_loaders ], - [ 'ico', [ 'io-ico.c' ], not native_windows_loaders ], - [ 'ani', [ 'io-ani.c', 'io-ani-animation.c' ] ], - [ 'jpeg', [ 'io-jpeg.c' ], enabled_loaders.contains('jpeg') ], - [ 'pnm', [ 'io-pnm.c' ] ], - [ 'tiff', [ 'io-tiff.c' ], enabled_loaders.contains('tiff') ], - [ 'xpm', [ 'io-xpm.c' ] ], - [ 'xbm', [ 'io-xbm.c' ] ], - [ 'tga', [ 'io-tga.c', 'gdk-pixbuf-buffer-queue.c' ] ], - [ 'icns', [ 'io-icns.c' ] ], - [ 'qtif', [ 'io-qtif.c' ] ] -] +# Loaders +# - sources: additional source files +# - c_args: additional C compiler arguments +# - enabled: condition for building + +loaders = { + 'png': { + 'sources': [ 'io-png.c' ], + 'enabled': enabled_loaders.contains('png'), + }, + 'bmp': { + 'sources': [ 'io-bmp.c' ], + 'enabled': not native_windows_loaders, + }, + 'gif': { + 'sources': [ 'io-gif.c', 'io-gif-animation.c', 'lzw.c' ], + 'enabled': not native_windows_loaders, + }, + 'ico': { + 'sources': [ 'io-ico.c' ], + 'enabled': not native_windows_loaders, + }, + 'ani': { + 'sources': [ 'io-ani.c', 'io-ani-animation.c' ], + 'enabled': true, + }, + 'jpeg': { + 'sources': [ 'io-jpeg.c' ], + 'enabled': enabled_loaders.contains('jpeg'), + }, + 'pnm': { + 'sources': [ 'io-pnm.c' ], + 'enabled': true, + }, + 'tiff': { + 'sources': [ 'io-tiff.c' ], + 'enabled': enabled_loaders.contains('tiff'), + }, + 'xpm': { + 'sources': [ 'io-xpm.c' ], + 'enabled': true, + }, + 'xbm': { + 'sources': [ 'io-xbm.c' ], + 'enabled': true, + }, + 'tga': { + 'sources': [ 'io-tga.c', 'gdk-pixbuf-buffer-queue.c' ], + 'enabled': true, + }, + 'icns': { + 'sources': [ 'io-icns.c' ], + 'enabled': true, + }, + 'qtif': { + 'sources': [ 'io-qtif.c' ], + 'enabled': true, + }, +} gdk_pixbuf_inc = include_directories('.') @@ -111,11 +148,10 @@ endif included_loaders_cflags = [] included_loaders_deps = [] -foreach l: loaders - name = l[0] - sources = l[1] - cond = l.get(2, true) - cflags = l.get(3, []) +foreach name, loader: loaders + sources = loader.get('sources', []) + cond = loader.get('enabled', true) + cflags = loader.get('c_args', []) if cond and (builtin_loaders.contains(name) or builtin_all_loaders) cflag_for_included_loader = ['-DINCLUDE_@0@'.format(name)] @@ -242,11 +278,10 @@ gdkpixbuf_dep = declare_dependency( dynamic_loaders = [] dynamic_loaders_dep = [] -foreach l: loaders - name = l[0] - sources = l[1] - cond = l.get(2, true) - cflags = l.get(3, []) +foreach name, loader: loaders + sources = loader.get('sources', []) + cond = loader.get('enabled', true) + cflags = loader.get('c_args', []) name_suffix = [] # FIXME: workaround for https://gitlab.gnome.org/GNOME/glib/issues/1413 @@ -274,8 +309,8 @@ endforeach # Build the loaders using native Windows components as dynamic modules, if requested if native_windows_loaders if not (builtin_loaders.contains('windows') or builtin_all_loaders) - foreach loader: windows_native_loader_formats - loader_sources = windows_base_loader_sources + [ 'io-gdip-@0@.c'.format(loader) ] + foreach name, loader: windows_native_loader_formats + loader_sources = windows_base_loader_sources + [ 'io-gdip-@0@.c'.format(name) ] mod = shared_module('pixbufloader-gdip-@0@'.format(loader), loader_sources, @@ -331,21 +366,23 @@ else loaders_dep = declare_dependency() endif +pkg_variables = { + 'bindir': '${prefix}/@0@'.format(get_option('bindir')), + 'gdk_pixbuf_binary_version': gdk_pixbuf_binary_version, + 'gdk_pixbuf_binarydir': '${libdir}/@0@/@1@'.format(gdk_pixbuf_api_name, gdk_pixbuf_binary_version), + 'gdk_pixbuf_moduledir': '${gdk_pixbuf_binarydir}/loaders', + 'gdk_pixbuf_cache_file': '${gdk_pixbuf_binarydir}/loaders.cache', + 'gdk_pixbuf_csource': '${bindir}/gdk-pixbuf-csource', + 'gdk_pixbuf_pixdata': '${bindir}/gdk-pixbuf-pixdata', + 'gdk_pixbuf_query_loaders': '${bindir}/gdk-pixbuf-query-loaders', +} + pkgconfig = import('pkgconfig') pkgconfig.generate( gdkpixbuf, name: 'GdkPixbuf', description: 'Image loading and scaling', - variables: [ - 'bindir=${prefix}/@0@'.format(get_option('bindir')), - 'gdk_pixbuf_binary_version=@0@'.format(gdk_pixbuf_binary_version), - 'gdk_pixbuf_binarydir=${libdir}/@0@/@1@'.format(gdk_pixbuf_api_name, gdk_pixbuf_binary_version), - 'gdk_pixbuf_moduledir=${gdk_pixbuf_binarydir}/loaders', - 'gdk_pixbuf_cache_file=${gdk_pixbuf_binarydir}/loaders.cache', - 'gdk_pixbuf_csource=${bindir}/gdk-pixbuf-csource', - 'gdk_pixbuf_pixdata=${bindir}/gdk-pixbuf-pixdata', - 'gdk_pixbuf_query_loaders=${bindir}/gdk-pixbuf-query-loaders', - ], + variables: pkg_variables, requires: 'gobject-2.0', subdirs: gdk_pixbuf_api_name, filebase: gdk_pixbuf_api_name, diff --git a/meson.build b/meson.build index df1800df3..0241fcde0 100644 --- a/meson.build +++ b/meson.build @@ -1,12 +1,13 @@ project('gdk-pixbuf', 'c', - version: '2.42.5', - license: 'LGPL-2.1-or-later', - default_options: [ - 'buildtype=debugoptimized', - 'warning_level=1', - 'c_std=gnu99', - ], - meson_version: '>= 0.55.3') + version: '2.42.5', + license: 'LGPL-2.1-or-later', + default_options: [ + 'buildtype=debugoptimized', + 'warning_level=1', + 'c_std=gnu99', + ], + meson_version: '>= 0.56.0', +) add_project_arguments([ '-D_POSIX_C_SOURCE=200809L', '-D_DEFAULT_SOURCE', '-D_XOPEN_SOURCE=700' ], language: 'c') @@ -193,12 +194,15 @@ endif # On non-Windows/macOS/android systems we always required shared-mime-info and GIO # shared_mime_dep = [] shared_mime_dep = [] +use_gio_mime = false if get_option('gio_sniffing') and host_system not in ['windows', 'darwin', 'android'] shared_mime_dep += dependency('shared-mime-info') gdk_pixbuf_conf.set('GDK_PIXBUF_USE_GIO_MIME', 1) + use_gio_mime = true endif # Check if medialib is available +use_medialib = false medialib_dep = cc.find_library('mlib', required: false) if medialib_dep.found() if cc.has_function('mlib_ImageSetStruct', dependencies: medialib_dep) @@ -207,30 +211,42 @@ if medialib_dep.found() if cc.has_function('mlib_VideoColorRGBint_to_BGRAint', dependencies: medialib_dep) gdk_pixbuf_conf.set('USE_MEDIALIB25', 1) endif + + use_medialib = true else medialib_dep = [] endif endif -gdk_pixbuf_deps = [ mathlib_dep, glib_dep, gobject_dep, gmodule_dep, gio_dep, - shared_mime_dep, medialib_dep, intl_dep ] +gdk_pixbuf_deps = [ + mathlib_dep, + glib_dep, + gobject_dep, + gmodule_dep, + gio_dep, + shared_mime_dep, + medialib_dep, + intl_dep, +] # Check if we can build shared modules if gmodule_dep.type_name() == 'pkgconfig' - build_modules = gmodule_dep.get_pkgconfig_variable('gmodule_supported') == 'true' + build_modules = gmodule_dep.get_variable(pkgconfig: 'gmodule_supported') == 'true' else build_modules = subproject('glib').get_variable('g_module_impl') != '0' endif gdk_pixbuf_conf.set('USE_GMODULE', build_modules) # Check which loaders should be built into gdk-pixbuf -builtin_loaders = get_option('builtin_loaders').split(',') +builtin_loaders = get_option('builtin_loaders') # If 'all' is specified for builtin_loaders, build all # buildable loaders into gdk-pixbuf builtin_all_loaders = false -if builtin_loaders == [ 'all' ] +if builtin_loaders.contains('all') builtin_all_loaders = true +elif builtin_loaders.contains('none') + builtin_loaders = [] endif # Loader dependencies @@ -281,7 +297,7 @@ if get_option('png') # that will bypass --wrap-mode and cause issues for distro packagers. # See: https://mesonbuild.com/Reference-manual.html#dependency if not png_dep.found() - png_dep = dependency('', required: false, fallback: ['libpng', 'png_dep']) + png_dep = dependency('', required: false, fallback: 'libpng') if png_dep.found() enabled_loaders += 'png' loaders_deps += png_dep @@ -397,42 +413,32 @@ build_docs = get_option('gtk_doc') or get_option('docs') subdir('docs') if not meson.is_cross_build() - # On Visual Studio, we don't normally have a shell interpreter, so use a .bat - if cc.get_id() == 'msvc' - meson.add_install_script('build-aux/post-install.bat', - gdk_pixbuf_bindir, - gdk_pixbuf_libdir, - gdk_pixbuf_binary_version, - ) - else - meson.add_install_script('build-aux/post-install.sh', - gdk_pixbuf_bindir, - gdk_pixbuf_libdir, - gdk_pixbuf_binary_version, - ) - endif + meson.add_install_script('build-aux/post-install.py', + gdk_pixbuf_bindir, + gdk_pixbuf_libdir, + gdk_pixbuf_binary_version, + ) endif if not meson.is_subproject() meson.add_dist_script('build-aux/dist.py') endif -summary = [ - '', - 'GDK-Pixbuf @0@'.format(meson.project_version()), - '==================', - ' prefix: @0@'.format(gdk_pixbuf_prefix), - ' libdir: @0@'.format(gdk_pixbuf_libdir), - ' datadir: @0@'.format(gdk_pixbuf_datadir), - ' libexecdir: @0@'.format(gdk_pixbuf_libexecdir), - '', - ' enabled loaders: @0@'.format(' '.join(enabled_loaders)), - '', - ' documentation: @0@'.format(build_docs), - ' man pages: @0@'.format(get_option('man')), - ' introspection: @0@'.format(build_gir), - ' installed tests: @0@'.format(get_option('installed_tests')), - ' relocatable: @0@'.format(get_option('relocatable')), - '', -] -message('\n'.join(summary)) +summary('Shared modules', build_modules, section: 'Loaders') +summary('Enabled loaders', enabled_loaders, section: 'Loaders') +summary('Builtin loaders', builtin_loaders, section: 'Loaders') + +summary('Debugging', get_option('debug'), section: 'Build') +summary('Optimization', get_option('optimization'), section: 'Build') +summary('GIO MIME sniffing', use_gio_mime, section: 'Build') +summary('MediaLib', use_medialib, section: 'Build') +summary('Introspection', build_gir, section: 'Build') +summary('Documentation', build_docs, section: 'Build') +summary('Manual pages', get_option('man'), section: 'Build') +summary('Relocatable', get_option('relocatable'), section: 'Build') +summary('Installed tests', get_option('installed_tests'), section: 'Build') + +summary('prefix', gdk_pixbuf_prefix, section: 'Directories') +summary('libdir', gdk_pixbuf_libdir, section: 'Directories') +summary('datadir', gdk_pixbuf_datadir, section: 'Directories') +summary('libexecdir', gdk_pixbuf_libdir, section: 'Directories') diff --git a/meson_options.txt b/meson_options.txt index 5c2641cb6..0ee6718bf 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -11,9 +11,10 @@ option('jpeg', type: 'boolean', value: true) option('builtin_loaders', - description: 'Comma-separated list of loaders to build into gdk-pixbuf, or "none", or "all" to build all buildable loaders into gdk-pixbuf', - type: 'string', - value: 'none') + description: 'Comma-separated list of loaders to build into gdk-pixbuf', + type: 'array', + choices: ['all', 'none', 'windows', 'png', 'bmp', 'gif', 'ico', 'ani', 'jpeg', 'pnm', 'tiff', 'xpm', 'xbm', 'tga', 'icns', 'qtif'], + value: ['png', 'jpeg']) option('gtk_doc', description: 'Whether to generate the API reference', type: 'boolean', diff --git a/subprojects/libpng.wrap b/subprojects/libpng.wrap index 519b1170a..c4c751217 100644 --- a/subprojects/libpng.wrap +++ b/subprojects/libpng.wrap @@ -8,3 +8,6 @@ source_hash = 2f1e960d92ce3b3abd03d06dfec9637dfbd22febf107a536b44f7a47c60659f6 patch_url = https://wrapdb.mesonbuild.com/v1/projects/libpng/1.6.35/4/get_zip patch_filename = libpng-1.6.35-4-wrap.zip patch_hash = 0cd6ca9e8959b9c720c25d67bbf9315ec115bfc74ea4d34ea569619f4cff986f + +[provide] +libpng = png_dep |