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

EAPI=8

CRATES="
	why2@1.5.1
	ab_glyph@0.2.32
	ab_glyph_rasterizer@0.1.10
	adler2@2.0.1
	ahash@0.8.12
	aho-corasick@1.1.4
	alloca@0.4.0
	allocator-api2@0.2.21
	alsa@0.11.0
	alsa-sys@0.4.0
	android-activity@0.6.1
	android-properties@0.2.2
	android_system_properties@0.1.5
	anes@0.1.6
	annotate-snippets@0.11.5
	anstyle@1.0.14
	anyhow@1.0.103
	anymap3@1.1.0
	argon2@0.5.3
	array-init@2.1.0
	arrayref@0.3.9
	arrayvec@0.7.8
	ash@0.38.0+1.3.281
	as-raw-xcb-connection@1.0.1
	async-broadcast@0.7.2
	async-channel@2.5.0
	async-executor@1.14.0
	async-io@2.6.0
	async-lock@3.4.2
	async-process@2.5.0
	async-recursion@1.1.1
	async-signal@0.2.14
	async-task@4.7.1
	async-trait@0.1.89
	atomic-waker@1.1.2
	audiopus@0.2.0
	audiopus_sys@0.1.8
	autocfg@1.5.1
	base16ct@1.0.0
	base64@0.22.1
	base64ct@1.8.3
	bindgen@0.72.1
	bitflags@1.3.2
	bitflags@2.13.0
	bit-set@0.9.1
	bit-vec@0.9.1
	blake2@0.10.6
	block2@0.5.1
	block2@0.6.2
	block-buffer@0.10.4
	block-buffer@0.12.1
	blocking@1.6.2
	bumpalo@3.20.3
	bytemuck@1.25.1
	bytemuck_derive@1.11.0
	byteorder@1.5.0
	byteorder-lite@0.1.0
	bytes@1.12.1
	calloop@0.13.0
	calloop-wayland-source@0.3.0
	cast@0.3.0
	cc@1.2.67
	cexpr@0.6.0
	cfg_aliases@0.2.1
	cfg-expr@0.20.8
	cfg-if@1.0.4
	chacha20@0.10.1
	ciborium@0.2.2
	ciborium-io@0.2.2
	ciborium-ll@0.2.2
	clang-sys@1.8.1
	clap@4.6.1
	clap_builder@4.6.0
	clap_lex@1.1.0
	cmov@0.5.4
	codespan-reporting@0.13.1
	colored@3.1.1
	combine@4.6.7
	concurrent-queue@2.5.0
	const-oid@0.10.2
	convert_case@0.10.0
	convert_case@0.8.0
	cookie-factory@0.3.3
	coreaudio-rs@0.14.2
	core-foundation@0.9.4
	core-foundation-sys@0.8.7
	core-graphics@0.23.2
	core-graphics-types@0.1.3
	cpal@0.18.1
	cpubits@0.1.1
	cpufeatures@0.2.17
	cpufeatures@0.3.0
	crc32fast@1.5.0
	criterion@0.8.2
	criterion-plot@0.8.2
	crossbeam-channel@0.5.16
	crossbeam-deque@0.8.7
	crossbeam-epoch@0.9.20
	crossbeam-utils@0.8.22
	crossterm@0.29.0
	crossterm_winapi@0.9.1
	crunchy@0.2.4
	crypto-bigint@0.7.5
	crypto-common@0.1.7
	crypto-common@0.2.2
	ctrlc@3.5.2
	ctutils@0.4.2
	cursor-icon@1.2.0
	darling@0.23.0
	darling_core@0.23.0
	darling_macro@0.23.0
	dashmap@6.2.1
	dasp_sample@0.11.0
	der@0.8.1
	deranged@0.5.8
	derive_more@2.1.1
	derive_more-impl@2.1.1
	digest@0.10.7
	digest@0.11.3
	dirs@6.0.0
	dirs-sys@0.5.0
	dispatch@0.2.0
	dispatch2@0.3.1
	displaydoc@0.2.6
	dlib@0.5.3
	document-features@0.2.12
	downcast-rs@1.2.1
	dpi@0.1.2
	drm@0.14.1
	drm@0.15.0
	drm-ffi@0.9.1
	drm-fourcc@2.2.0
	drm-sys@0.8.1
	easyfft@0.4.2
	ecdsa@0.17.0
	either@1.16.0
	elliptic-curve@0.14.1
	endi@1.1.1
	enumflags2@0.7.12
	enumflags2_derive@0.7.12
	enum-primitive-derive@0.3.0
	equivalent@1.0.2
	errno@0.3.14
	event-listener@5.4.1
	event-listener-strategy@0.5.4
	fastrand@2.4.1
	fdeflate@0.3.7
	ff@0.14.0
	filedescriptor@0.8.3
	find-msvc-tools@0.1.9
	flate2@1.1.9
	foldhash@0.1.5
	foldhash@0.2.0
	foreign-types@0.5.0
	foreign-types-macros@0.2.3
	foreign-types-shared@0.3.1
	form_urlencoded@1.2.2
	futures@0.3.32
	futures-channel@0.3.32
	futures-core@0.3.32
	futures-executor@0.3.32
	futures-io@0.3.32
	futures-lite@2.6.1
	futures-macro@0.3.32
	futures-sink@0.3.32
	futures-task@0.3.32
	futures-util@0.3.32
	gag@1.0.0
	gbm@0.18.0
	gbm-sys@0.4.0
	generic-array@0.14.7
	generic_singleton@0.5.3
	gethostname@1.1.0
	getrandom@0.2.17
	getrandom@0.3.4
	getrandom@0.4.3
	gl@0.14.0
	gl_generator@0.14.0
	glob@0.3.3
	glow@0.17.0
	glutin_wgl_sys@0.6.1
	gpu-allocator@0.28.0
	gpu-descriptor@0.3.2
	gpu-descriptor-types@0.2.0
	group@0.14.0
	half@2.7.1
	hashbrown@0.14.5
	hashbrown@0.15.5
	hashbrown@0.16.1
	hashbrown@0.17.1
	heck@0.5.0
	hermit-abi@0.5.2
	hex@0.4.3
	hexf-parse@0.2.1
	hkdf@0.13.0
	hmac@0.13.0
	http@1.4.2
	httparse@1.10.1
	hybrid-array@0.4.13
	icu_collections@2.2.0
	icu_locale_core@2.2.0
	icu_normalizer@2.2.0
	icu_normalizer_data@2.2.0
	icu_properties@2.2.0
	icu_properties_data@2.2.0
	icu_provider@2.2.0
	ident_case@1.0.1
	idna@1.1.0
	idna_adapter@1.2.2
	image@0.25.10
	indexmap@2.14.0
	itertools@0.13.0
	itoa@1.0.18
	jni@0.22.4
	jni-macros@0.22.4
	jni-sys@0.3.1
	jni-sys@0.4.1
	jni-sys-macros@0.4.1
	jobserver@0.1.35
	js-sys@0.3.103
	keccak@0.2.0
	kem@0.3.0
	khronos_api@3.1.0
	khronos-egl@6.0.0
	lewton@0.10.2
	libc@0.2.186
	libloading@0.8.9
	libm@0.2.16
	libredox@0.1.18
	libspa@0.9.2
	libspa-sys@0.9.2
	libwayshot@0.8.0
	libwayshot-xcap@0.3.2
	linux-raw-sys@0.12.1
	linux-raw-sys@0.4.15
	linux-raw-sys@0.9.4
	litemap@0.8.2
	litrs@1.0.0
	lock_api@0.4.14
	log@0.4.33
	mach2@0.6.0
	memchr@2.8.3
	memmap2@0.9.11
	memoffset@0.9.1
	minimal-lexical@0.2.1
	miniz_oxide@0.8.9
	mio@1.2.2
	ml-kem@0.3.2
	module-lattice@0.2.3
	moxcms@0.8.1
	naga@29.0.4
	nasm-rs@0.3.2
	ndk@0.9.0
	ndk-context@0.1.1
	ndk-sys@0.6.0+11769913
	nix@0.30.1
	nix@0.31.3
	nnnoiseless@0.5.2
	nom@7.1.3
	nom@8.0.0
	num-complex@0.4.6
	num-conv@0.2.2
	num-derive@0.4.2
	num_enum@0.7.6
	num_enum_derive@0.7.6
	num-integer@0.1.46
	num_threads@0.1.7
	num-traits@0.2.19
	objc2@0.5.2
	objc2@0.6.4
	objc2-app-kit@0.2.2
	objc2-app-kit@0.3.2
	objc2-audio-toolbox@0.3.2
	objc2-avf-audio@0.3.2
	objc2-av-foundation@0.3.2
	objc2-cloud-kit@0.2.2
	objc2-cloud-kit@0.3.2
	objc2-contacts@0.2.2
	objc2-core-audio@0.3.2
	objc2-core-audio-types@0.3.2
	objc2-core-data@0.2.2
	objc2-core-data@0.3.2
	objc2-core-foundation@0.3.2
	objc2-core-graphics@0.3.2
	objc2-core-image@0.2.2
	objc2-core-image@0.3.2
	objc2-core-location@0.2.2
	objc2-core-media@0.3.2
	objc2-core-text@0.3.2
	objc2-core-video@0.3.2
	objc2-encode@4.1.0
	objc2-foundation@0.2.2
	objc2-foundation@0.3.2
	objc2-image-io@0.3.2
	objc2-io-surface@0.3.2
	objc2-link-presentation@0.2.2
	objc2-media-toolbox@0.3.2
	objc2-metal@0.2.2
	objc2-metal@0.3.2
	objc2-quartz-core@0.2.2
	objc2-quartz-core@0.3.2
	objc2-symbols@0.2.2
	objc2-ui-kit@0.2.2
	objc2-uniform-type-identifiers@0.2.2
	objc2-user-notifications@0.2.2
	objc-sys@0.3.5
	ogg@0.8.0
	once_cell@1.21.4
	oorandom@11.1.5
	openh264@0.9.7
	openh264-sys2@0.9.7
	option-ext@0.2.0
	orbclient@0.3.55
	ordered-float@5.3.0
	ordered-stream@0.2.0
	owned_ttf_parser@0.25.1
	p521@0.14.0
	page_size@0.6.0
	parking@2.2.1
	parking_lot@0.12.5
	parking_lot_core@0.9.12
	password-hash@0.5.0
	pastey@0.2.3
	pem-rfc7468@1.0.0
	percent-encoding@2.3.2
	pin-project@1.1.13
	pin-project-internal@1.1.13
	pin-project-lite@0.2.17
	piper@0.2.5
	pipewire@0.9.2
	pipewire-sys@0.9.2
	pixels@0.17.1
	pkcs8@0.11.0
	pkg-config@0.3.33
	plain@0.2.3
	plotters@0.3.7
	plotters-backend@0.3.7
	plotters-svg@0.3.7
	png@0.18.1
	polling@3.11.0
	pollster@0.4.0
	portable-atomic@1.13.1
	portable-atomic-util@0.2.7
	potential_utf@0.1.5
	powerfmt@0.2.0
	ppv-lite86@0.2.21
	presser@0.3.1
	primal-check@0.3.4
	primefield@0.14.0
	primeorder@0.14.0
	proc-macro2@1.0.106
	proc-macro-crate@3.5.0
	profiling@1.0.18
	pulseaudio@0.3.1
	pxfm@0.1.30
	quick-xml@0.30.0
	quick-xml@0.39.4
	quote@1.0.46
	rand@0.10.2
	rand@0.9.5
	rand_chacha@0.10.0
	rand_chacha@0.9.0
	rand_core@0.10.1
	rand_core@0.6.4
	rand_core@0.9.5
	range-alloc@0.1.5
	raw-window-handle@0.6.2
	raw-window-metal@1.1.0
	rayon@1.12.0
	rayon-core@1.13.0
	realfft@3.5.0
	redox_syscall@0.4.1
	redox_syscall@0.5.18
	redox_syscall@0.9.0
	redox_users@0.5.2
	r-efi@5.3.0
	r-efi@6.0.0
	regex@1.13.0
	regex-automata@0.4.15
	regex-syntax@0.8.11
	renderdoc-sys@1.1.0
	rfc6979@0.6.0
	ring@0.17.14
	ringbuf@0.5.0
	rustc-hash@1.1.0
	rustc-hash@2.1.3
	rustc_version@0.4.1
	rustfft@6.4.1
	rustix@0.38.44
	rustix@1.1.4
	rustls@0.23.42
	rustls-pki-types@1.15.0
	rustls-webpki@0.103.13
	rustversion@1.0.23
	safe_arch@0.7.4
	safe_arch@1.0.0
	same-file@1.0.6
	scoped-tls@1.0.1
	scopeguard@1.2.0
	sctk-adwaita@0.10.1
	sec1@0.8.1
	semver@1.0.28
	serde@1.0.228
	serde_core@1.0.228
	serdect@0.4.3
	serde_derive@1.0.228
	serde_json@1.0.150
	serde_repr@0.1.20
	serde_spanned@1.1.1
	sha2@0.11.0
	sha3@0.11.0
	shlex@1.3.0
	shlex@2.0.1
	signal-hook@0.3.18
	signal-hook-mio@0.2.5
	signal-hook-registry@1.4.8
	signature@3.0.0
	simd-adler32@0.3.9
	simd_cesu8@1.1.1
	simdutf8@0.1.5
	simple_logger@5.2.0
	slab@0.4.12
	slotmap@1.1.1
	smallvec@1.15.2
	smithay-client-toolkit@0.19.2
	smol_str@0.2.2
	socks@0.3.4
	spirv@0.4.0+sdk-1.4.341.0
	spki@0.8.0
	stable_deref_trait@1.2.1
	static_assertions@1.1.0
	strength_reduce@0.2.4
	strict-num@0.1.1
	strsim@0.11.1
	subtle@2.6.1
	syn@2.0.118
	synstructure@0.13.2
	system-deps@7.0.8
	target-lexicon@0.13.5
	tempfile@3.27.0
	termcolor@1.4.1
	thiserror@1.0.69
	thiserror@2.0.18
	thiserror-impl@1.0.69
	thiserror-impl@2.0.18
	time@0.3.53
	time-core@0.1.9
	time-macros@0.2.31
	tiny-skia@0.11.4
	tiny-skia-path@0.11.4
	tinystr@0.8.3
	tinytemplate@1.2.1
	tinyvec@1.12.0
	tinyvec_macros@0.1.1
	toml@1.1.2+spec-1.1.0
	toml_datetime@1.1.1+spec-1.1.0
	toml_edit@0.25.12+spec-1.1.0
	toml_parser@1.1.2+spec-1.1.0
	toml_writer@1.1.1+spec-1.1.0
	tracing@0.1.44
	tracing-attributes@0.1.31
	tracing-core@0.1.36
	transpose@0.2.3
	ttf-parser@0.25.1
	typenum@1.20.1
	uds_windows@1.2.1
	ultraviolet@0.10.0
	unicode-ident@1.0.24
	unicode-segmentation@1.13.3
	unicode-width@0.2.2
	untrusted@0.9.0
	ureq@3.3.0
	ureq-proto@0.6.0
	url@2.5.8
	utf8_iter@1.0.4
	utf8-zero@0.8.1
	uuid@1.23.5
	version_check@0.9.5
	version-compare@0.2.1
	walkdir@2.5.0
	wasi@0.11.1+wasi-snapshot-preview1
	wasip2@1.0.4+wasi-0.2.12
	wasm-bindgen@0.2.126
	wasm-bindgen-futures@0.4.76
	wasm-bindgen-macro@0.2.126
	wasm-bindgen-macro-support@0.2.126
	wasm-bindgen-shared@0.2.126
	wayland-backend@0.3.15
	wayland-client@0.31.14
	wayland-csd-frame@0.3.0
	wayland-cursor@0.31.14
	wayland-protocols@0.32.13
	wayland-protocols-plasma@0.3.12
	wayland-protocols-wlr@0.3.12
	wayland-scanner@0.31.10
	wayland-server@0.31.13
	wayland-sys@0.31.11
	webpki-roots@1.0.8
	web-sys@0.3.103
	web-time@1.1.0
	wgpu@29.0.4
	wgpu-core@29.0.4
	wgpu-core-deps-apple@29.0.4
	wgpu-core-deps-emscripten@29.0.4
	wgpu-core-deps-wasm@29.0.4
	wgpu-core-deps-windows-linux-android@29.0.4
	wgpu-hal@29.0.4
	wgpu-naga-bridge@29.0.4
	wgpu-types@29.0.4
	wide@0.7.33
	wide@1.5.0
	widestring@1.2.1
	winapi@0.3.9
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.11
	winapi-x86_64-pc-windows-gnu@0.4.0
	wincode@0.5.5
	wincode-derive@0.4.6
	windows@0.62.2
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_msvc@0.52.6
	windows-collections@0.3.2
	windows-core@0.62.2
	windows-future@0.3.2
	windows_i686_gnu@0.52.6
	windows_i686_gnullvm@0.52.6
	windows_i686_msvc@0.52.6
	windows-implement@0.60.2
	windows-interface@0.59.3
	windows-link@0.2.1
	windows-numerics@0.3.1
	windows-result@0.4.1
	windows-strings@0.5.1
	windows-sys@0.52.0
	windows-sys@0.59.0
	windows-sys@0.61.2
	windows-targets@0.52.6
	windows-threading@0.2.1
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_msvc@0.52.6
	winit@0.30.13
	winnow@1.0.4
	wit-bindgen@0.57.1
	wnaf@0.14.0
	writeable@0.6.3
	x11-dl@2.21.0
	x11rb@0.13.2
	x11rb-protocol@0.13.2
	xcap@0.9.6
	xcb@1.7.0
	xcursor@0.3.10
	xkbcommon-dl@0.4.2
	xkeysym@0.2.1
	xml-rs@0.8.28
	yoke@0.8.3
	yoke-derive@0.8.2
	zbus@5.17.0
	zbus_macros@5.17.0
	zbus_names@4.3.3
	zerocopy@0.8.54
	zerocopy-derive@0.8.54
	zerofrom@0.1.8
	zerofrom-derive@0.1.7
	zeroize@1.9.0
	zeroize_derive@1.5.0
	zerotrie@0.2.4
	zerovec@0.11.6
	zerovec-derive@0.11.3
	zmij@1.0.23
	zvariant@5.13.0
	zvariant_derive@5.13.0
	zvariant_utils@3.5.0
