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

_realname=gstreamer
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.26.7
pkgrel=1
pkgdesc="GStreamer Multimedia Framework (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://gstreamer.freedesktop.org/"
msys2_references=(
  "cpe: cpe:/a:gstreamer:gstreamer"
  "cpe: cpe:/a:gstreamer_project:gstreamer"
)
license=("spdx:LGPL-2.1-or-later")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-gettext-tools"
             "${MINGW_PACKAGE_PREFIX}-rust")
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-libwinpthread")
conflicts=("${MINGW_PACKAGE_PREFIX}-gst-plugins-bad<1.14.0")
source=("${url}/src/gstreamer/gstreamer-${pkgver}.tar.xz"{,.asc})
sha256sums=('18a5e214114dc501407697dd458514bba62cadd5414c60f793cf70141a4d0bb3'
            'SKIP')
validpgpkeys=('D637032E45B8C6585B9456565D2EEE6F6F349D7C') # Tim Müller <tim@gstreamer-foundation.org>

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

  declare -a extra_config
  if check_option "debug" "n"; then
    extra_config+=("--buildtype=release")
  else
    extra_config+=("--buildtype=debug")
  fi

  # For clock_gettime
  LDFLAGS+=" -pthread" \
  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson.exe setup \
    --prefix="${MINGW_PREFIX}" \
    ${extra_config[@]} \
    --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}

  meson compile
}

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

  DESTDIR="${pkgdir}" meson install

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