# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=qt6-tools
pkgver=6.7.2
pkgrel=2
arch=(x86_64)
url='https://www.qt.io'
license=(GPL3 LGPL3 FDL custom)
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=('3bfa78a1ce46c5c0e3f1bfba7c8571d1c77783da7efb4ed7bcfd896e03a2bf7c'
            'SKIP')

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

  git cherry-pick -n 46ffaed90df8c14d67b4b16fdf5e0b87ab227c88 # Fix crash in Designer
}

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
}
