# Maintainer: Lubosz Sarnecki <lubosz@gmail.com>

_realname=gst-editing-services
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.18.4
pkgrel=1
pkgdesc="GStreamer Editing Services (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
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"
             "${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-python-gobject")
depends=("${MINGW_PACKAGE_PREFIX}-gst-plugins-base")
options=(!libtool strip staticlibs)
source=(${url}/src/${_realname}/${_realname}-${pkgver}.tar.xz
        0001-meson-Don-t-harcode-path-to-site-packages.patch)
sha256sums=('4687b870a7de18aebf50f45ff572ad9e0138020e3479e02a6f056a0c4c7a1d04'
            '92ffe7a8d2109d0dbca4d591af8d7a7f2aa2db3994781458f3cf313c1f8ed391')

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

  # https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/230
  patch -Np1 -i "${srcdir}"/0001-meson-Don-t-harcode-path-to-site-packages.patch
}

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 \
    -Ddoc=disabled \
    -Dbash-completion=disabled \
    -Dpython=disabled \
    -Dvalidate=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
}
