[gdk-pixbuf] Initial implementation of a Meson build



commit 8a055f4c866e0ae1d677be5fd70aab1b2869d4d2
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed May 24 23:47:12 2017 +0100

    Initial implementation of a Meson build
    
    Meson is a better build system than Autotools that has gotten traction
    in the GNOME community.
    
    The build is pretty much equivalent between Autotools and Meson, but at
    this point it needs further testing to verify complete matching
    behaviour.
    
    The GDI-plus loaders are not currently built, as that will require
    access to a platform I don't have in order to test them.
    
    Additionally, the API reference is not being generated yet in Meson.

 gdk-pixbuf/meson.build        |  178 +++++++++++++++++++++++++
 gdk-pixbuf/pixops/meson.build |    9 ++
 meson.build                   |  295 +++++++++++++++++++++++++++++++++++++++++
 meson_options.txt             |   24 ++++
 po/meson.build                |    3 +
 tests/gen-resources.py        |   44 ++++++
 tests/meson.build             |   82 ++++++++++++
 7 files changed, 635 insertions(+), 0 deletions(-)
---
diff --git a/gdk-pixbuf/meson.build b/gdk-pixbuf/meson.build
new file mode 100644
index 0000000..c50a20c
--- /dev/null
+++ b/gdk-pixbuf/meson.build
@@ -0,0 +1,178 @@
+subdir('pixops')
+
+# Loader libs
+#  - name
+#  - sources
+#  - conditional, otherwise always built
+loaders = [
+  [ 'png', [ 'io-png.c' ], enabled_loaders.contains('png') ],
+  [ 'bmp', [ 'io-bmp.c' ] ],
+  [ 'gif', [ 'io-gif.c', 'io-gif-animation.c' ] ],
+  [ 'ico', [ 'io-ico.c' ] ],
+  [ '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' ] ],
+  [ 'jasper', [ 'io-jasper.c' ], enabled_loaders.contains('jasper') ],
+  [ 'qtif', [ 'io-qtif.c' ] ]
+]
+
+gdk_pixbuf_cflags = [
+  '-DG_LOG_STRUCTURED=1',
+  '-DG_LOG_DOMAIN="GdkPixbuf"',
+  '-DGDK_PIXBUF_COMPILATION',
+  '-DGDK_PIXBUF_PREFIX="@0@"'.format(gdk_pixbuf_prefix),
+  '-DGDK_PIXBUF_LOCALEDIR="@0@"'.format(gdk_pixbuf_localedir),
+  '-DGDK_PIXBUF_LIBDIR="@0@"'.format(gdk_pixbuf_libdir),
+  '-DGDK_PIXBUF_BINARY_VERSION="@0@"'.format(gdk_pixbuf_binary_version),
+  '-DGDK_PIXBUF_ENABLE_BACKEND',
+  '-DPIXBUF_LIBDIR="@0@"'.format(gdk_pixbuf_loaderdir),
+  '-DBUILT_MODULES_DIR="@0@"'.format(meson.current_build_dir()),
+]
+
+gdk_pixbuf_api_path = join_paths('gdk-pixbuf-@0@'.format(gdk_pixbuf_api_version), 'gdk-pixbuf')
+
+gdkpixbuf_features_conf = configuration_data()
+gdkpixbuf_features_conf.set('GDK_PIXBUF_MAJOR', gdk_pixbuf_version_major)
+gdkpixbuf_features_conf.set('GDK_PIXBUF_MINOR', gdk_pixbuf_version_minor)
+gdkpixbuf_features_conf.set('GDK_PIXBUF_MICRO', gdk_pixbuf_version_micro)
+gdkpixbuf_features_conf.set('GDK_PIXBUF_VERSION', meson.project_version())
+configure_file(input: 'gdk-pixbuf-features.h.in',
+               output: 'gdk-pixbuf-features.h',
+               configuration: gdkpixbuf_features_conf,
+               install: true,
+               install_dir: join_paths(gdk_pixbuf_includedir, gdk_pixbuf_api_path))
+
+gdkpixbuf_headers = [
+  'gdk-pixbuf.h',
+  'gdk-pixbuf-autocleanups.h',
+  'gdk-pixbuf-core.h',
+  'gdk-pixbuf-transform.h',
+  'gdk-pixbuf-io.h',
+  'gdk-pixbuf-animation.h',
+  'gdk-pixbuf-simple-anim.h',
+  'gdk-pixbuf-loader.h',
+]
+
+install_headers(gdkpixbuf_headers, subdir: gdk_pixbuf_api_path)
+
+gdkpixbuf_sources = [
+  'gdk-pixbuf.c',
+  'gdk-pixbuf-animation.c',
+  'gdk-pixbuf-data.c',
+  'gdk-pixbuf-io.c',
+  'gdk-pixbuf-loader.c',
+  'gdk-pixbuf-scale.c',
+  'gdk-pixbuf-simple-anim.c',
+  'gdk-pixbuf-scaled-anim.c',
+  'gdk-pixbuf-util.c',
+  'gdk-pixdata.c',
+]
+
+gdkpixbuf_marshals = gnome.genmarshal('gdk-pixbuf-marshal',
+                                      sources: 'gdk-pixbuf-marshal.list',
+                                      prefix: '_gdk_pixbuf_marshal')
+
+gdkpixbuf_enums = gnome.mkenums('gdk-pixbuf-enum-types',
+                                sources: gdkpixbuf_headers,
+                                c_template: 'gdk-pixbuf-enum-types.c.template',
+                                h_template: 'gdk-pixbuf-enum-types.h.template',
+                                install_header: true)
+gdkpixbuf_enum_h = gdkpixbuf_enums[1]
+
+# Check if we need to build loaders as built-in functionality
+included_loaders_cflags = []
+included_loaders_deps = []
+
+foreach l: loaders
+  name = l[0]
+  sources = l[1]
+  cond = l.get(2, true)
+
+  if cond and builtin_loaders.contains(name)
+    included_loaders_cflags += '-DINCLUDED_@0@'.format(name)
+
+    mod = static_library('staticpixbufloader-@0@'.format(name),
+                         sources,
+                         dependencies: loaders_deps + gdk_pixbuf_deps,
+                         include_directories: [ root_inc, include_directories('.') ],
+                         c_args: common_cflags + gdk_pixbuf_cflags)
+
+    included_loaders_deps += declare_dependency(link_with: mod)
+  endif
+endforeach
+
+# The main gdk-pixbuf shared library
+gdkpixbuf = library('gdk-pixbuf-2.0',
+                    gdkpixbuf_sources + gdkpixbuf_enums + gdkpixbuf_marshals,
+                    soversion: soversion,
+                    version: libversion,
+                    c_args: common_cflags + gdk_pixbuf_cflags + included_loaders_cflags,
+                    link_args: common_ldflags,
+                    include_directories: root_inc,
+                    dependencies: gdk_pixbuf_deps + included_loaders_deps + [ pixops_dep ],
+                    install: true)
+
+gdkpixbuf_dep = declare_dependency(link_with: gdkpixbuf,
+                                   include_directories: root_inc,
+                                   dependencies: gdk_pixbuf_deps,
+                                   sources: gdkpixbuf_enum_h)
+
+# Now check if we are building loaders as installed shared modules
+# We do this here because shared modules depend on libgdk-pixbuf
+dynamic_loaders = []
+
+foreach l: loaders
+  name = l[0]
+  sources = l[1]
+  cond = l.get(2, true)
+
+  if cond and not builtin_loaders.contains(name)
+    mod = shared_module('pixbufloader-@0@'.format(name),
+                        sources,
+                        dependencies: loaders_deps + gdk_pixbuf_deps + [ gdkpixbuf_dep ],
+                        include_directories: [ root_inc, include_directories('.') ],
+                        c_args: common_cflags + gdk_pixbuf_cflags,
+                        install: true,
+                        install_dir: gdk_pixbuf_loaderdir)
+
+    # We need the path to build loaders.cache for tests
+    dynamic_loaders += mod.full_path()
+  endif
+endforeach
+
+gdkpixbuf_bin = [
+  [ 'gdk-pixbuf-csource' ],
+  [ 'gdk-pixbuf-pixdata' ],
+  [ 'gdk-pixbuf-query-loaders', [ 'queryloaders.c' ] ],
+]
+
+foreach bin: gdkpixbuf_bin
+  bin_name = bin[0]
+  bin_source = bin.get(1, bin_name + '.c')
+
+  bin = executable(bin_name, bin_source,
+                   dependencies: gdk_pixbuf_deps + [ gdkpixbuf_dep ],
+                   include_directories: [ root_inc, include_directories('.') ],
+                   c_args: common_cflags + gdk_pixbuf_cflags,
+                   install: true)
+
+  # Used in tests
+  set_variable(bin_name.underscorify(), bin)
+endforeach
+
+# The 'loaders.cache' used for testing, so we don't accidentally
+# load the installed cache; we always build it by default
+loaders_cache = custom_target('loaders.cache',
+                              output: 'loaders.cache',
+                              capture: true,
+                              command: [
+                                gdk_pixbuf_query_loaders,
+                                dynamic_loaders,
+                              ],
+                              build_by_default: true)
+loaders_dep = declare_dependency(source: loaders_cache)
diff --git a/gdk-pixbuf/pixops/meson.build b/gdk-pixbuf/pixops/meson.build
new file mode 100644
index 0000000..20cc99b
--- /dev/null
+++ b/gdk-pixbuf/pixops/meson.build
@@ -0,0 +1,9 @@
+pixops = static_library('pixops', 'pixops.c',
+                        include_directories: root_inc,
+                        dependencies: gdk_pixbuf_deps)
+
+pixops_dep = declare_dependency(link_with: pixops,
+                                include_directories: [ root_inc, include_directories('.') ],
+                                dependencies: gdk_pixbuf_deps)
+
+executable('timescale', 'timescale.c', dependencies: pixops_dep)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..7cdb4fc
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,295 @@
+project('gdk-pixbuf', 'c',
+        version: '2.36.7',
+        license: 'LGPLv2.1+',
+        default_options: [
+          'buildtype=debugoptimized',
+          'warning_level=1',
+          'c_std=c99',
+        ],
+        meson_version: '>= 0.40.1')
+
+add_project_arguments([ '-D_POSIX_C_SOURCE', '-D_DEFAULT_SOURCE' ], language: 'c')
+
+cc = meson.get_compiler('c')
+host_system = host_machine.system()
+
+# Versioning
+gdk_pixbuf_version = meson.project_version()
+version_arr = gdk_pixbuf_version.split('.')
+gdk_pixbuf_version_major = version_arr[0].to_int()
+gdk_pixbuf_version_minor = version_arr[1].to_int()
+gdk_pixbuf_version_micro = version_arr[2].to_int()
+
+gdk_pixbuf_api_version = '2.0'
+gdk_pixbuf_binary_version = '2.10.0'
+
+if gdk_pixbuf_version_minor.is_odd()
+  gdk_pixbuf_interface_age = 0
+else
+  gdk_pixbuf_interface_age = gdk_pixbuf_version_micro
+endif
+
+gdk_pixbuf_binary_age = 100 * gdk_pixbuf_version_minor + gdk_pixbuf_version_micro
+
+# maintaining compatibility with the previous libtool versioning
+# current = binary - interface
+# revision = interface
+soversion = 0
+current = gdk_pixbuf_binary_age - gdk_pixbuf_interface_age
+revision = gdk_pixbuf_interface_age
+libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
+
+# Paths
+gdk_pixbuf_prefix = get_option('prefix')
+gdk_pixbuf_libdir = join_paths(gdk_pixbuf_prefix, get_option('libdir'))
+gdk_pixbuf_includedir = join_paths(gdk_pixbuf_prefix, get_option('includedir'))
+gdk_pixbuf_datadir = join_paths(gdk_pixbuf_prefix, get_option('datadir'))
+gdk_pixbuf_mandir = join_paths(gdk_pixbuf_prefix, get_option('mandir'))
+gdk_pixbuf_localedir = join_paths(gdk_pixbuf_prefix, get_option('localedir'))
+gdk_pixbuf_libexecdir = join_paths(gdk_pixbuf_prefix, get_option('libexecdir'))
+gdk_pixbuf_loaderdir = join_paths(gdk_pixbuf_libdir, 
'gdk-pixbuf-@0@/@1@/loaders'.format(gdk_pixbuf_api_version, gdk_pixbuf_binary_version))
+
+# Dependencies
+glib_req_version = '>= 2.38.0'
+gio_dep = dependency('gio-2.0', version: glib_req_version)
+
+# Configurations
+gdk_pixbuf_conf = configuration_data()
+
+check_headers = [
+  'unistd.h'
+]
+
+foreach h: check_headers
+  if cc.has_header(h)
+    gdk_pixbuf_conf.set('HAVE_' + h.underscorify().to_upper(), 1)
+  endif
+endforeach
+
+# We use links() because sigsetjmp() is often a macro hidden behind other macros
+gdk_pixbuf_conf.set('HAVE_SIGSETJMP',
+                    cc.links('''#define _POSIX_SOURCE
+                                #include <setjmp.h>
+                                int main (void) {
+                                  sigjmp_buf env;
+                                  sigsetjmp (env, 0);
+                                  return 0;
+                                }''', name: 'sigsetjmp'))
+
+# XXX: Remove once we declare gdk-pixbuf C99-only
+if cc.get_id() != 'msvc'
+  gdk_pixbuf_conf.set('HAVE_ROUND', 1)
+  gdk_pixbuf_conf.set('HAVE_LRINT', 1)
+endif
+
+# Common compiler and linker flags
+common_cflags = []
+common_ldflags = []
+
+if cc.get_id() == 'msvc'
+  # Compiler options taken from msvc_recommended_pragmas.h
+  # in GLib, based on _Win32_Programming_ by Rector and Newcomer
+  test_cflags = [
+    '-we4002', # too many actual parameters for macro
+    '-we4003', # not enough actual parameters for macro
+    '-w14010', # single-line comment contains line-continuation character
+    '-we4013', # 'function' undefined; assuming extern returning int
+    '-w14016', # no function return type; using int as default
+    '-we4020', # too many actual parameters
+    '-we4021', # too few actual parameters
+    '-we4027', # function declared without formal parameter list
+    '-we4029', # declared formal parameter list different from definition
+    '-we4033', # 'function' must return a value
+    '-we4035', # 'function' : no return value
+    '-we4045', # array bounds overflow
+    '-we4047', # different levels of indirection
+    '-we4049', # terminating line number emission
+    '-we4053', # an expression of type void was used as an operand
+    '-we4071', # no function prototype given
+    '-we4819', # the file contains a character that cannot be represented in the current code page
+  ]
+elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
+  test_cflags = [
+    '-Wpointer-arith',
+    '-Wformat=2',
+    '-Wstrict-prototypes',
+    '-Wnested-externs',
+    '-Wold-style-definition',
+    '-Wdeclaration-after-statement',
+    '-Wunused',
+    '-Wcast-align',
+    '-Wmissing-noreturn',
+    '-Wmissing-format-attribute',
+    '-Wlogical-op',
+    '-fno-strict-aliasing',
+    '-Wno-int-conversion',
+    '-Wno-uninitialized',
+    '-Wno-discarded-qualifiers',
+    '-Werror=implicit',
+    '-Werror=nonnull',
+    '-Werror=init-self',
+    '-Werror=main',
+    '-Werror=missing-braces',
+    '-Werror=sequence-point',
+    '-Werror=return-type',
+    '-Werror=trigraphs',
+    '-Werror=array-bounds',
+    '-Werror=write-strings',
+    '-Werror=address',
+    '-Werror=int-to-pointer-cast',
+    '-Werror=pointer-to-int-cast',
+    '-Werror=empty-body',
+  ]
+
+  # Ensure we have the correct bit packing on Windows
+  if host_system == 'windows'
+    test_cflags += '-mms-bitfields'
+  endif
+else
+  test_cflags = []
+endif
+
+# Symbol visibility
+if get_option('default_library') != 'static'
+  if host_system == 'windows'
+    gdk_pixbuf_conf.set('DLL_EXPORT', true)
+    gdk_pixbuf_conf.set('_GDK_PIXBUF_EXTERN', '__declspec(dllexport) extern')
+    if cc.get_id() != 'msvc'
+      test_cflags += ['-fvisibility=hidden']
+    endif
+  else
+    gdk_pixbuf_conf.set('_GDK_PIXBUF_EXTERN', '__attribute__((visibility("default"))) extern')
+    test_cflags += ['-fvisibility=hidden']
+  endif
+endif
+
+foreach cflag: test_cflags
+  if cc.has_argument(cflag)
+    common_cflags += cflag
+  endif
+endforeach
+
+# Linker flags
+if host_machine.system() == 'linux'
+  ldflag_prog = 'int main (void) { return 0; }'
+  foreach ldflag: [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ]
+    if cc.links(ldflag_prog, args: ldflag, name: 'using @0@'.format(ldflag))
+      common_ldflags += ldflag
+    endif
+  endforeach
+endif
+
+# Maintain compatibility with autotools on macOS
+if host_machine.system() == 'darwin'
+  common_ldflags += [ '-compatibility_version 1', '-current_version 1.0', ]
+endif
+
+# Dependencies
+mathlib_dep = cc.find_library('m', required: false)
+gobject_dep = dependency('gobject-2.0', version: glib_req_version)
+gmodule_dep = dependency('gmodule-no-export-2.0')
+gio_dep = dependency('gio-2.0')
+
+# On non-Windows systems we always required shared-mime-info and GIO
+if host_machine.system() != 'windows'
+  shared_mime_dep = dependency('shared-mime-info')
+  gdk_pixbuf_conf.set('GDK_PIXBUF_USE_GIO_MIME', 1)
+else
+  shared_mime_dep = []
+endif
+
+gdk_pixbuf_deps = [ mathlib_dep, gobject_dep, gmodule_dep, gio_dep, shared_mime_dep ]
+
+# Check if we can build shared modules
+build_modules = gmodule_dep.get_pkgconfig_variable('gmodule_supported') == 'true'
+gdk_pixbuf_conf.set10('USE_GMODULE', build_modules)
+
+# Check which loaders should be built into gdk-pixbuf
+builtin_loaders = get_option('builtin_loaders').split(',')
+
+# Loader dependencies
+enabled_loaders = []
+loaders_deps = []
+
+if get_option('enable_png')
+  # We have a vast selection of libpng versions to choose from
+  foreach png: [ 'libpng16', 'libpng15', 'libpng14', 'libpng12', 'libpng13', 'libpng10' ]
+    if not enabled_loaders.contains('png')
+      png_dep = dependency(png, required: false)
+      if png_dep.found()
+        enabled_loaders += 'png'
+        loaders_deps += png_dep
+      endif
+    endif
+  endforeach
+endif
+
+if get_option('enable_tiff')
+  tiff_dep = dependency('libtiff-4', required: false)
+  if tiff_dep.found()
+    enabled_loaders += 'tiff'
+    loaders_deps += tiff_dep
+  endif
+endif
+
+if get_option('enable_jpeg')
+  if cc.has_header('jpeglib.h')
+    jpeg_dep = cc.find_library('jpeg', required: false)
+    if jpeg_dep.found() and cc.has_function('jpeg_destroy_decompress', dependencies: jpeg_dep)
+      enabled_loaders += 'jpeg'
+      loaders_deps += jpeg_dep
+
+      gdk_pixbuf_conf.set('HAVE_PROGRESSIVE_JPEG',
+                          cc.has_function('jpeg_simple_progression', dependencies: jpeg_dep))
+    endif
+  endif
+endif
+
+if get_option('enable_jasper')
+  if cc.has_header('jasper/jasper.h')
+    jasper_dep = cc.find_library('jasper', required: false)
+    if jasper_dep.found() and cc.has_function('jas_init', dependencies: jasper_dep)
+      enabled_loaders += 'jasper'
+      loaders_deps += jasper_dep
+    endif
+  endif
+endif
+
+gdk_pixbuf_conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+
+configure_file(output: 'config.h', configuration: gdk_pixbuf_conf)
+
+# Compat variables for pkgconfig
+pkgconf = configuration_data()
+pkgconf.set('prefix', gdk_pixbuf_prefix)
+pkgconf.set('exec_prefix', gdk_pixbuf_prefix)
+pkgconf.set('libdir', gdk_pixbuf_libdir)
+pkgconf.set('includedir', gdk_pixbuf_includedir)
+pkgconf.set('GDK_PIXBUF_API_VERSION', gdk_pixbuf_api_version)
+pkgconf.set('GDK_PIXBUF_BINARY_VERSION', gdk_pixbuf_binary_version)
+pkgconf.set('GDK_PIXBUF_EXTRA_CFLAGS', '')
+pkgconf.set('GDK_PIXBUF_EXTRA_LIBS', '')
+pkgconf.set('PNG_DEP_CFLAGS_PACKAGES', '')
+pkgconf.set('VERSION', meson.project_version())
+
+configure_file(input: 'gdk-pixbuf-2.0.pc.in',
+               output: 'gdk-pixbuf-2.0.pc',
+               configuration: pkgconf,
+               install: true,
+               install_dir: join_paths(gdk_pixbuf_libdir, 'pkgconfig'))
+
+root_inc = include_directories('.')
+
+gnome = import('gnome')
+
+subdir('gdk-pixbuf')
+
+# i18n
+subdir('po')
+
+subdir('tests')
+
+# Documentation
+#if get_option('with_docs')
+#  subdir('docs/reference/gdk-pixbuf')
+#endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..55f9cca
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,24 @@
+option('enable_png',
+       description: 'Enable PNG loader (requires libpng)',
+       type: 'boolean',
+       value: true)
+option('enable_tiff',
+       description: 'Enable TIFF loader (requires libtiff)',
+       type: 'boolean',
+       value: true)
+option('enable_jpeg',
+       description: 'Enable JPEG loader (requires libjpeg)',
+       type: 'boolean',
+       value: true)
+option('enable_jasper',
+       description: 'Enable JPEG2000 loader (requires libjasper)',
+       type: 'boolean',
+       value: false)
+option('builtin_loaders',
+       description: 'Comma-separated list of loaders to build into gdk-pixbuf',
+       type: 'string',
+       value: 'none')
+option('with_docs',
+       description: 'Whether to generate the API reference (requires GTK-Doc)',
+       type: 'boolean',
+       value: false)
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..704ca6e
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,3 @@
+i18n = import('i18n')
+
+i18n.gettext(meson.project_name(), preset: 'glib')
diff --git a/tests/gen-resources.py b/tests/gen-resources.py
new file mode 100644
index 0000000..4c182d9
--- /dev/null
+++ b/tests/gen-resources.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+
+# Ancillary wrapper around glib-compile-resources that sets up a
+# modified environment in order to use the tools that we just
+# built instead of the system ones
+
+import argparse
+import os
+import subprocess
+import sys
+
+argparser = argparse.ArgumentParser(description='Compile resources')
+argparser.add_argument('--pixdata', metavar='PATH', help='Path to gdk-pixbuf-pixdata')
+argparser.add_argument('--loaders', metavar='PATH', help='Path to the loaders.cache file')
+argparser.add_argument('--sourcedir', metavar='PATH', help='Path to the source directory')
+argparser.add_argument('resource', help='GResource XML file')
+argparser.add_argument('output', help='Output file')
+
+group = argparser.add_mutually_exclusive_group()
+group.add_argument('--header', help='Generate header file', action='store_true')
+group.add_argument('--source', help='Generate source file', action='store_true')
+
+args = argparser.parse_args()
+
+cmd = ['glib-compile-resources']
+if args.header:
+    cmd += ['--generate-header']
+else:
+    cmd += ['--generate-source']
+
+cmd += ['--sourcedir', args.sourcedir]
+cmd += [args.resource]
+cmd += ['--target', args.output]
+
+newenv = os.environ.copy()
+newenv['GDK_PIXBUF_PIXDATA'] = args.pixdata
+newenv['GDK_PIXBUF_MODULE_FILE'] = args.loaders
+
+out, err = subprocess.Popen(cmd, env=newenv).communicate()
+if out is None:
+    sys.exit(0)
+else:
+    print(out)
+    sys.exit(1)
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..91e2f88
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,82 @@
+# 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
+gen_resources = find_program('gen-resources.py')
+resources_c = custom_target('resources.c',
+                            input: 'resources.gresource.xml',
+                            output: 'resources.c',
+                            command: [
+                              gen_resources,
+                              '--pixdata=@0@'.format(gdk_pixbuf_pixdata.full_path()),
+                              '--loaders=@0@'.format(loaders_cache.full_path()),
+                              '--sourcedir=@0@'.format(meson.current_source_dir()),
+                              '--source',
+                              '@INPUT@',
+                              '@OUTPUT@',
+                            ],
+                            depends: [
+                              gdk_pixbuf_pixdata,
+                              loaders_cache,
+                            ])
+resources_h = custom_target('resources.h',
+                            input: 'resources.gresource.xml',
+                            output: 'resources.h',
+                            command: [
+                              gen_resources,
+                              '--pixdata=@0@'.format(gdk_pixbuf_pixdata.full_path()),
+                              '--loaders=@0@'.format(loaders_cache.full_path()),
+                              '--sourcedir=@0@'.format(meson.current_source_dir()),
+                              '--header',
+                              '@INPUT@',
+                              '@OUTPUT@',
+                            ],
+                            depends: [
+                              gdk_pixbuf_pixdata,
+                              loaders_cache,
+                            ])
+
+installed_tests = [
+  [ 'animation' ],
+  [ 'cve-2015-4491', true ],
+  [ 'pixbuf-fail' ],
+  [ 'pixbuf-icon-serialize' ],
+  [ 'pixbuf-randomly-modified' ],
+  [ 'pixbuf-threads' ],
+  [ 'pixbuf-icc' ],
+  [ 'pixbuf-jpeg' ],
+  [ 'pixbuf-dpi' ],
+  [ 'pixbuf-pixdata', true ],
+  [ 'pixbuf-stream' ],
+  [ 'pixbuf-reftest' ],
+  [ 'pixbuf-resource', true ],
+  [ 'pixbuf-scale' ],
+  [ 'pixbuf-scale-two-step' ],
+  [ 'pixbuf-short-gif-write' ],
+  [ 'pixbuf-save' ],
+  [ 'pixbuf-readonly-to-mutable' ],
+  [ 'pixbuf-composite' ],
+  [ 'pixbuf-area-updated' ],
+]
+
+test_deps = gdk_pixbuf_deps + [ gdkpixbuf_dep ]
+foreach t: installed_tests
+  test_name = t[0]
+  test_sources = [ test_name + '.c', 'test-common.c' ]
+  needs_resources = t.get(1, false)
+  if needs_resources
+    test_sources += [ resources_c, resources_h ]
+  endif
+
+  test_bin = executable(test_name, test_sources,
+                        dependencies: test_deps,
+                        include_directories: [ root_inc, include_directories('../gdk-pixbuf') ],
+                        c_args: common_cflags)
+
+  test(test_name, test_bin,
+       args: [ '-k', '--tap' ],
+       env: [
+         'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+         'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+         'GDK_PIXBUF_MODULE_FILE=@0@'.format(loaders_cache.full_path()),
+       ])
+endforeach


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]