# Maintainer: Maksim Bondarenkov <maksapple2306@gmail.com>

_realname=muon
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.5.0
pkgrel=3
pkgdesc="Meson implementation in C (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://muon.build'
license=('spdx:GPL-3.0-only')
msys2_references=(
  'aur: muon-meson'
)
msys2_repository_url='https://git.sr.ht/~lattis/muon'
depends=("${MINGW_PACKAGE_PREFIX}-ninja"
         "${MINGW_PACKAGE_PREFIX}-pkgconf"
         "${MINGW_PACKAGE_PREFIX}-curl"
         "${MINGW_PACKAGE_PREFIX}-libarchive")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-scdoc")
source=("${url}/releases/v${pkgver}/${_realname}-v${pkgver}.tar.gz")
sha256sums=('24aa4d29ed272893f6e6d355b1ec4ef20647438454e88161bdb9defd7c6faf77')

build() {
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    meson setup \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --default-library=shared \
      --auto-features=enabled \
      --buildtype=plain \
      -Dmeson-docs=disabled \
      -Dmeson-tests=disabled \
      -Dwebsite=disabled \
      -Dtracy=disabled \
      "build-${MSYSTEM}" \
      "${_realname}-v${pkgver}"

  meson compile -C "build-${MSYSTEM}"
}

check() {
  meson test -C "build-${MSYSTEM}"
}

package() {
  meson install -C "build-${MSYSTEM}" --destdir "${pkgdir}"

  install -Dm644 "${_realname}-v${pkgver}/LICENSES/GPL-3.0-only.txt" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
