_realname=pragtical
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=3.5.2
pkgrel=1
pkgdesc='The practical and pragmatic code editor. (mingw-w64)'
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: pragtical'
)
msys2_repository_url='https://github.com/pragtical/pragtical'
url='https://pragtical.dev/'
license=('spdx:MIT')
depends=(
  "${MINGW_PACKAGE_PREFIX}-freetype"
  "${MINGW_PACKAGE_PREFIX}-luajit"
  "${MINGW_PACKAGE_PREFIX}-pcre2"
  "${MINGW_PACKAGE_PREFIX}-SDL2"
  "${MINGW_PACKAGE_PREFIX}-uchardet"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-meson"
  "${MINGW_PACKAGE_PREFIX}-ninja"
  "${MINGW_PACKAGE_PREFIX}-pkgconf"
  "git"
)
source=("https://github.com/pragtical/pragtical/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz"
        "0001-pragtical-meson-fix-install.patch")
sha256sums=('95050aaa879f05c5ca765d53cfa547b1e1967a60e9a10e8c92bb63d473f51d48'
            '2e3da169123c34e059d78e63557f5c6e0e89b1e3fd377b3af69a6e6c44928b82')

prepare() {
  cd "${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/0001-pragtical-meson-fix-install.patch"
}

build() {
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    "${MINGW_PREFIX}"/bin/meson.exe setup \
      --prefix="${MINGW_PREFIX}" \
      --auto-features=enabled \
      --buildtype=plain \
      -Duse_system_lua=true \
      -Dppm=false \
      ${_realname}-${pkgver} \
      build-${MSYSTEM}

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

package() {
  "${MINGW_PREFIX}"/bin/meson.exe install -C build-${MSYSTEM} --destdir "${pkgdir}"
}
