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

_realname=gstreamer
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.18.4
pkgrel=1
pkgdesc="GStreamer Multimedia Framework (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://gstreamer.freedesktop.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "flex"
             "bison")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gettext"
         "${MINGW_PACKAGE_PREFIX}-gmp"
         "${MINGW_PACKAGE_PREFIX}-gsl")
conflicts=("${MINGW_PACKAGE_PREFIX}-gst-plugins-bad<1.14.0")
source=("${url}/src/gstreamer/gstreamer-${pkgver}.tar.xz")
sha256sums=('9aeec99b38e310817012aa2d1d76573b787af47f8a725a65b833880a094dfbc5')

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

}

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=" \
  ${MINGW_PREFIX}/bin/meson.exe \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    --wrap-mode=nofallback \
    -Dauto_features=enabled \
    -Dpackage-origin='https://www.msys2.org' \
    -Dtests=disabled \
    -Dexamples=disabled \
    -Dbenchmarks=disabled \
    -Ddoc=disabled \
    -Dlibunwind=disabled \
    -Dlibdw=disabled \
    -Ddbghelp=disabled \
    -Dbash-completion=disabled \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/ninja.exe
}

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

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

  rm -f ${pkgdir}${MINGW_PREFIX}/lib/gstreamer*/*.a
}
