# Template file for 'libportal'
pkgname=libportal
version=0.10.0
revision=1
build_style=meson
build_helper="gir"
configure_args="$(vopt_bool gtk_doc docs) $(vopt_bool gir vapi)
 -Dbackend-gtk3=enabled -Dbackend-gtk4=enabled -Dbackend-qt6=enabled"
hostmakedepends="pkgconf glib-devel gobject-introspection $(vopt_if gir vala)
 $(vopt_if gtk_doc gi-docgen)"
makedepends="glib-devel gobject-introspection gtk+3-devel gtk4-devel
 qt6-base-devel qt6-base-private-devel"
checkdepends="python3-dbusmock python3-pytest xvfb-run"
short_desc="Flatpak portal library"
maintainer="Orphaned <orphan@voidlinux.org>"
license="LGPL-3.0-only"
homepage="https://github.com/flatpak/libportal"
changelog="https://raw.githubusercontent.com/flatpak/libportal/refs/heads/main/NEWS"
distfiles="https://github.com/flatpak/libportal/releases/download/${version}/libportal-${version}.tar.xz"
checksum=1c74a3f7becbd4ff745d7f565afd06e97e50eb080a0e268cb14bb55289a745bf

make_check_pre="xvfb-run"

build_options="gir gtk_doc"
build_options_default="gir gtk_doc"

if [ "$CROSS_BUILD" ]; then
	configure_args+=" -Dtests=false"
fi

libportal-devel_package() {
	depends="libportal>=${version}_${revision} glib-devel"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include/libportal
		vmove "usr/lib/libportal.so"
		vmove usr/lib/pkgconfig/libportal.pc
		if [ "$build_option_gtk_doc" ]; then
			vmove usr/share/doc
		fi
		if [ "$build_option_gir" ]; then
			vmove usr/share/gir-1.0/Xdp-1.0.gir
			vmove "usr/share/vala/vapi/libportal.*"
		fi
	}
}

libportal-gtk3_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - GTK3"
	pkg_install() {
		vmove "usr/lib/libportal-gtk3.so.*"
		if [ "$build_option_gir" ]; then
			vmove "usr/lib/girepository-1.0/XdpGtk3*"
		fi
	}
}

libportal-gtk3-devel_package() {
	depends="libportal-gtk3>=${version}_${revision} libportal-devel>=${version}_${revision} glib-devel gtk+3-devel"
	short_desc+=" - GTK3 - development files"
	pkg_install() {
		vmove usr/include/libportal-gtk3
		vmove "usr/lib/libportal-gtk3.so"
		vmove usr/lib/pkgconfig/libportal-gtk3.pc
		if [ "$build_option_gir" ]; then
			vmove usr/share/gir-1.0/XdpGtk3*
			vmove "usr/share/vala/vapi/libportal-gtk3*"
		fi
	}
}

libportal-gtk4_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - GTK4"
	pkg_install() {
		vmove "usr/lib/libportal-gtk4.so.*"
		if [ "$build_option_gir" ]; then
			vmove "usr/lib/girepository-1.0/XdpGtk4*"
		fi
	}
}

libportal-gtk4-devel_package() {
	depends="libportal-gtk4>=${version}_${revision} libportal-devel>=${version}_${revision} glib-devel gtk4-devel"
	short_desc+=" - GTK4 - development files"
	pkg_install() {
		vmove usr/include/libportal-gtk4
		vmove "usr/lib/libportal-gtk4.so"
		vmove usr/lib/pkgconfig/libportal-gtk4.pc
		if [ "$build_option_gir" ]; then
			vmove "usr/share/gir-1.0/XdpGtk4*"
			vmove "usr/share/vala/vapi/libportal-gtk4*"
		fi
	}
}

libportal-qt6_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - Qt6"
	pkg_install() {
		vmove "usr/lib/libportal-qt6.so.*"
	}
}

libportal-qt6-devel_package() {
	depends="libportal-devel>=${version}_${revision}
	 libportal-qt6>=${version}_${revision} qt6-base-devel"
	short_desc+=" - Qt6 - development files"
	pkg_install() {
		vmove usr/include/libportal-qt6
		vmove usr/lib/libportal-qt6.so
		vmove usr/lib/pkgconfig/libportal-qt6.pc
	}
}
