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

EAPI=8

CRATES="
	ab_glyph@0.2.23
	ab_glyph_rasterizer@0.1.8
	accesskit@0.11.2
	accesskit_consumer@0.15.2
	accesskit_macos@0.9.0
	accesskit_unix@0.5.2
	accesskit_windows@0.14.3
	accesskit_winit@0.14.4
	addr2line@0.21.0
	adler@1.0.2
	ahash@0.8.7
	aho-corasick@1.1.2
	android-activity@0.4.3
	android-properties@0.2.2
	anyhow@1.0.79
	approx@0.5.1
	arboard@3.3.0
	arrayref@0.3.7
	arrayvec@0.7.4
	async-broadcast@0.5.1
	async-channel@1.9.0
	async-channel@2.2.0
	async-executor@1.8.0
	async-fs@1.6.0
	async-io@1.13.0
	async-io@2.3.1
	async-lock@2.8.0
	async-lock@3.3.0
	async-process@1.8.1
	async-recursion@1.0.5
	async-signal@0.2.5
	async-task@4.7.0
	async-trait@0.1.77
	atk-sys@0.16.0
	atomic-waker@1.1.2
	atomic_refcell@0.1.13
	atspi@0.10.1
	atspi-macros@0.2.0
	autocfg@1.1.0
	backtrace@0.3.69
	base64@0.21.7
	bit_field@0.10.2
	bitflags@1.3.2
	bitflags@2.4.2
	block@0.1.6
	block-buffer@0.10.4
	block-sys@0.1.0-beta.1
	block2@0.2.0-alpha.6
	blocking@1.5.1
	bumpalo@3.14.0
	bytemuck@1.14.3
	bytemuck_derive@1.5.0
	byteorder@1.5.0
	bytes@1.5.0
	cairo-sys-rs@0.16.3
	calloop@0.10.6
	cc@1.0.83
	cesu8@1.1.0
	cfg-expr@0.15.7
	cfg-if@1.0.0
	cfg_aliases@0.1.1
	cgl@0.3.2
	claims@0.7.1
	clipboard-win@4.5.0
	cocoa@0.24.1
	cocoa-foundation@0.1.2
	color_quant@1.1.0
	combine@4.6.6
	concurrent-queue@2.4.0
	confy@0.5.1
	conv@0.3.3
	core-foundation@0.9.4
	core-foundation-sys@0.8.6
	core-graphics@0.22.3
	core-graphics-types@0.1.3
	cpufeatures@0.2.12
	crc32fast@1.3.2
	crossbeam-channel@0.5.11
	crossbeam-deque@0.8.5
	crossbeam-epoch@0.9.18
	crossbeam-utils@0.8.19
	crunchy@0.2.2
	crypto-common@0.1.6
	custom_derive@0.1.7
	deranged@0.3.11
	derivative@2.2.0
	digest@0.10.7
	directories@4.0.1
	directories@5.0.1
	dirs-sys@0.3.7
	dirs-sys@0.4.1
	dispatch@0.2.0
	dlib@0.5.2
	downcast-rs@1.2.0
	ecolor@0.22.0
	eframe@0.22.0
	egui@0.22.0
	egui-winit@0.22.0
	egui_extras@0.22.0
	egui_glow@0.22.0
	either@1.9.0
	emath@0.22.0
	encoding_rs@0.8.33
	enum-iterator@1.5.0
	enum-iterator-derive@1.3.0
	enumflags2@0.7.8
	enumflags2_derive@0.7.8
	epaint@0.22.0
	equivalent@1.0.1
	errno@0.3.8
	error-code@2.3.1
	event-listener@2.5.3
	event-listener@3.1.0
	event-listener@4.0.3
	event-listener@5.0.0
	event-listener-strategy@0.4.0
	event-listener-strategy@0.5.0
	exr@1.72.0
	fastrand@1.9.0
	fastrand@2.0.1
	fdeflate@0.3.4
	ffmpeg-sidecar@0.3.3
	flate2@1.0.28
	flume@0.11.0
	fnv@1.0.7
	foreign-types@0.3.2
	foreign-types-shared@0.1.1
	form_urlencoded@1.2.1
	futures-channel@0.3.30
	futures-core@0.3.30
	futures-io@0.3.30
	futures-lite@1.13.0
	futures-lite@2.2.0
	futures-sink@0.3.30
	futures-task@0.3.30
	futures-util@0.3.30
	gdk-pixbuf-sys@0.16.3
	gdk-sys@0.16.0
	generic-array@0.14.7
	gethostname@0.3.0
	getrandom@0.1.16
	getrandom@0.2.12
	getset@0.1.2
	gif@0.12.0
	gimli@0.28.1
	gio-sys@0.16.3
	git2@0.16.1
	github_release_check@0.2.1
	gl_generator@0.14.0
	glib-sys@0.16.3
	glow@0.12.3
	glutin@0.30.10
	glutin-winit@0.3.0
	glutin_egl_sys@0.5.1
	glutin_glx_sys@0.4.0
	glutin_wgl_sys@0.4.0
	gobject-sys@0.16.3
	gtk-sys@0.16.0
	h2@0.3.24
	half@2.3.1
	hashbrown@0.14.3
	heck@0.4.1
	hermit-abi@0.3.5
	hex@0.4.3
	home@0.5.9
	http@0.2.11
	http-body@0.4.6
	httparse@1.8.0
	httpdate@1.0.3
	hyper@0.14.28
	hyper-tls@0.5.0
	idna@0.5.0
	image@0.24.8
	imageproc@0.23.0
	indexmap@2.2.2
	instant@0.1.12
	io-lifetimes@1.0.11
	ipnet@2.9.0
	itertools@0.10.5
	itoa@1.0.10
	jni@0.21.1
	jni-sys@0.3.0
	jobserver@0.1.28
	jpeg-decoder@0.3.1
	js-sys@0.3.68
	khronos_api@3.1.0
	lazy_static@1.4.0
	lebe@0.5.2
	libc@0.2.153
	libgit2-sys@0.14.2+1.5.1
	libloading@0.7.4
	libloading@0.8.1
	libredox@0.0.1
	libredox@0.0.2
	libz-sys@1.1.15
	linux-raw-sys@0.3.8
	linux-raw-sys@0.4.13
	lock_api@0.4.11
	log@0.4.20
	malloc_buf@0.0.6
	matrixmultiply@0.3.8
	memchr@2.7.1
	memmap2@0.5.10
	memoffset@0.6.5
	memoffset@0.7.1
	memoffset@0.9.0
	mime@0.3.17
	miniz_oxide@0.7.2
	mio@0.8.10
	nalgebra@0.30.1
	native-tls@0.2.11
	ndk@0.7.0
	ndk-context@0.1.1
	ndk-sys@0.4.1+23.1.7779620
	nix@0.24.3
	nix@0.25.1
	nix@0.26.4
	nohash-hasher@0.2.0
	ntapi@0.4.1
	nu-ansi-term@0.46.0
	num@0.4.1
	num-bigint@0.4.4
	num-complex@0.4.5
	num-conv@0.1.0
	num-integer@0.1.46
	num-iter@0.1.44
	num-rational@0.4.1
	num-traits@0.2.18
	num_cpus@1.16.0
	num_enum@0.5.11
	num_enum@0.6.1
	num_enum_derive@0.5.11
	num_enum_derive@0.6.1
	objc@0.2.7
	objc-foundation@0.1.1
	objc-sys@0.2.0-beta.2
	objc2@0.3.0-beta.3.patch-leaks.3
	objc2-encode@2.0.0-pre.2
	objc_id@0.1.1
	object@0.32.2
	once_cell@1.19.0
	openssl@0.10.63
	openssl-macros@0.1.1
	openssl-probe@0.1.5
	openssl-sys@0.9.99
	option-ext@0.2.0
	orbclient@0.3.47
	ordered-stream@0.2.0
	overload@0.1.1
	owned_ttf_parser@0.15.2
	owned_ttf_parser@0.20.0
	pango-sys@0.16.3
	parking@2.2.0
	parking_lot@0.12.1
	parking_lot_core@0.9.9
	parse-display@0.8.2
	parse-display-derive@0.8.2
	paste@1.0.14
	percent-encoding@2.3.1
	pin-project-lite@0.2.13
	pin-utils@0.1.0
	piper@0.2.1
	pkg-config@0.3.29
	png@0.17.11
	polling@2.8.0
	polling@3.4.0
	powerfmt@0.2.0
	ppv-lite86@0.2.17
	proc-macro-crate@1.3.1
	proc-macro-error@1.0.4
	proc-macro-error-attr@1.0.4
	proc-macro2@1.0.78
	qoi@0.4.1
	quote@1.0.35
	rand@0.7.3
	rand@0.8.5
	rand_chacha@0.2.2
	rand_chacha@0.3.1
	rand_core@0.5.1
	rand_core@0.6.4
	rand_distr@0.2.2
	rand_hc@0.2.0
	raw-window-handle@0.5.2
	rawpointer@0.2.1
	rayon@1.8.1
	rayon-core@1.12.1
	redox_syscall@0.3.5
	redox_syscall@0.4.1
	redox_users@0.4.4
	regex@1.10.3
	regex-automata@0.4.5
	regex-syntax@0.7.5
	regex-syntax@0.8.2
	reqwest@0.11.24
	rfd@0.11.4
	ron@0.8.1
	rustc-demangle@0.1.23
	rustc_version@0.4.0
	rustix@0.37.27
	rustix@0.38.31
	rustls-pemfile@1.0.4
	rusttype@0.9.3
	rustversion@1.0.14
	ryu@1.0.16
	safe_arch@0.7.1
	same-file@1.0.6
	schannel@0.1.23
	scoped-tls@1.0.1
	scopeguard@1.2.0
	sctk-adwaita@0.5.4
	security-framework@2.9.2
	security-framework-sys@2.9.1
	semver@1.0.21
	serde@1.0.196
	serde_derive@1.0.196
	serde_json@1.0.113
	serde_repr@0.1.18
	serde_spanned@0.6.5
	serde_urlencoded@0.7.1
	sha1@0.10.6
	sharded-slab@0.1.7
	signal-hook-registry@1.4.1
	simba@0.7.3
	simd-adler32@0.3.7
	slab@0.4.9
	slotmap@1.0.7
	smallvec@1.13.1
	smithay-client-toolkit@0.16.1
	smithay-clipboard@0.6.6
	socket2@0.4.10
	socket2@0.5.5
	spin@0.9.8
	srtparse@0.2.0
	static_assertions@1.1.0
	str-buf@1.0.6
	strict-num@0.1.1
	structmeta@0.2.0
	structmeta-derive@0.2.0
	syn@1.0.109
	syn@2.0.48
	sync_wrapper@0.1.2
	sysinfo@0.27.8
	system-configuration@0.5.1
	system-configuration-sys@0.5.0
	system-deps@6.2.0
	target-lexicon@0.12.13
	tempfile@3.10.0
	thiserror@1.0.56
	thiserror-impl@1.0.56
	thread_local@1.1.7
	tiff@0.9.1
	time@0.3.36
	time-core@0.1.2
	time-macros@0.2.18
	tiny-skia@0.8.4
	tiny-skia-path@0.8.4
	tinyvec@1.6.0
	tinyvec_macros@0.1.1
	tokio@1.36.0
	tokio-native-tls@0.3.1
	tokio-util@0.7.10
	toml@0.8.10
	toml_datetime@0.6.5
	toml_edit@0.19.15
	toml_edit@0.22.4
	tower-service@0.3.2
	tracing@0.1.40
	tracing-appender@0.2.3
	tracing-attributes@0.1.27
	tracing-core@0.1.32
	tracing-log@0.2.0
	tracing-subscriber@0.3.18
	try-lock@0.2.5
	ttf-parser@0.15.2
	ttf-parser@0.20.0
	typenum@1.17.0
	uds_windows@1.1.0
	unicode-bidi@0.3.15
	unicode-ident@1.0.12
	unicode-normalization@0.1.22
	url@2.5.0
	valuable@0.1.0
	vcpkg@0.2.15
	vec_map@0.8.2
	vergen@7.5.1
	version-compare@0.1.1
	version_check@0.9.4
	waker-fn@1.1.1
	walkdir@2.4.0
	want@0.3.1
	wasi@0.9.0+wasi-snapshot-preview1
	wasi@0.11.0+wasi-snapshot-preview1
	wasm-bindgen@0.2.91
	wasm-bindgen-backend@0.2.91
	wasm-bindgen-futures@0.4.41
	wasm-bindgen-macro@0.2.91
	wasm-bindgen-macro-support@0.2.91
	wasm-bindgen-shared@0.2.91
	wayland-client@0.29.5
	wayland-commons@0.29.5
	wayland-cursor@0.29.5
	wayland-protocols@0.29.5
	wayland-scanner@0.29.5
	wayland-sys@0.29.5
	wayland-sys@0.30.1
	web-sys@0.3.68
	webbrowser@0.8.12
	weezl@0.1.8
	wide@0.7.15
	winapi@0.3.9
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.6
	winapi-wsapoll@0.1.1
	winapi-x86_64-pc-windows-gnu@0.4.0
	windows@0.44.0
	windows@0.48.0
	windows-implement@0.48.0
	windows-interface@0.48.0
	windows-sys@0.45.0
	windows-sys@0.48.0
	windows-sys@0.52.0
	windows-targets@0.42.2
	windows-targets@0.48.5
	windows-targets@0.52.0
	windows_aarch64_gnullvm@0.42.2
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_gnullvm@0.52.0
	windows_aarch64_msvc@0.42.2
	windows_aarch64_msvc@0.48.5
	windows_aarch64_msvc@0.52.0
	windows_i686_gnu@0.42.2
	windows_i686_gnu@0.48.5
	windows_i686_gnu@0.52.0
	windows_i686_msvc@0.42.2
	windows_i686_msvc@0.48.5
	windows_i686_msvc@0.52.0
	windows_x86_64_gnu@0.42.2
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnu@0.52.0
	windows_x86_64_gnullvm@0.42.2
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_gnullvm@0.52.0
	windows_x86_64_msvc@0.42.2
	windows_x86_64_msvc@0.48.5
	windows_x86_64_msvc@0.52.0
	winit@0.28.7
	winnow@0.5.39
	winreg@0.50.0
	x11-dl@2.21.0
	x11rb@0.12.0
	x11rb-protocol@0.12.0
	xcursor@0.3.5
	xdg-home@1.1.0
	xml-rs@0.8.19
	zbus@3.15.0
	zbus_macros@3.15.0
	zbus_names@2.6.0
	zerocopy@0.7.32
	zerocopy-derive@0.7.32
	zune-inflate@0.2.54
	zvariant@3.15.0
	zvariant_derive@3.15.0
	zvariant_utils@1.0.1
