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

EAPI=8

inherit git-r3
inherit cargo meson

DESCRIPTION="Cross-platform COM implementation"
HOMEPAGE="https://git.dblsaiko.net/nucom/about"
EGIT_REPO_URI="https://git.dblsaiko.net/nucom"

LICENSE="LGPL-3"
# Dependent crate licenses
LICENSE+=" Apache-2.0 CC0-1.0 MIT Unicode-DFS-2016"
SLOT="0"
IUSE="runtime swift gnustep"

RDEPEND="
	runtime? (
		gnustep? ( gnustep-base/gnustep-base )
		!gnustep? (
			app-pda/libplist
			dev-libs/icu
		)
	)
	swift? ( dev-lang/swift:= )"
DEPEND="${RDEPEND}"

src_unpack() {
	git-r3_src_unpack
	cd "${P}" || die
	meson subprojects download || die
}

_use_yn() {
	usex "$1" "-D${2-$1}=yes" "-D${2-$1}=no"
}

src_configure() {
	local emesonargs=(
		$(_use_yn runtime with_runtime)
		$(_use_yn swift with_swift)
		$(_use_yn gnustep with_cocoa)
	)
	meson_src_configure
}