# Maintainer: Dmitry Rogozhkin <dmitry.rogozhkin@intel.com>

_realname=libva-utils
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.22.0
pkgrel=1
pkgdesc='Video Acceleration (VA) API utilies (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://01.org/linuxmedia/vaapi'
msys2_repository_url="https://github.com/intel/libva-utils"
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-libva")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-directx-headers"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkgconf")
optdepends=("${MINGW_PACKAGE_PREFIX}-mesa: for the vaon12 Gallium driver")
source=("https://github.com/intel/libva-utils/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('7b57615c130427ec134bb5d2b80af516ce5bb19a40e89b1dab46a0d59760d96c')

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

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/meson.exe setup \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/meson.exe compile
}

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

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

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