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

_realname=graphene
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.10.4
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
pkgdesc="A thin layer of graphic data types (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
options=('strip' '!debug')
license=("MIT")
url="https://ebassi.github.io/graphene/"
source=("${_realname}-${pkgver}.tar.gz::https://github.com/ebassi/graphene/archive/${pkgver}.tar.gz")
sha256sums=('d73861aceda1adf13c1fbb588ce8a3b4f632bd8d41e4635d4c70e00595d85c4d')

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

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

  ninja
}

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

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

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