# 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.8.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="
	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 --output-on-failure -E "$skipped_tests"
}

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

sha512sums="
dab4c499f742c2405589feff42b7c931597a8be859372fb6f8878a16b919078fb3086d21ef18d3023fb0260ef181e3d30f31538ca46381c666736ad1fccdfad4  ktexteditor-6.8.0.tar.xz
"
