# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=appstream-glib
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.7.18
pkgrel=2
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
pkgdesc="Objects and methods for reading and writing AppStream metadata (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-json-glib"
         "${MINGW_PACKAGE_PREFIX}-libyaml"
         "${MINGW_PACKAGE_PREFIX}-libsoup"
         "${MINGW_PACKAGE_PREFIX}-libarchive")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
options=('strip' 'staticlibs')
license=("LGPL")
url="https://people.freedesktop.org/~hughsient/appstream-glib/"
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/hughsie/appstream-glib/archive/appstream_glib_${pkgver//./_}.tar.gz")
sha256sums=('73b8c10273c4cdd8f6de03c2524fedad64e34ccae08ee847dba804bb15461f6e')

prepare() {
  cd "${srcdir}"/${_realname}-${_realname//-/_}_${pkgver//./_}
}

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

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson \
    --prefix=${MINGW_PREFIX} \
    --buildtype=plain \
    -Dintrospection=true \
    -Dgtk-doc=true \
    -Dman=true \
    -Dfonts=true \
    -Dstemmer=false \
    -Dalpm=false \
    -Drpm=false \
    -Ddep11=false \
    -Dbuilder=false \
    "../${_realname}-${_realname//-/_}_${pkgver//./_}"
  ninja
}

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

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