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

_realname=talkatu
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.2.1.r509.42ce88fc5ee3
pkgrel=2
pkgdesc="Gtk+ widgets for chat software (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://keep.imfreedom.org/talkatu/talkatu'
license=('spdx:GPL-2.0-or-later')
depends=(
  "${MINGW_PACKAGE_PREFIX}-gtk4"
  "${MINGW_PACKAGE_PREFIX}-glib2"
  "${MINGW_PACKAGE_PREFIX}-gumbo-parser"
  "${MINGW_PACKAGE_PREFIX}-cmark"
  "${MINGW_PACKAGE_PREFIX}-gspell"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-meson"
  "${MINGW_PACKAGE_PREFIX}-ninja"
  "${MINGW_PACKAGE_PREFIX}-pkgconf"
  "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
  "${MINGW_PACKAGE_PREFIX}-gi-docgen"
  "${MINGW_PACKAGE_PREFIX}-vala"
  "mercurial"
  "help2man"
)
_commit="42ce88fc5ee3"
source=("hg+https://keep.imfreedom.org/talkatu/talkatu#revision=${_commit}")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}"/${_realname}
  printf "0.2.1.r%s.%s" "$(hg identify -n -r "${_commit}")" "$(hg identify -i -r "${_commit}")"
}

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

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson setup \
    --prefix="${MINGW_PREFIX}" \
    --wrap-mode=nodownload \
    --auto-features=enabled \
    --buildtype=plain \
    ../${_realname}

  ${MINGW_PREFIX}/bin/meson compile
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson install

  install -Dm644 "${srcdir}/${_realname}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