"

declare -A GIT_CRATES=(
	[ffprobe]="https://github.com/avsaase/ffprobe-rs;8c863431ebf0df913e325ec490589023b193402f"
	[poll-promise]="https://github.com/EmbarkStudios/poll-promise;b493586107b0e508860aa2e9d18049fd8cd9d13f"
)

RUST_MIN_VER="1.71.1"

inherit cargo desktop xdg-utils

DESCRIPTION="Tool for rendering OSDs over Walksnail DVR recordings"
HOMEPAGE="https://github.com/avsaase/walksnail-osd-tool"
SRC_URI="https://github.com/avsaase/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}"

LICENSE="0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD BSD-2 Boost-1.0 GPL-3 ISC UbuntuFontLicense-1.0 MIT MPL-2.0 OFL-1.1 Unicode-DFS-2016 Unlicense XC ZLIB"
SLOT="0"
KEYWORDS="~amd64"

DEPEND="
	dev-libs/openssl:=
	x11-libs/gtk+:3
"
RDEPEND="
	${DEPEND}
	media-video/ffmpeg
"

PATCHES=(
	"${FILESDIR}/${P}-version-parse-fix.patch"
	"${FILESDIR}/${P}-build-remove-git-dep.patch"
	"${FILESDIR}/${P}-rust-1.80.patch"
)

QA_FLAGS_IGNORED="usr/bin/${PN}"

src_unpack() {
	cargo_src_unpack
	# rename the repo to match what the build expects
	mv ffprobe-rs-8c863431ebf0df913e325ec490589023b193402f ffprobe-8c863431ebf0df913e325ec490589023b193402f || die
}

src_install() {
	cd ui || die
	cargo_src_install

	cd .. || die
	cp resources/icons/app-icon.svg walksnail-osd-tool.svg || die
	doicon -s scalable walksnail-osd-tool.svg
	make_desktop_entry walksnail-osd-tool 'Walksnail OSD Tool' walksnail-osd-tool
}

pkg_postinst() {
	xdg_icon_cache_update
}

pkg_postrm() {
	xdg_icon_cache_update
}
