# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-frameworks
maintainer="team/kde <bribbers@disroot.org>"
pkgname=ktexteditor
pkgver=6.13.0
pkgrel=0
pkgdesc="Advanced embeddable text editor"
# armhf blocked by syntax-highlighting
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="
	editorconfig-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
	graphviz
	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_TESTING=ON \
		-DBUILD_QCH=ON
	cmake --build build
}

check() {
	local skipped_tests="(encoding_utf8.txt_diff"
	local tests="
		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_koi8-r.txt_diff
		encoding_one-char-latin-15.txt_diff
		encoding_latin15-with-utf8-bom.txt_diff
		encoding_cp1251.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 -E "$skipped_tests"
}

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

sha512sums="
23dfa2a9262b650ae03e65581bb6826938a6901c160992f6775d94e0ae20f5a4d9a416450ccd85b24b9766a016549a69448464f72d5c1d71e78d1383052af96d  ktexteditor-6.13.0.tar.xz
"
