# Template file for 'python3-PyQt5-webengine'
pkgname=python3-PyQt5-webengine
version=5.15.4
revision=1
wrksrc="PyQtWebEngine-${version}"
build_helper="qmake"
hostmakedepends="pkg-config qt5-qmake python3-PyQt5-devel
 sip python3-PyQt-builder"
makedepends="qt5-declarative-devel qt5-webchannel-devel qt5-location-devel
 qt5-webengine-devel python3-devel python3-PyQt5-devel"
depends="python3-PyQt5>=${version} python3-PyQt5-webchannel>=${version}"
short_desc="Python 3 bindings for the Qt5 toolkit - webengine module"
maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
license="GPL-3.0-only"
homepage="https://www.riverbankcomputing.com/software/pyqtwebengine/intro"
distfiles="${PYPI_SITE}/P/PyQtWebEngine/PyQtWebEngine-${version}.tar.gz"
checksum=cedc28f54165f4b8067652145aec7f732a17eadf6736835852868cf76119cc19
lib32disabled=yes
CXXFLAGS="-I$XBPS_CROSS_BASE/usr/include/python$py3_ver"
CXXFLAGS+=" -I$XBPS_CROSS_BASE/usr/include/qt5/QtWebChannel"

if [ "$XBPS_TARGET_ENDIAN" != le ]; then
	broken="no webengine for big endian"
fi

if [ "$XBPS_WORDSIZE" != "$XBPS_TARGET_WORDSIZE" ]; then
	broken="webengine can be built only if word size matches"
fi

post_extract() {
	rm -rf pyuic/uic/port_v2
}

do_configure() {
	mkdir -p build
	sip-build --no-make \
		--api-dir /usr/share/qt5/qsci/api/python \
		--build-dir build

	if [ "$CROSS_BUILD" ]; then
		# -I/usr/include/python$py3_ver is set by sip-build :(
		find build -name Makefile |
		xargs sed -i "s,-I\\(/usr/include\\),-I$XBPS_CROSS_BASE\\1,g"
	fi
}

do_build() {
	make -C build ${makejobs}
}

do_install() {
	make -C build DESTDIR=${DESTDIR} INSTALL_ROOT=${DESTDIR} install
}

python3-PyQt5-webengine-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove ${py3_sitelib}/PyQt5/bindings
	}
}
