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

# Autogenerated by pycargoebuild 0.14.0

EAPI=8

CRATES="
"

# Name before the move
MY_PN="wlx-overlay-s"

declare -A GIT_CRATES=(
	[libmonado]='https://github.com/technobaboo/libmonado-rs;256895b18c8f9368174fad8a6232ff07764eeacb;libmonado-rs-%commit%'
	[libspa-sys]='https://gitlab.freedesktop.org/galister/pipewire-rs;ba32202c3c391004c3bb533b58fa75a50e47ff57;pipewire-rs-%commit%/libspa-sys;gitlab'
	[libspa]='https://gitlab.freedesktop.org/galister/pipewire-rs;ba32202c3c391004c3bb533b58fa75a50e47ff57;pipewire-rs-%commit%/libspa;gitlab'
	[openxr-sys]='https://github.com/galister/openxrs;af4a55df60125491c80c61464c824219c6019b76;openxrs-%commit%/sys'
	[openxr]='https://github.com/galister/openxrs;af4a55df60125491c80c61464c824219c6019b76;openxrs-%commit%/openxr'
	[ovr_overlay]='https://github.com/galister/ovr_overlay_oyasumi;49b0d856c282d1f696b87e85a55674f4db913872;ovr_overlay_oyasumi-%commit%'
	[ovr_overlay_sys]='https://github.com/galister/ovr_overlay_oyasumi;49b0d856c282d1f696b87e85a55674f4db913872;ovr_overlay_oyasumi-%commit%/sys'
	[pipewire-sys]='https://gitlab.freedesktop.org/galister/pipewire-rs;ba32202c3c391004c3bb533b58fa75a50e47ff57;pipewire-rs-%commit%/pipewire-sys;gitlab'
	[pipewire]='https://gitlab.freedesktop.org/galister/pipewire-rs;ba32202c3c391004c3bb533b58fa75a50e47ff57;pipewire-rs-%commit%/pipewire;gitlab'
	[wayvr_ipc]='https://github.com/olekolek1000/wayvr-ipc;a72587d23f3bb8624d9aeb1f13c0a21e65350f51;wayvr-ipc-%commit%'
	[wlx-capture]='https://github.com/galister/wlx-capture;c68c66d487ef0f57bab23b5c780472a31a01ecab;wlx-capture-%commit%'
)

LLVM_COMPAT=({15..19})

inherit cargo llvm-r2 desktop

DESCRIPTION="A lightweight OpenXR/OpenVR overlay for Wayland and X11 desktops"
HOMEPAGE="https://github.com/wlx-team/wayvr"
SRC_URI="
	${CARGO_CRATE_URIS}
	https://github.com/wlx-team/wayvr/archive/refs/tags/v${PV}.tar.gz -> ${MY_PN}-${PV}.tar.gz
	https://github.com/wlx-team/wayvr/releases/download/v${PV}/WlxOverlay-S-v${PV}-crates.tar.xz
"

S="${WORKDIR}/${MY_PN}-${PV}"

LICENSE="GPL-3"
# Dependent crate licenses
LICENSE+="
	0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD CC0-1.0
	GPL-3 ISC MIT Unicode-3.0 Unlicense ZLIB
"
SLOT="0"
KEYWORDS="~amd64"

REQUIRED_USE="
	|| ( openvr openxr )
	|| ( wayland X )
	wayland? ( pipewire )
"

IUSE="+openvr +openxr +wayland +X +pipewire +osc"

DEPEND="
	media-libs/alsa-lib
	media-libs/shaderc
	media-libs/fontconfig
	sys-apps/dbus
	media-libs/freetype
	X? (
		x11-libs/libxcb
		x11-libs/libxkbcommon[X]
		x11-libs/libX11
		x11-libs/libXext
		x11-libs/libXrandr
	)
	openvr? (
		=media-libs/openvr-1.23.8-r0
	)
	openxr? (
		media-libs/openxr-loader[X?,wayland?]
	)
	pipewire? (
		media-video/pipewire
	)
	wayland? (
		x11-libs/libxkbcommon[wayland]
	)
	$(llvm_gen_dep '
		llvm-core/clang:${LLVM_SLOT}=
	')
"
BDEPEND="
	virtual/pkgconfig
"
RDEPEND="${DEPEND}"

pkg_setup() {
	export PKG_CONFIG_ALLOW_CROSS=1
	export OPENVR_NO_VENDOR=1
	rust_pkg_setup
}

src_configure() {
	echo $ECARGO_HOME
	local myfeatures=(
		$(usev openvr)
		$(usev openxr)
		$(usev wayland)
		$(usev X x11)
		$(usev pipewire)
		$(usev osc)
	)
	cargo_src_configure --no-default-features
}

src_install() {
	doicon --size 256 wlx-overlay-s.png
	doicon --size scalable wlx-overlay-s.svg
	domenu wlx-overlay-s.desktop
	cargo_src_install
}
