# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Chih-Hsuan Yen <yan12125@archlinux.org>
# Contributor: Jerome Leclanche <jerome@leclan.ch>

pkgname=qtermwidget
pkgver=2.1.0
pkgrel=2
pkgdesc="A terminal widget for Qt, used by QTerminal"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url="https://github.com/lxqt/qtermwidget"
# Yep, it's messy when you're talking about licenses
# https://github.com/lxqt/qtermwidget/blob/2.0.0/README.md?plain=1#L13-L42
license=('LGPL-2.0-or-later' 'BSD-3-Clause')
depends=("qt6-base")
makedepends=("git" "lxqt-build-tools"
             "python-pyqt6" "pyqt-builder" "sip" "python-installer")
optdepends=(
  'python: PyQt bindings'
)
source=(
  "git+https://github.com/lxqt/qtermwidget.git?signed#tag=$pkgver"
)
sha256sums=('f757c30fda5c023bc88be4bf9628097ab8eacc87335ed9aca136eb672bca9e84')
validpgpkeys=(
  "19DFDF3A579BD509DBB572D8BE793007AD22DF7E"  # https://github.com/tsujan.gpg
)

build() {
  cmake -B build -S qtermwidget \
    -DCMAKE_INSTALL_PREFIX=/usr
  make -C build

  cd "$srcdir"/qtermwidget/pyqt
  CXXFLAGS="$CXXFLAGS -I$PWD/../lib -I$PWD/../../build/lib" LDFLAGS="$LDFLAGS -L$PWD/../../build" sip-wheel --verbose --qmake /usr/bin/qmake6
}

package() {
  make -C build DESTDIR="$pkgdir" install
  install -Dm644 "$srcdir"/qtermwidget/README.md -t "$pkgdir"/usr/share/licenses/$pkgname

  python -m installer --destdir="$pkgdir" "$srcdir"/qtermwidget/pyqt/*.whl
}
