# Contributor: Rasmus Thomsen <oss@cogitri.dev>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-plasma
maintainer="team/kde <bribbers@disroot.org>"
pkgname=xdg-desktop-portal-kde
pkgver=6.2.4
pkgrel=0
pkgdesc="A backend implementation for xdg-desktop-portal that is using Qt/KDE"
# armhf blocked by extra-cmake-modules
arch="all !armhf"
url="https://phabricator.kde.org/source/xdg-desktop-portal-kde"
license="LGPL-2.0-or-later"
depends="xdg-desktop-portal"
makedepends="
	cups-dev
	extra-cmake-modules
	glib-dev
	kcoreaddons-dev
	kdeclarative-dev
	kio-dev
	kirigami-dev
	kstatusnotifieritem-dev
	kwayland-dev>=$pkgver
	libepoxy-dev
	pipewire-dev
	libplasma-dev
	plasma-wayland-protocols
	qt6-qtbase-dev
	samurai
	xdg-desktop-portal-dev
	"
checkdepends="
	dbus-x11
	py3-gobject3
	xvfb-run
	"
subpackages="$pkgname-lang"

case "$pkgver" in
	*.90*) _rel=unstable;;
	*) _rel=stable;;
esac
_repo_url="https://invent.kde.org/plasma/xdg-desktop-portal-kde.git"
source="https://download.kde.org/$_rel/plasma/$pkgver/xdg-desktop-portal-kde-$pkgver.tar.xz"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DKDE_INSTALL_LIBEXECDIR=libexec
	cmake --build build
}

check() {
	# colorschemetest requires the package itself installed
	xvfb-run -a ctest --test-dir build --output-on-failure -E "colorschemetest"
}

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

	rm -rf "$pkgdir"/usr/lib/systemd
}

sha512sums="
b6f2c4d7044ad5a16e71db39e9ce8f074aa1e12f34de9377b08f711fc5ffb4f2d8a79ce29bcb220eb9888a0db3783cac68d0a69de5087ac910f73a20a77ee557  xdg-desktop-portal-kde-6.2.4.tar.xz
"
