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

EAPI=8

inherit meson git-r3

DESCRIPTION="Primitive drawing library targeted at Wayland (maintained fork of wld)"
HOMEPAGE="https://git.sr.ht/~shrub900/neuwld"
EGIT_REPO_URI="https://git.sr.ht/~shrub900/neuwld"

LICENSE="MIT"
SLOT="0"
IUSE="+drm +wayland video_cards_intel video_cards_nouveau"
REQUIRED_USE="
	video_cards_intel? ( drm )
	video_cards_nouveau? ( drm )
"

DEPEND="
	media-libs/fontconfig
	media-libs/freetype
	x11-libs/pixman
	drm? (
		x11-libs/libdrm
		video_cards_intel? ( x11-libs/libdrm[video_cards_intel] )
		video_cards_nouveau? ( x11-libs/libdrm[video_cards_nouveau] )
	)
	wayland? ( dev-libs/wayland )
"
RDEPEND="${DEPEND}"
BDEPEND="
	dev-util/wayland-scanner
	virtual/pkgconfig
"

src_configure() {
	local -a drivers=()
	use video_cards_intel && drivers+=( intel )
	use video_cards_nouveau && drivers+=( nouveau )

	local emesonargs=(
		$(meson_feature drm)
		$(meson_feature wayland)
		-Ddoxygen=disabled
		-Ddrivers="$(IFS=,; echo "${drivers[*]:-[]}")"
	)
	meson_src_configure
}