# Maintainer: diabolus <your@email.com>
pkgname=uartscope
pkgver=1.0.0
pkgrel=1
pkgdesc="Qt6-based UART serial monitor with tag monitoring, table view and auto-reconnect"
arch=('x86_64' 'aarch64')
url="https://git.projekt-hirnfrei.de/diabolus/uartscope"
license=('MIT')
depends=('qt6-base' 'qt6-serialport')
makedepends=('cmake' 'git')
provides=('uartscope')
conflicts=('uartscope')
source=("${pkgname}::git+https://git.projekt-hirnfrei.de/diabolus/uartscope.git")
sha256sums=('SKIP')

pkgver() {
    cd "${pkgname}"
    # Use latest git tag if available, otherwise fall back to commit count + hash
    git describe --long --tags 2>/dev/null \
        | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' \
        || printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
    cmake -B build -S "${pkgname}" \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr
    cmake --build build --parallel
}

package() {
    DESTDIR="${pkgdir}" cmake --install build

    # .desktop file (generated by cmake configure_file)
    install -Dm644 "build/${pkgname}.desktop" \
        "${pkgdir}/usr/share/applications/${pkgname}.desktop"

    # License – adjust path if you add a LICENSE file to the repo
    # install -Dm644 "${pkgname}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
