# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: team/kde <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-applications
pkgname=messagelib
pkgver=24.08.1
pkgrel=0
pkgdesc="KDE PIM messaging library"
# armhf blocked by extra-cmake-modules
# armv7, ppc64le, s390x, riscv64 blocked by qt6-qtwebengine
# loongarch64 blocked by pimcommon
arch="all !armv7 !armhf !ppc64le !s390x !riscv64 !loongarch64"
url="https://kontact.kde.org/"
license="LGPL-2.0-only OR LGPL-3.0-only AND GPL-2.0-or-later"
depends_dev="
	akonadi-contacts-dev
	akonadi-dev
	akonadi-mime-dev
	akonadi-search-dev
	gpgme-dev
	grantlee-dev
	grantleetheme-dev
	karchive-dev
	kcodecs-dev
	kcompletion-dev
	kconfig-dev
	kconfigwidgets-dev
	kcontacts-dev
	kdbusaddons-dev
	ki18n-dev
	kiconthemes-dev
	kidentitymanagement-dev
	kio-dev
	kitemviews-dev
	kjobwidgets-dev
	kldap-dev
	kmailtransport-dev
	kmbox-dev
	kmime-dev
	knewstuff-dev
	kpimtextedit-dev
	kservice-dev
	ktextwidgets-dev
	kwidgetsaddons-dev
	kwindowsystem-dev
	kxmlgui-dev
	libgravatar-dev
	libkdepim-dev
	libkleo-dev
	pimcommon-dev
	qca-qt6-dev
	qt6-qtbase-dev
	qt6-qtwebengine-dev
	sonnet-dev
	syntax-highlighting-dev
	"
makedepends="$depends_dev
	doxygen
	extra-cmake-modules
	graphviz
	samurai
	"
checkdepends="
	dbus
	procps-ng
	xvfb-run
	"
subpackages="$pkgname-dev $pkgname-lang"
_repo_url="https://invent.kde.org/pim/messagelib.git"
source="https://download.kde.org/stable/release-service/$pkgver/src/messagelib-$pkgver.tar.xz"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_QCH=ON
	cmake --build build
}

check() {
	local skipped_tests="("
	local tests="
		mimetreeparser-bodypartformatterbasefactory
		messageviewer-scamwebenginedetection-scamdetectionwebengine
		messageviewer-messageparttheme-objecttreeparser
		messageviewer-messageparttheme-render
		messageviewer-messageparttheme-unencryptedmessage
		messageviewer-messageparttheme-showonlymimepart
		messageviewer-dkimchecksignaturejob
		akonadi-mysql-viewer
		akonadi-sqlite-viewer
		templateparser-templateextracttextfrommail
		templateparser-templateextracthtmlelementfrommail
		templateparser-templateparserjob
		messagecomposer-messagefactoryng
		messagecomposer-replystrategy
		messagecomposer-cryptocomposer
		messagecomposer-composerviewbase
		messagecore-autocryptrecipient
		messageviewer-webengine-webengineaccesskeyanchorfromhtml
		webengineviewer-findbar-findbarbase
		webengineview-createdatabasefilejob
		"
	for test in $tests; do
		skipped_tests="$skipped_tests|$test"
	done
	skipped_tests="$skipped_tests)test"

	dbus-run-session xvfb-run ctest --test-dir build --output-on-failure -E "$skipped_tests"
}

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

sha512sums="
df92ccbb9031f3db319f3d174bb30375231f2982d78bd783b0e7e6e856dc7710af1a52ccbeed07095541a1d41df740f44ac7127477f3196128e02b7fe81a3ff1  messagelib-24.08.1.tar.xz
"
