# Copyright 2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Autogenerated by pycargoebuild 0.15.0

EAPI=8

RUST_MIN_VER="1.86.0"
CARGO_OPTIONAL=1

CRATES="
	addr2line@0.24.2
	adler2@2.0.1
	aho-corasick@1.1.3
	ashpd@0.12.0
	async-broadcast@0.7.2
	async-recursion@1.1.1
	async-trait@0.1.88
	autocfg@1.5.0
	backtrace@0.3.75
	bitflags@2.9.1
	block@0.1.6
	bytes@1.10.1
	cairo-rs@0.21.1
	cairo-sys-rs@0.21.1
	cc@1.2.30
	cfg-expr@0.20.1
	cfg-if@1.0.1
	cfg_aliases@0.2.1
	concurrent-queue@2.5.0
	crossbeam-utils@0.8.21
	displaydoc@0.2.5
	endi@1.1.0
	enumflags2@0.7.12
	enumflags2_derive@0.7.12
	equivalent@1.0.2
	errno@0.3.13
	event-listener-strategy@0.5.4
	event-listener@5.4.0
	fastrand@2.3.0
	field-offset@0.3.6
	form_urlencoded@1.2.1
	futures-channel@0.3.31
	futures-core@0.3.31
	futures-executor@0.3.31
	futures-io@0.3.31
	futures-lite@2.6.0
	futures-macro@0.3.31
	futures-task@0.3.31
	futures-util@0.3.31
	gdk-pixbuf-sys@0.21.1
	gdk-pixbuf@0.21.1
	gdk4-sys@0.10.0
	gdk4-wayland-sys@0.10.0
	gdk4-wayland@0.10.0
	gdk4-x11-sys@0.10.0
	gdk4-x11@0.10.0
	gdk4@0.10.0
	getrandom@0.3.3
	gettext-rs@0.7.2
	gettext-sys@0.22.5
	gimli@0.31.1
	gio-sys@0.21.1
	gio@0.21.1
	glib-macros@0.21.0
	glib-sys@0.21.1
	glib@0.21.1
	gobject-sys@0.21.1
	graphene-rs@0.21.1
	graphene-sys@0.21.1
	gsk4-sys@0.10.0
	gsk4@0.10.0
	gtk4-macros@0.10.0
	gtk4-sys@0.10.0
	gtk4@0.10.0
	hashbrown@0.15.4
	heck@0.5.0
	hex@0.4.3
	icu_collections@2.0.0
	icu_locale_core@2.0.0
	icu_normalizer@2.0.0
	icu_normalizer_data@2.0.0
	icu_properties@2.0.1
	icu_properties_data@2.0.1
	icu_provider@2.0.0
	idna@1.0.3
	idna_adapter@1.2.1
	indexmap@2.10.0
	io-uring@0.7.9
	lazy_static@1.5.0
	libadwaita-sys@0.8.0
	libadwaita@0.8.0
	libc@0.2.174
	linux-raw-sys@0.9.4
	litemap@0.8.0
	locale_config@0.3.0
	malloc_buf@0.0.6
	memchr@2.7.5
	memoffset@0.9.1
	miniz_oxide@0.8.9
	mio@1.0.4
	nix@0.30.1
	objc-foundation@0.1.1
	objc@0.2.7
	objc_id@0.1.1
	object@0.36.7
	once_cell@1.21.3
	ordered-stream@0.2.0
	pango-sys@0.21.1
	pango@0.21.1
	parking@2.2.1
	percent-encoding@2.3.1
	pin-project-lite@0.2.16
	pin-utils@0.1.0
	pkg-config@0.3.32
	potential_utf@0.1.2
	ppv-lite86@0.2.21
	proc-macro-crate@3.3.0
	proc-macro2@1.0.95
	quote@1.0.40
	r-efi@5.3.0
	rand@0.9.2
	rand_chacha@0.9.0
	rand_core@0.9.3
	regex-automata@0.4.9
	regex-syntax@0.8.5
	regex@1.11.1
	rustc-demangle@0.1.25
	rustc_version@0.4.1
	rustix@1.0.8
	semver@1.0.26
	serde@1.0.219
	serde_derive@1.0.219
	serde_repr@0.1.20
	serde_spanned@0.6.9
	shlex@1.3.0
	signal-hook-registry@1.4.5
	slab@0.4.10
	smallvec@1.15.1
	socket2@0.5.10
	stable_deref_trait@1.2.0
	static_assertions@1.1.0
	syn@2.0.104
	synstructure@0.13.2
	system-deps@7.0.5
	target-lexicon@0.13.2
	temp-dir@0.1.16
	tempfile@3.20.0
	tinystr@0.8.1
	tokio@1.46.1
	toml@0.8.23
	toml_datetime@0.6.11
	toml_edit@0.22.27
	tracing-attributes@0.1.30
	tracing-core@0.1.34
	tracing@0.1.41
	uds_windows@1.1.0
	unicode-ident@1.0.18
	url@2.5.4
	utf8_iter@1.0.4
	version-compare@0.2.0
	wasi@0.11.1+wasi-snapshot-preview1
	wasi@0.14.2+wasi-0.2.4
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-sys@0.52.0
	windows-sys@0.59.0
	windows-sys@0.60.2
	windows-targets@0.52.6
	windows-targets@0.53.2
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_gnullvm@0.53.0
	windows_aarch64_msvc@0.52.6
	windows_aarch64_msvc@0.53.0
	windows_i686_gnu@0.52.6
	windows_i686_gnu@0.53.0
	windows_i686_gnullvm@0.52.6
	windows_i686_gnullvm@0.53.0
	windows_i686_msvc@0.52.6
	windows_i686_msvc@0.53.0
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnu@0.53.0
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_gnullvm@0.53.0
	windows_x86_64_msvc@0.52.6
	windows_x86_64_msvc@0.53.0
	winnow@0.7.12
	wit-bindgen-rt@0.39.0
	writeable@0.6.1
	x11@2.21.0
	yoke-derive@0.8.0
	yoke@0.8.0
	zbus@5.9.0
	zbus_macros@5.9.0
	zbus_names@4.2.0
	zerocopy-derive@0.8.27
	zerocopy@0.8.27
	zerofrom-derive@0.1.6
	zerofrom@0.1.6
	zerotrie@0.2.2
	zerovec-derive@0.11.1
	zerovec@0.11.2
	zvariant@5.6.0
	zvariant_derive@5.6.0
	zvariant_utils@3.2.0
