# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=qt6-tools
_pkgver=6.8.1
pkgver=6.8.1
pkgrel=1
arch=(x86_64)
url='https://www.qt.io'
license=(GPL-3.0-only
         LGPL-3.0-only
         LicenseRef-Qt-Commercial
         Qt-GPL-exception-1.0)
pkgdesc='A cross-platform application and UI framework (Development Tools, QtHelp)'
depends=(gcc-libs
         glibc
         qt6-base
         zstd)
makedepends=(clang
             cmake
             git
             litehtml
             llvm
             ninja
             qt6-declarative)
optdepends=('clang: for qdoc and lupdate'
            'litehtml: for assistant'
            'qt6-declarative: for qdoc and lupdate')
groups=(qt6)
_pkgfn=${pkgname/6-/}
source=(git+https://code.qt.io/qt/$_pkgfn#tag=v$_pkgver
        git+https://code.qt.io/playground/qlitehtml)
sha256sums=('7b1e6d811a5e2c0de54b439d64d8862153bdad82ba3d30b52dfdc2f44cb6a4de'
            'SKIP')

prepare() {
  cd $_pkgfn
  git submodule init
  git submodule set-url src/assistant/qlitehtml "$srcdir"/qlitehtml
  git -c protocol.file.allow=always submodule update
}

build() {
  cmake -B build -S $_pkgfn -G Ninja \
    -DINSTALL_PUBLICBINDIR=usr/bin \
    -DCMAKE_MESSAGE_LOG_LEVEL=STATUS
  cmake --build build
}

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

# Install symlinks for user-facing tools
  cd "$pkgdir"
  mkdir usr/bin
  while read _line; do
    ln -s $_line
  done < "$srcdir"/build/user_facing_tool_links.txt

  install -d "$pkgdir"/usr/share/licenses
  ln -s /usr/share/licenses/qt6-base "$pkgdir"/usr/share/licenses/$pkgname
}
