# Maintainer: Andrew Chadwick <a.t.chadwick@gmail.com>

_realname=graphene
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.10.8
pkgrel=3
pkgdesc="A thin layer of graphic data types (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://ebassi.github.io/graphene/"
msys2_repository_url="https://github.com/ebassi/graphene"
license=("spdx:MIT")
depends=("${MINGW_PACKAGE_PREFIX}-glib2")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
source=("https://github.com/ebassi/graphene/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('922dc109d2dc5dc56617a29bd716c79dd84db31721a8493a13a5f79109a4a4ed')

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

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson \
    --prefix="${MINGW_PREFIX}" \
    --buildtype release \
    -Dgtk_doc=true \
    -Dinstalled_tests=false \
    ../${_realname}-${pkgver}

  meson compile
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  meson test --print-errorlogs || true
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  DESTDIR="${pkgdir}" meson install

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