# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=totem-pl-parser
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.26.3
pkgrel=7
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
pkgdesc="Simple GObject-based library to parse and save a host of playlist formats (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gmime"
         "${MINGW_PACKAGE_PREFIX}-libarchive"
         "${MINGW_PACKAGE_PREFIX}-libgcrypt"
         "${MINGW_PACKAGE_PREFIX}-libxml2")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-cc")
license=("LGPL 2")
url="https://gitlab.gnome.org/GNOME/totem-pl-parser"
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        001-win.patch
        002-meson-check-version-script.patch)
sha256sums=('0efd01b8a0a9770d52fe7354d298874ed845449b88f3f78f49290729fc2d448d'
            '370eabf2ec0b4d8182e4e5a474c0b63665bc278343243b6ad59f20dc94723771'
            'de8c897a3e3d3596b16eace85eee88c67f823c1d1b5dfa31ae9456bccf0ecb0a')
noextract=(${_realname}-${pkgver}.tar.xz)

prepare() {
  tar --exclude=really-flv.mp4 -Jxf ${_realname}-${pkgver}.tar.xz

  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i "${srcdir}"/001-win.patch
  patch -p1 -i "${srcdir}"/002-meson-check-version-script.patch
}

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

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    -Dintrospection=true \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/meson compile
}

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

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