# 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-frameworks
pkgname=ktexteditor
pkgver=6.5.0
pkgrel=0
pkgdesc="Advanced embeddable text editor"
# armhf blocked by extra-cmake-modules
arch="all !armhf"
url="https://community.kde.org/Frameworks"
license="LGPL-2.0-or-later AND (LGPL-2.0-only OR LGPL-3.0-only)"
depends_dev="
	karchive-dev
	kauth-dev
	kconfig-dev
	kguiaddons-dev
	ki18n-dev
	kiconthemes-dev
	kio-dev
	kparts-dev
	sonnet-dev
	syntax-highlighting-dev
	"
makedepends="$depends_dev
	doxygen
	extra-cmake-modules
	qt6-qttools-dev
	samurai
	"
checkdepends="xvfb-run"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
_repo_url="https://invent.kde.org/frameworks/ktexteditor.git"
source="https://download.kde.org/stable/frameworks/${pkgver%.*}/ktexteditor-$pkgver.tar.xz"

replaces="ktexteditor5"

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="
		encoding_utf8.txt_diff
		encoding_latin15.txt_diff
		encoding_utf32.txt_diff
		encoding_utf16.txt_diff
		encoding_utf32be.txt_diff
		encoding_utf16be.txt_diff
		encoding_cyrillic_utf8.txt_diff
		encoding_cp1251.txt_diff
		encoding_koi8-r.txt_diff
		encoding_one-char-latin-15.txt_diff
		encoding_latin15-with-utf8-bom.txt_diff
		"
	case "$CARCH" in
		s390x) tests="$tests
			encodingtest
			messagetest
			" ;;
	esac
	for test in $tests; do
		skipped_tests="$skipped_tests|$test"
	done
	skipped_tests="$skipped_tests)"
	xvfb-run ctest --test-dir build --output-on-failure -E "$skipped_tests"
}

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

sha512sums="
848e552b06432564fdda4667f13f514632610df50914721c0784287fe9b0f17bf50c0f8bba562d27fe9ecf6d1fa8090d2e0c419b74c8e01d668c218a45385115  ktexteditor-6.5.0.tar.xz
"
