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

EAPI=8

# Upstream tag is "7.0.0-beta"; the crate version at that tag is 7.0.0-beta2.
# When stable 7.0.0 is released, rename to ...-7.0.0.ebuild and drop MY_PV.
MY_PV="${PV/_beta/-beta}"

# Rust edition 2024 -> needs >=rust 1.85
RUST_MIN_VER="1.85.0"

CRATES="
	adler2@2.0.1
	aho-corasick@1.1.4
	aligned-vec@0.6.4
	aligned@0.4.3
	allocator-api2@0.2.21
	ansi-to-tui@7.0.0
	anstream@0.6.21
	anstyle-parse@0.2.7
	anstyle-query@1.1.5
	anstyle-wincon@3.0.11
	anstyle@1.0.13
	anyhow@1.0.100
	arbitrary@1.4.2
	arg_enum_proc_macro@0.3.4
	arrayvec@0.7.6
	as-slice@0.2.1
	autocfg@1.5.0
	av-scenechange@0.14.1
	av1-grain@0.2.5
	avif-serialize@0.8.6
	bindgen@0.65.1
	bit_field@0.10.3
	bitflags@1.3.2
	bitflags@2.10.0
	bitstream-io@4.9.0
	built@0.8.0
	bumpalo@3.19.1
	bytemuck@1.24.0
	byteorder-lite@0.1.0
	cassowary@0.3.0
	castaway@0.2.4
	cc@1.2.49
	cexpr@0.6.0
	cfg-if@1.0.4
	clang-sys@1.8.1
	clap@4.5.53
	clap_builder@4.5.53
	clap_derive@4.5.49
	clap_lex@0.7.6
	color_quant@1.1.0
	colorchoice@1.0.4
	compact_str@0.8.1
	console@0.15.11
	convert_case@0.10.0
	core2@0.4.0
	crc32fast@1.5.0
	crossbeam-deque@0.8.6
	crossbeam-epoch@0.9.18
	crossbeam-utils@0.8.21
	crossterm@0.28.1
	crossterm@0.29.0
	crossterm_winapi@0.9.1
	crunchy@0.2.4
	darling@0.20.11
	darling_core@0.20.11
	darling_macro@0.20.11
	deranged@0.5.5
	derive_more-impl@2.1.0
	derive_more@2.1.0
	dirs-sys@0.5.0
	dirs@6.0.0
	document-features@0.2.12
	either@1.15.0
	encode_unicode@1.0.0
	equator-macro@0.4.2
	equator@0.4.2
	equivalent@1.0.2
	errno@0.3.14
	exr@1.74.0
	fax@0.2.6
	fax_derive@0.2.0
	fdeflate@0.3.7
	find-msvc-tools@0.1.5
	flate2@1.1.5
	fnv@1.0.7
	foldhash@0.1.5
	futures-channel@0.3.31
	futures-core@0.3.31
	futures-executor@0.3.31
	futures-io@0.3.31
	futures-macro@0.3.31
	futures-sink@0.3.31
	futures-task@0.3.31
	futures-util@0.3.31
	futures@0.3.31
	getrandom@0.2.16
	getrandom@0.3.4
	gif@0.14.1
	glob@0.3.3
	half@2.7.1
	hashbrown@0.15.5
	hashbrown@0.16.1
	heck@0.5.0
	home@0.5.12
	ident_case@1.0.1
	image-webp@0.2.4
	image@0.25.9
	imgref@1.12.0
	indexmap@2.12.1
	indoc@2.0.7
	insta@1.44.3
	instability@0.3.10
	interpolate_name@0.2.4
	is_terminal_polyfill@1.70.2
	itertools@0.13.0
	itertools@0.14.0
	itoa@1.0.15
	jobserver@0.1.34
	lazy_static@1.5.0
	lazycell@1.3.0
	lebe@0.5.3
	libc@0.2.178
	libfuzzer-sys@0.4.10
	libloading@0.8.9
	libredox@0.1.11
	linux-raw-sys@0.11.0
	linux-raw-sys@0.4.15
	litrs@1.0.0
	lock_api@0.4.14
	log@0.4.29
	loop9@0.1.5
	lru@0.12.5
	maybe-rayon@0.1.1
	memchr@2.7.6
	minimal-lexical@0.2.1
	miniz_oxide@0.8.9
	mio@1.1.1
	moxcms@0.7.11
	new_debug_unreachable@1.0.6
	nom@7.1.3
	nom@8.0.0
	noop_proc_macro@0.3.0
	num-bigint@0.4.6
	num-conv@0.1.0
	num-derive@0.4.2
	num-integer@0.1.46
	num-rational@0.4.2
	num-traits@0.2.19
	num_threads@0.1.7
	once_cell@1.21.3
	once_cell_polyfill@1.70.2
	option-ext@0.2.0
	parking_lot@0.12.5
	parking_lot_core@0.9.12
	paste@1.0.15
	pastey@0.1.1
	peeking_take_while@0.1.2
	pin-project-lite@0.2.16
	pin-utils@0.1.0
	png@0.18.0
	powerfmt@0.2.0
	ppv-lite86@0.2.21
	prettyplease@0.2.37
	proc-macro2@1.0.103
	profiling-procmacros@1.0.17
	profiling@1.0.17
	pxfm@0.1.27
	qoi@0.4.1
	quick-error@2.0.1
	quote@1.0.42
	r-efi@5.3.0
	rand@0.9.2
	rand_chacha@0.9.0
	rand_core@0.9.3
	ratatui@0.29.0
	rav1e@0.8.1
	ravif@0.12.0
	rayon-core@1.13.0
	rayon@1.11.0
	redox_syscall@0.5.18
	redox_users@0.5.2
	regex-automata@0.4.13
	regex-syntax@0.8.8
	regex@1.12.2
	rgb@0.8.52
	rustc-hash@1.1.0
	rustc_version@0.4.1
	rustix@0.38.44
	rustix@1.1.2
	rustversion@1.0.22
	ryu@1.0.20
	scc@2.4.0
	scopeguard@1.2.0
	sdd@3.0.10
	semver@1.0.27
	serde@1.0.228
	serde_core@1.0.228
	serde_derive@1.0.228
	serde_spanned@1.0.3
	serial_test@3.2.0
	serial_test_derive@3.2.0
	shellexpand@3.1.1
	shlex@1.3.0
	signal-hook-mio@0.2.5
	signal-hook-registry@1.4.7
	signal-hook@0.3.18
	simd-adler32@0.3.8
	simd_helpers@0.1.0
	simdutf8@0.1.5
	similar@2.7.0
	simplelog@0.12.2
	slab@0.4.11
	smallvec@1.15.1
	stable_deref_trait@1.2.1
	static_assertions@1.1.0
	strsim@0.11.1
	strum@0.26.3
	strum_macros@0.26.4
	syn@2.0.111
	termcolor@1.4.1
	thiserror-impl@1.0.69
	thiserror-impl@2.0.17
	thiserror@1.0.69
	thiserror@2.0.17
	tiff@0.10.3
	time-core@0.1.6
	time-macros@0.2.24
	time@0.3.44
	tokio-macros@2.6.0
	tokio@1.48.0
	toml@0.9.8
	toml_datetime@0.7.3
	toml_parser@1.0.4
	toml_writer@1.0.4
	unicode-ident@1.0.22
	unicode-segmentation@1.12.0
	unicode-truncate@1.1.0
	unicode-width@0.1.14
	unicode-width@0.2.0
	utf8parse@0.2.2
	v4l2-sys-mit@0.3.0
	v4l@0.14.0
	v_frame@0.3.9
	wasi@0.11.1+wasi-snapshot-preview1
	wasip2@1.0.1+wasi-0.2.4
	wasm-bindgen-macro-support@0.2.106
	wasm-bindgen-macro@0.2.106
	wasm-bindgen-shared@0.2.106
	wasm-bindgen@0.2.106
	weezl@0.1.12
	which@4.4.2
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.11
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-link@0.2.1
	windows-sys@0.59.0
	windows-sys@0.61.2
	windows-targets@0.52.6
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_msvc@0.52.6
	windows_i686_gnu@0.52.6
	windows_i686_gnullvm@0.52.6
	windows_i686_msvc@0.52.6
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_msvc@0.52.6
	winnow@0.7.14
	wit-bindgen@0.46.0
	y4m@0.8.0
	zerocopy-derive@0.8.31
	zerocopy@0.8.31
	zune-core@0.4.12
	zune-core@0.5.0
	zune-inflate@0.2.54
	zune-jpeg@0.4.21
	zune-jpeg@0.5.7
