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

_realname=lite-xl
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.1.8
pkgrel=1
pkgdesc='A lightweight text editor written in Lua (mingw-w64)'
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: lite-xl'
)
msys2_repository_url='https://github.com/lite-xl/lite-xl'
url='https://lite-xl.com/'
license=('spdx:MIT')
depends=(
  "${MINGW_PACKAGE_PREFIX}-freetype"
  "${MINGW_PACKAGE_PREFIX}-lua"
  "${MINGW_PACKAGE_PREFIX}-pcre2"
  "${MINGW_PACKAGE_PREFIX}-sdl3"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-meson"
  "${MINGW_PACKAGE_PREFIX}-ninja"
  "${MINGW_PACKAGE_PREFIX}-pkgconf"
)
source=("https://github.com/lite-xl/lite-xl/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz"
        "0001-lite-xl-meson-fix-install.patch")
sha256sums=('fcaffb946bc60583369cb040d533a4ac18075a6d474d49a2a5ff4bf87e2e9a10'
            '30162cd66c9a72325f86d358d2bbae455c9ae28cfb158a983773bbdc8b0984c1')

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

build() {
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    "${MINGW_PREFIX}"/bin/meson.exe setup \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      -Duse_system_lua=true \
      ${_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}"
}
