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

# Autogenerated by pycargoebuild 0.15.0

EAPI=8

CRATES="
	aho-corasick@1.1.3
	autocfg@1.4.0
	bitflags@2.9.4
	block@0.1.6
	cairo-rs@0.21.1
	cairo-sys-rs@0.21.1
	cc@1.2.1
	cfg-expr@0.17.1
	equivalent@1.0.1
	field-offset@0.3.6
	futures-channel@0.3.31
	futures-core@0.3.31
	futures-executor@0.3.31
	futures-io@0.3.31
	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@0.10.0
	gettext-rs@0.7.2
	gettext-sys@0.22.5
	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.1
	heck@0.5.0
	indexmap@2.6.0
	lazy_static@1.5.0
	libadwaita-sys@0.8.0
	libadwaita@0.8.1
	libc@0.2.162
	locale_config@0.3.0
	malloc_buf@0.0.6
	memchr@2.7.5
	memoffset@0.9.1
	objc-foundation@0.1.1
	objc@0.2.7
	objc_id@0.1.1
	pango-sys@0.21.1
	pango@0.21.1
	pin-project-lite@0.2.15
	pin-utils@0.1.0
	pkg-config@0.3.32
	proc-macro-crate@3.3.0
	proc-macro2@1.0.101
	quote@1.0.37
	regex-automata@0.4.9
	regex-syntax@0.8.5
	regex@1.11.1
	rustc_version@0.4.1
	semver@1.0.23
	serde@1.0.215
	serde_derive@1.0.215
	serde_spanned@0.6.9
	shlex@1.3.0
	slab@0.4.9
	smallvec@1.15.1
	syn@2.0.106
	system-deps@7.0.3
	target-lexicon@0.12.16
	temp-dir@0.1.14
	toml@0.8.19
	toml_datetime@0.6.11
	toml_edit@0.22.27
	unicode-ident@1.0.13
	version-compare@0.2.0
	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-targets@0.52.6
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_msvc@0.52.6
	windows_i686_gnu@0.52.6
	windows_i686_gnullvm@0.52.6
	windows_i686_msvc@0.52.6
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_msvc@0.52.6
	winnow@0.7.13
"

RUST_MIN_VER="1.83"

inherit cargo gnome2-utils meson systemd verify-sig virtualx xdg

MY_PN="PhoshFileSelector"
MY_P="${MY_PN}-${PV}"
DESCRIPTION="Phosh File Selector library for selecting files"
HOMEPAGE="https://gitlab.gnome.org/World/Phosh/pfs"
SRC_URI="https://sources.phosh.mobi/releases/${MY_PN}/${MY_P}.tar.xz
	verify-sig? ( https://sources.phosh.mobi/releases/${MY_PN}/${MY_P}.tar.xz.asc )
	${CARGO_CRATE_URIS}"
S="${WORKDIR}/${MY_P}"

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

RDEPEND="
	>=dev-libs/glib-2.74:2
	>=gnome-base/gsettings-desktop-schemas-47
	>=gui-libs/gtk-4.12:4
	>=gui-libs/libadwaita-1.6:1
"
# sys crates
DEPEND="${RDEPEND}
	media-libs/graphene
	x11-libs/cairo
	x11-libs/gdk-pixbuf:2
	x11-libs/pango
"
BDEPEND="
	dev-libs/glib:2
	dev-util/patchelf
	sys-devel/gettext
	verify-sig? ( >=sec-keys/openpgp-keys-phosh-2025 )
"

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

EMESON_BUILDTYPE="release"

QA_FLAGS_IGNORED="
	usr/bin/.*
	usr/lib.*/libpfs.*
"

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

src_configure() {
	unset RUSTC_WRAPPER
	local emesonargs=(
		$(meson_use test examples)
		-Dshared-lib=true
		-Dsystemd_user_unit_dir="$(systemd_get_userunitdir)"
	)

	meson_src_configure
	ln -s "${CARGO_HOME}" "${BUILD_DIR}/cargo-home" || die
}

src_compile() {
	cargo_env meson_src_compile
}

src_test() {
	local -x PFS_RESOURCE_DIR="${BUILD_DIR}/src"
	virtx cargo_src_test
}

pkg_postinst() {
	xdg_pkg_postinst
	gnome2_schemas_update
}

pkg_postrm() {
	xdg_pkg_postrm
	gnome2_schemas_update
}