"

inherit cargo

DESCRIPTION="Lightweight, fast and secure chat application powered by WHY2 encryption"
HOMEPAGE="https://why2.satan.red"

MY_PN="why2-chat"
SRC_URI="https://crates.io/api/v1/crates/${MY_PN}/${PV}/download -> ${MY_PN}-${PV}.crate ${CARGO_CRATE_URIS}"
S="${WORKDIR}/${MY_PN}-${PV}"

LICENSE="GPL-3 0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD BSD-2 BlueOak-1.0.0 CDLA-Permissive-2.0 ISC LGPL-2.1+ MIT MPL-2.0 Unicode-3.0 Unlicense ZLIB"
SLOT="0"
KEYWORDS="~amd64"

QA_FLAGS_IGNORED="usr/bin/why2 usr/bin/why2-server"
IUSE="+server"

DEPEND="media-libs/alsa-lib"
RDEPEND="${DEPEND}"
BDEPEND="virtual/pkgconfig"

src_unpack() {
	cargo_src_unpack
	tar xf "${DISTDIR}/${MY_PN}-${PV}.crate" -C "${WORKDIR}" || die
}

src_compile() {
	cargo_src_compile  # builds client (default features)
	if use server; then
	cargo_src_compile --bin why2-server --no-default-features --features server
	fi
}

src_install() {
	dobin "$(cargo_target_dir)/why2"
	use server && dobin "$(cargo_target_dir)/why2-server"
}