# Maintainer: Miloš Komarčević <miloskomarcevic@aim.com>

_realname=webp-pixbuf-loader
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.2.7
pkgrel=2
pkgdesc="WebP GDK Pixbuf Loader library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/aruiz/webp-pixbuf-loader"
msys2_references=(
  'archlinux: webp-pixbuf-loader'
  'gentoo: gui-libs/gdk-pixbuf-loader-webp'
)
license=('spdx:LGPL-2.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-libwebp"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-meson")
source=("https://github.com/aruiz/webp-pixbuf-loader/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('61ce5e8e036043f9d0e78c1596a621788e879c52aedf72ab5e78a8c44849411a')

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/meson.exe \
      --prefix=${MINGW_PREFIX} \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      "../${_realname}-${pkgver}"

  ${MINGW_PREFIX}/bin/meson.exe compile
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson.exe install

  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/LICENSE.LGPL-2 \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
