# Maintainer: suacayipkisi <konuki8523@gmail.com>
# The source is the v$pkgver tag's archive on GitHub. For a new release: bump pkgver (and the
# metadata: `makepkg --printsrcinfo > .SRCINFO`), push the tag, then run
# packaging/aur/update-checksum.sh, which puts that archive's sha256 here and in .SRCINFO.
# packaging/build.sh cannot catch a stale checksum: it builds from the working tree's tarball and
# replaces the checksum with that one's.
pkgname=t-code-ide
pkgver=0.4.2
pkgrel=1
pkgdesc='Lightweight C/C++ IDE: file tree, editor tabs with clangd and a shell'
arch=('x86_64')
url='https://github.com/suacayipkisi/t-code'
license=('MIT')
depends=('glib2' 'gtk4' 'gtksourceview5' 'json-glib' 'vte4' 'md4c' 'clang' 'git'
         'ttf-cascadia-code' 'hicolor-icon-theme')
makedepends=('pkgconf')
conflicts=('t-code')
optdepends=('ripgrep: faster Search panel (falls back to grep)'
            'gdb: the debugger (F5)')
source=("t-code-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('1d0939e6f753306ca9473552f2a43d73d3c1cbc9c72f4d36b99786366bd377d8')

build() {
  cd "t-code-$pkgver"
  make build/t-code
}

check() {
  cd "t-code-$pkgver"
  build/t-code --version | grep -qx "t-code $pkgver"
  # The other tests open windows and need a display.
  make build/test-searchmatch build/test-detect build/test-linediff
  build/test-searchmatch
  build/test-detect
  build/test-linediff
}

package() {
  cd "t-code-$pkgver"
  make DESTDIR="$pkgdir" PREFIX=/usr install
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 THIRD-PARTY.md "$pkgdir/usr/share/licenses/$pkgname/THIRD-PARTY.md"
}
