# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=qt6
maintainer="Bart Ribbers <bribbers@disroot.org>"
pkgname=qt6-qtwebsockets
pkgver=6.8.2
pkgrel=0
pkgdesc="Provides WebSocket communication compliant with RFC 6455"
url="https://qt.io/"
arch="all"
license="LGPL-2.1-only AND LGPL-3.0-only AND GPL-3.0-only AND Qt-GPL-exception-1.0"
depends_dev="
	qt6-qtbase-dev
	qt6-qtdeclarative-dev
	"
makedepends="$depends_dev
	cmake
	perl
	samurai
	"
# needs a .so from the main package
depends_dev="$depends_dev $pkgname=$pkgver-r$pkgrel"
subpackages="$pkgname-dev $pkgname-libs"

case $pkgver in
	*_alpha*|*_beta*|*_rc*) _rel=development_releases;;
	*) _rel=official_releases;;
esac
source="https://download.qt.io/$_rel/qt/${pkgver%.*}/${pkgver/_/-}/submodules/qtwebsockets-everywhere-src-${pkgver/_/-}.tar.xz"
options="!check" # No usable tests
builddir="$srcdir/qtwebsockets-everywhere-src-${pkgver/_/-}"

build() {
	export CFLAGS="$CFLAGS -g1 -flto=auto"
	export CXXFLAGS="$CXXFLAGS -g1 -flto=auto"
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DINSTALL_BINDIR=lib/qt6/bin \
		-DINSTALL_DOCDIR=share/doc/qt6 \
		-DINSTALL_ARCHDATADIR=lib/qt6 \
		-DINSTALL_DATADIR=share/qt6 \
		-DINSTALL_INCLUDEDIR=include/qt6 \
		-DINSTALL_MKSPECSDIR=lib/qt6/mkspecs \
		-DINSTALL_EXAMPLESDIR=share/doc/qt6/examples
	cmake --build build --parallel
}

check() {
	ctest --test-dir build --output-on-failure
}

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

dev() {
	default_dev

	amove usr/lib/qt6/sbom
}

sha512sums="
e8b4c05513537655d20c346f4e330a8dbb3509623be7c571f28aa5105e7475892458140a187dc63e9ef566eb460cc4252ffa752694fca3bc0fe7ee31b840969d  qtwebsockets-everywhere-src-6.8.2.tar.xz
"
