# Maintainer: Alexandros Theodotou <alex@zrythm.org>

_realname=lilv
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.24.26
pkgrel=1
pkgdesc='A C library with Python bindings for hosting LV2 plugins in applications (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://drobilla.net/software/lilv.html'
msys2_repository_url="https://gitlab.com/lv2/lilv/"
msys2_references=(
  'archlinux: lilv'
)
license=("spdx:0BSD OR ISC")
depends=("${MINGW_PACKAGE_PREFIX}-libsndfile"
         "${MINGW_PACKAGE_PREFIX}-serd"
         "${MINGW_PACKAGE_PREFIX}-sord"
         "${MINGW_PACKAGE_PREFIX}-sratom"
         "${MINGW_PACKAGE_PREFIX}-zix")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkgconf")
source=(https://download.drobilla.net/${_realname}-${pkgver}.tar.xz{,.sig})
sha256sums=('22feed30bc0f952384a25c2f6f4b04e6d43836408798ed65a8a934c055d5d8ac'
            'SKIP')
validpgpkeys=('907D226E7E13FA337F014A083672782A9BF368F3') # David Robillard <d@drobilla.net>

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

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

  ${MINGW_PREFIX}/bin/meson compile
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/meson test || warning "Tests failed"
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson install
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
