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

EAPI=8

# GNOME 51 mirror ahead of ::gentoo; drop each tag below when ::gentoo reaches this version
# BENTOO-DIVERGENCE: SLOT - 51.0 compat_libversion 20 -> 21, so subslot 3/21
# BENTOO-DIVERGENCE: IUSE - slot-3 vs ::gentoo slot-4 artifact; same as ::gentoo 44.5-r300
# BENTOO-DIVERGENCE: DEPEND - slot-3 vs ::gentoo slot-4 artifact; same as ::gentoo 44.5-r300
# BENTOO-DIVERGENCE: RDEPEND - slot-3 vs ::gentoo slot-4 artifact; same as ::gentoo 44.5-r300
# BENTOO-DIVERGENCE: BDEPEND - slot-3 vs ::gentoo slot-4 artifact; same as ::gentoo 44.5-r300
inherit gnome.org meson xdg

DESCRIPTION="Library with common API for various GNOME modules"
HOMEPAGE="https://gitlab.gnome.org/GNOME/gnome-desktop/"

LICENSE="GPL-2+ LGPL-2+ FDL-1.1+"
SLOT="3/21" # subslot = libgnome-desktop-3 soname version
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86"
IUSE="debug +introspection seccomp systemd udev"

COMMON_DEPEND="
	>=x11-libs/gdk-pixbuf-2.36.5:2[introspection?]
	>=x11-libs/gtk+-3.3.6:3[introspection?]
	>=dev-libs/glib-2.53.0:2
	>=gnome-base/gsettings-desktop-schemas-3.27.0[introspection?]
	x11-misc/xkeyboard-config
	x11-libs/libxkbcommon
	app-text/iso-codes
	systemd? ( sys-apps/systemd:= )
	udev? ( virtual/libudev:= )
	seccomp? ( sys-libs/libseccomp )

	x11-libs/cairo
	introspection? ( >=dev-libs/gobject-introspection-1.82.0-r2:= )
"
DEPEND="${COMMON_DEPEND}
	media-libs/fontconfig
"
RDEPEND="${COMMON_DEPEND}
	seccomp? ( sys-apps/bubblewrap )
	!<gnome-base/gnome-desktop-${PV}:4
"
BDEPEND="
	app-text/docbook-xml-dtd:4.1.2
	>=dev-util/gdbus-codegen-2.80.5-r1
	dev-util/itstool
	>=sys-devel/gettext-0.19.8
	virtual/pkgconfig
"

src_prepare() {
	default
	xdg_environment_reset

	# Don't build manual test programs that will never get run
	sed -i -e "/'test-.*'/d" libgnome-desktop/meson.build || die
}

src_configure() {
	local emesonargs=(
		-Ddesktop_docs=false
		$(meson_use debug debug_tools)
		$(meson_use introspection)
		$(meson_feature udev)
		$(meson_feature systemd)
		-Dgtk_doc=false
		-Dinstalled_tests=false
		-Dbuild_gtk4=false
		-Dqr=disabled # gtk4 absent here but auto-detected on the host; tests/meson.build then needs gnome_qr_dep
		-Dlegacy_library=true
	)
	meson_src_configure
}

src_install() {
	meson_src_install

	rm -r \
		"${ED}"/usr/share/locale \
		|| die
}