# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=rtaudio
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=6.0.1
pkgrel=1
pkgdesc="A set of C++ classes that provide a common API for realtime audio input/output (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://caml.music.mcgill.ca/~gary/rtaudio/'
msys2_repository_url="https://github.com/thestk/rtaudio"
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkgconf")
source=("https://github.com/thestk/${_realname}/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('7206c8b6cee43b474f43d64988fefaadfdcfc4264ed38d8de5f5d0e6ddb0a123')

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

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/meson.exe \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --buildtype=plain \
      --default-library=both \
      -Dasio=enabled \
      -Ddsound=enabled \
      -Dwasapi=enabled \
      ../${_realname}-${pkgver}

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

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/meson.exe test
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/meson.exe install --destdir="${pkgdir}"
  install -vDm644 "${srcdir}"/${_realname}-${pkgver}/LICENSE \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
