# Template file for 'AppStream'
pkgname=AppStream
version=1.0.2
revision=2
build_style=meson
build_helper="gir qemu"
configure_args="$(vopt_bool gir gir) $(vopt_bool vala vapi)
 -Dstemming=false -Dapidocs=false -Dqt=true -Dsystemd=false
 -Dcompose=true"
hostmakedepends="docbook-xsl gettext glib-devel gperf libxslt pkg-config
 qt6-base $(vopt_if vala vala) itstool"
makedepends="libglib-devel libxml2-devel libyaml-devel qt6-base-devel libxmlb-devel
 libcurl-devel librsvg-devel"
checkdepends="tar"
short_desc="Tools and libraries to work with AppStream metadata"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later"
homepage="https://github.com/ximion/appstream"
changelog="https://raw.githubusercontent.com/ximion/appstream/master/NEWS"
distfiles="https://github.com/ximion/appstream/archive/v${version}.tar.gz"
checksum=77e271f47167ae37a68111b951c3c07e4261579e69047747044f7924c8219d14
triggers="appstream-cache"

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" AppStream-devel"
fi

build_options="gir vala"
build_options_default="gir vala"

pre_configure() {
	# Meson uses paths from pkg-config which is /usr/lib32/qt6 when cross compiling 32-bit
	# Work around this for now
	export PATH="/usr/lib/qt6/libexec/:$PATH"
}

AppStream-devel_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include/appstream
		vmove usr/lib/pkgconfig/appstream.pc
		vmove /usr/lib/libappstream.so
		if [ "$build_option_gir" ]; then
			vmove usr/share/gir-1.0/AppStream-1.0.gir
		fi
		if [ "$build_option_vala" ]; then
			vmove "usr/share/vala/vapi/appstream.*"
		fi
	}
}

AppStream-compose_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - compose libraries and tools"
	pkg_install() {
		vmove usr/libexec/appstreamcli-compose
		vmove "usr/share/man/man1/appstreamcli-compose.*"
		vmove "usr/lib/libappstream-compose.so.*"
		vmove usr/lib/girepository-1.0/AppStreamCompose-1.0.typelib
		vmove usr/share/metainfo/org.freedesktop.appstream.compose.metainfo.xml
	}
}

AppStream-compose-devel_package() {
	depends="AppStream-compose>=${version}_${revision} AppStream-devel>=${version}_${revision}"
	short_desc+=" - compose development files"
	pkg_install() {
		vmove usr/include/appstream-compose
		vmove usr/lib/pkgconfig/appstream-compose.pc
		vmove /usr/lib/libappstream-compose.so
		if [ "$build_option_gir" ]; then
			vmove usr/share/gir-1.0/AppStreamCompose-1.0.gir
		fi
	}
}

AppStream-qt_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - qt6 interface library"
	pkg_install() {
		vmove "usr/lib/libAppStreamQt.so.*"
	}
}

AppStream-qt-devel_package() {
	depends="AppStream-qt>=${version}_${revision}"
	short_desc+=" - qt6 development files"
	pkg_install() {
		vmove usr/include/AppStreamQt
		vmove usr/lib/cmake/AppStreamQt
		vmove usr/lib/libAppStreamQt.so
	}
}
