# Template file for 'qt6-declarative'
pkgname=qt6-declarative
version=6.3.0
revision=1
wrksrc="qtdeclarative-everywhere-src-${version}"
build_style=cmake
configure_args=" -DQT_HOST_PATH=/usr"
hostmakedepends="qt6-base-devel perl pkg-config wayland-devel
 qt6-shadertools-devel"
makedepends="qt6-base-devel Vulkan-Headers"
short_desc="Cross-platform application and UI framework - Declarative"
maintainer="John <me@johnnynator.dev>"
license="GPL-3.0-only with Qt-GPL-exception-1.0, LGPL-3.0-only, GPL-2.0-or-later"
homepage="https://www.qt.io"
distfiles="https://download.qt.io/official_releases/qt/${version%.*}/${version}/submodules/qtdeclarative-everywhere-src-${version}.tar.xz"
checksum=d294b029dc2b2d4f65da516fdc3b8088d32643eb7ff77db135a8b9ce904caa37
replaces="qt6-quickcontrols2>=0"

if [ "$CROSS_BUILD" ]; then
	configure_args+=" -DQT_BUILD_TOOLS_WHEN_CROSSCOMPILING=true"
	hostmakedepends+=" qt6-declarative-devel"
fi

if [ "$XBPS_CHECK_PKGS" ]; then
	configure_args+=" -DQT_BUILD_TESTS=ON"
fi

if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
	broken="shader compilation fails"
fi

pre_check() {
	export QML2_IMPORT_PATH="$wrksrc/build/lib/qt6/qml"
}

do_check() {
	cd build
	ctest -E '(tst_qqmllocale|text|tst_qquickwidget)'
}

qt6-declarative-tools_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - tools"
	pkg_install() {
		vmove usr/lib/qt6/plugins/qmltooling
		for bin in qmlcachegen qmlimportscanner qmltyperegistrar; do
			vmove usr/lib/qt6/libexec/$bin
		done
		for bin in qmlformat qmllint qmlpreview qmlprofiler; do
			vmove usr/lib/qt6/bin/$bin
		done
	}
}

qt6-declarative-devel_package() {
	depends="${sourcepkg}>=${version}_${revision} qt6-base-devel>=${version}_1
	 qt6-declarative-tools>=${version}_${revision}"
	short_desc+=" - development files"
	replaces="qt6-quickcontrols2-devel>=0"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/cmake
		vmove usr/lib/qt6/mkspecs
		vmove "usr/lib/libQt6QuickTest.so.*"
		vmove usr/lib/qt6/qml/QtTest
		vmove usr/lib/qt6/bin/qmltestrunner
		vmove "usr/lib/*.so"
		vmove "usr/lib/*.prl"
	}
}