"

declare -A GIT_CRATES=(
	[ansipix]='https://github.com/EmixamPP/ansipix;4e29437ea3fc23ea451a50b90cafdf7c519ffacb;ansipix-%commit%'
)

inherit cargo

DESCRIPTION="Enables the infrared camera emitter, supports any v4l2 (UVC) device"
HOMEPAGE="https://github.com/EmixamPP/linux-enable-ir-emitter"
SRC_URI="
	https://github.com/EmixamPP/${PN}/archive/refs/tags/${MY_PV}.tar.gz
		-> ${P}.tar.gz
	${CARGO_CRATE_URIS}
"
S="${WORKDIR}/${PN}-${MY_PV}"

# Main package: MIT. Remainder is the aggregate of the dependency crates.
LICENSE="MIT"
LICENSE+="
	Apache-2.0 BSD-2 BSD GPL-3 ISC MIT MPL-2.0 UoI-NCSA Unicode-3.0 ZLIB
"
SLOT="0"
KEYWORDS="~amd64"

# bindgen (pulled in by v4l2-sys-mit) dlopens libclang and parses
# <linux/videodev2.h> at build time.
BDEPEND="
	llvm-core/clang:=
	virtual/os-headers
"

# Tests drive a real v4l2 capture device, which is unavailable in the sandbox.
RESTRICT="test"

src_install() {
	cargo_src_install
	einstalldocs
	dodoc CHANGELOG.md
}