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

# Separate package to prevent circular dependency between libplacebo and ffmpeg
_realname=libplacebo
pkgbase=mingw-w64-${_realname}-demos
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-demos"
pkgver=7.351.0
pkgrel=2
pkgdesc="Demo programs from libplacebo (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: libplacebo'
)
msys2_repository_url='https://code.videolan.org/videolan/libplacebo'
url='https://libplacebo.org/'
depends=("${MINGW_PACKAGE_PREFIX}-ffmpeg"
         "${MINGW_PACKAGE_PREFIX}-libplacebo"
         "${MINGW_PACKAGE_PREFIX}-SDL2")
makedepends=("git"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-python-glad"
             "${MINGW_PACKAGE_PREFIX}-python-jinja"
             "${MINGW_PACKAGE_PREFIX}-fast_float"
             "${MINGW_PACKAGE_PREFIX}-xxhash"
             "${MINGW_PACKAGE_PREFIX}-vulkan-headers")
license=('spdx:LGPL-2.1-or-later')
_commit="1fd3c7bde7b943fe8985c893310b5269a09b46c5"
source=("${_realname}"::"git+https://code.videolan.org/videolan/libplacebo.git#commit=${_commit}")
sha256sums=('c3ba7e6360560711afe5231d81d8d60d186bf91cb1450cba2baeffb1c5994a37')

prepare() {
  cd "${_realname}"
  git submodule update --init --depth=1 demos/3rdparty/nuklear
}

build() {
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/meson.exe setup \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    -Ddemos=true \
    -Dtests=false \
    -Dd3d11=enabled \
    -Dlcms=enabled \
    -Dlibdovi=enabled \
    -Dshaderc=enabled \
    -Dvulkan=enabled \
    "build-${MSYSTEM}" \
    "${_realname}"

  ${MINGW_PREFIX}/bin/meson.exe compile -C "build-${MSYSTEM}"
}

package() {
  install -Dm755 "build-${MSYSTEM}"/demos/*.exe -t "${pkgdir}${MINGW_PREFIX}"/bin/
  install -Dm644 "${_realname}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}-demos/LICENSE"
}
