# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

pkgname=meson
pkgver=1.4.1
pkgrel=1
pkgdesc='High-productivity build system'
arch=('any')
url="https://mesonbuild.com/"
msys2_repository_url="https://github.com/mesonbuild/meson"
msys2_references=(
  "pypi:meson"
)
license=('spdx:Apache-2.0')
depends=('python' 'ninja')
makedepends=(
  "python-setuptools"
  "python-wheel"
  "python-build"
  "python-installer"
)
source=("https://github.com/mesonbuild/${pkgname}/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.gz"{,.asc}
        "0001-cygwin-disguise.patch"
        "https://patch-diff.githubusercontent.com/raw/mesonbuild/meson/pull/12861.patch")
sha256sums=('1b8aad738a5f6ae64294cc8eaba9a82988c1c420204484ac02ef782e5bba5f49'
            'SKIP'
            '240f37b8c64446ff5d4e97a2775d48e9c5e48b62926c19900b4cead220f89614'
            'cf346c13f9548d7c4f61ecc399ec9797cc642c3e39867deed8c788d825b877f6')
validpgpkeys=("19E2D6D9B46D8DAA6288F877C24E631BABB1FE70") # Jussi Pakkanen <jpakkane@gmail.com>

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i "${srcdir}"/0001-cygwin-disguise.patch

  # https://github.com/mesonbuild/meson/pull/12861
  patch -p1 -i "${srcdir}"/12861.patch

}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  python -m installer --destdir="${pkgdir}" dist/*.whl

  install -Dm644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
}