"

inherit cargo meson systemd verify-sig xdg

DESCRIPTION="Phosh portal backend for xdg-desktop-portal"
HOMEPAGE="https://gitlab.gnome.org/World/Phosh/xdg-desktop-portal-phosh"
SRC_URI="https://sources.phosh.mobi/releases/${PN}/${P}.tar.xz
	rust? ( ${CARGO_CRATE_URIS} )
	verify-sig? ( https://sources.phosh.mobi/releases/${PN}/${P}.tar.xz.asc )"

LICENSE="GPL-3+"
# Dependent crate licenses
LICENSE+=" Apache-2.0 Apache-2.0-with-LLVM-exceptions MIT Unicode-3.0"
SLOT="0"
KEYWORDS="~amd64"
IUSE="+rust"

DEPEND="
	>=dev-libs/glib-2.76:2
	>=gnome-base/gnome-desktop-43:4=
	>=gnome-base/gsettings-desktop-schemas-47
	>=gui-libs/gtk-4.12:4[wayland]
	>=gui-libs/libadwaita-1.6:1
	media-libs/fontconfig:1.0
	phosh-base/pfs
	sys-apps/dbus
	>=sys-apps/xdg-desktop-portal-1.19.1
	x11-libs/cairo
	x11-libs/gdk-pixbuf:2
	virtual/libintl
	rust? (
		gui-libs/gtk:4[X]
		x11-libs/libX11
	)
"
RDEPEND="${DEPEND}
	!<phosh-base/phosh-shell-0.44.0
"
BDEPEND="
	dev-libs/glib:2
	dev-util/gdbus-codegen
	sys-devel/gettext
	virtual/pkgconfig
	rust? ( ${RUST_DEPEND} )
	verify-sig? ( sec-keys/openpgp-keys-phosh )
"

PATCHES=( "${FILESDIR}"/${PN}-0.50.0-use-pfs-subproject.patch )

VERIFY_SIG_OPENPGP_KEY_PATH="/usr/share/openpgp-keys/phosh.asc"

EMESON_BUILDTYPE="release"

QA_FLAGS_IGNORED="usr/libexec/xdg-desktop-portal-phrosh"

src_unpack() {
	use verify-sig &&
		verify-sig_verify_detached "${DISTDIR}"/${P}.tar.xz{,.asc}

	if use rust; then
		cargo_src_unpack
	else
		default
	fi
}

src_configure() {
	unset RUSTC_WRAPPER
	local emesonargs=(
		-Dsystemd_user_unit_dir="$(systemd_get_userunitdir)"
		$(meson_use rust rust-portal)
	)

	meson_src_configure
	if use rust; then
		ln -s "${CARGO_HOME}" "${BUILD_DIR}/cargo" || die
	fi
}

src_compile() {
	$(usex rust cargo_env "") meson_src_compile
}

src_test() {
	$(usex rust cargo_env "") meson_src_test -t 10
}
