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

# Autogenerated by pycargoebuild 0.13.3

EAPI=8

CRATES="
	addr2line@0.21.0
	adler@1.0.2
	aho-corasick@1.1.3
	android-tzdata@0.1.1
	android_system_properties@0.1.5
	ansi_term@0.12.1
	assert-json-diff@2.0.2
	async-attributes@1.1.2
	async-channel@1.9.0
	async-channel@2.2.0
	async-ctrlc@1.2.0
	async-executor@1.10.0
	async-global-executor@2.4.1
	async-io@1.13.0
	async-io@2.3.2
	async-lock@2.8.0
	async-lock@3.3.0
	async-process@1.8.1
	async-signal@0.2.5
	async-std@1.12.0
	async-task@4.7.0
	atomic-waker@1.1.2
	atty@0.2.14
	autocfg@1.2.0
	backtrace@0.3.71
	bincode@1.3.3
	bitflags@1.3.2
	bitflags@2.5.0
	blocking@1.5.1
	bstr@0.2.17
	bumpalo@3.16.0
	byteorder@1.5.0
	cc@1.0.94
	cfg-if@0.1.10
	cfg-if@1.0.0
	cfg_aliases@0.1.1
	chrono-humanize@0.1.2
	chrono-tz@0.5.3
	chrono@0.4.37
	clap@3.2.25
	clap_lex@0.2.4
	clipboard-win@4.5.0
	color-eyre@0.5.11
	color-eyre@0.6.3
	color-spantrace@0.1.6
	concurrent-queue@2.4.0
	console@0.15.8
	console_error_panic_hook@0.1.7
	core-foundation-sys@0.8.6
	crossbeam-utils@0.8.19
	ctrlc@3.4.4
	curl-sys@0.4.72+curl-8.6.0
	curl@0.4.46
	dirs-sys@0.3.7
	dirs@4.0.0
	displaydoc@0.2.4
	encode_unicode@0.3.6
	endian-type@0.1.2
	equivalent@1.0.1
	errno@0.3.8
	error-code@2.3.1
	event-listener-strategy@0.4.0
	event-listener-strategy@0.5.1
	event-listener@2.5.3
	event-listener@3.1.0
	event-listener@4.0.3
	event-listener@5.3.0
	eyre@0.6.12
	fastrand@1.9.0
	fastrand@2.0.2
	fd-lock@3.0.13
	futures-channel@0.3.30
	futures-core@0.3.30
	futures-io@0.3.30
	futures-lite@1.13.0
	futures-lite@2.3.0
	getrandom@0.2.14
	gimli@0.28.1
	gloo-timers@0.2.6
	hashbrown@0.12.3
	hashbrown@0.14.3
	hermit-abi@0.1.19
	hermit-abi@0.3.9
	humantime-serde@1.1.1
	humantime@2.1.0
	iana-time-zone-haiku@0.1.2
	iana-time-zone@0.1.60
	indenter@0.3.3
	indexmap@1.9.3
	indexmap@2.2.6
	instant@0.1.12
	io-lifetimes@1.0.11
	itoa@1.0.11
	js-sys@0.3.69
	kv-log-macro@1.0.7
	lazy_static@1.4.0
	libc@0.2.153
	libredox@0.1.3
	libz-sys@1.1.16
	linux-raw-sys@0.3.8
	linux-raw-sys@0.4.13
	log@0.4.21
	memchr@2.7.2
	memoffset@0.6.5
	memory_units@0.4.0
	miniz_oxide@0.7.2
	nibble_vec@0.1.0
	nix@0.23.2
	nix@0.28.0
	num-bigint@0.4.4
	num-integer@0.1.46
	num-rational@0.4.1
	num-traits@0.2.18
	object@0.32.2
	once_cell@1.19.0
	openssl-probe@0.1.5
	openssl-sys@0.9.102
	os_str_bytes@6.6.1
	owo-colors@1.3.0
	owo-colors@3.5.0
	parking@2.2.0
	parse-zoneinfo@0.3.0
	pin-project-lite@0.2.14
	pin-utils@0.1.0
	piper@0.2.1
	pkg-config@0.3.30
	polling@2.8.0
	polling@3.6.0
	proc-macro2@1.0.79
	quote@1.0.36
	radix_trie@0.2.1
	redox_users@0.4.5
	regex-automata@0.1.10
	regex-automata@0.4.6
	regex-syntax@0.8.3
	regex@1.10.4
	rustc-demangle@0.1.23
	rustix@0.37.27
	rustix@0.38.32
	rustyline@9.1.2
	ryu@1.0.17
	schannel@0.1.23
	scoped-tls@1.0.1
	scopeguard@1.2.0
	serde-wasm-bindgen@0.6.5
	serde@1.0.197
	serde_derive@1.0.197
	serde_json@1.0.115
	sharded-slab@0.1.7
	signal-hook-registry@1.4.1
	similar-asserts@1.5.0
	similar@2.5.0
	slab@0.4.9
	smallvec@1.13.2
	socket2@0.4.10
	socket2@0.5.6
	str-buf@1.0.6
	strsim@0.10.0
	syn@1.0.109
	syn@2.0.58
	tempfile@3.10.1
	termcolor@1.4.1
	textwrap@0.16.1
	thiserror-impl@1.0.58
	thiserror@1.0.58
	thread_local@1.1.8
	toml@0.5.11
	tracing-attributes@0.1.27
	tracing-core@0.1.32
	tracing-error@0.1.2
	tracing-subscriber@0.2.25
	tracing@0.1.40
	ubyte@0.10.4
	unicode-ident@1.0.12
	unicode-segmentation@1.11.0
	unicode-width@0.1.11
	utf8parse@0.2.1
	valuable@0.1.0
	value-bag@1.8.1
	vcpkg@0.2.15
	waker-fn@1.1.1
	wasi@0.11.0+wasi-snapshot-preview1
	wasm-bindgen-backend@0.2.92
	wasm-bindgen-futures@0.4.42
	wasm-bindgen-macro-support@0.2.92
	wasm-bindgen-macro@0.2.92
	wasm-bindgen-shared@0.2.92
	wasm-bindgen-test-macro@0.3.42
	wasm-bindgen-test@0.3.42
	wasm-bindgen@0.2.92
	web-sys@0.3.69
	wee_alloc@0.4.5
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.6
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-core@0.52.0
	windows-sys@0.48.0
	windows-sys@0.52.0
	windows-targets@0.48.5
	windows-targets@0.52.5
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_gnullvm@0.52.5
	windows_aarch64_msvc@0.48.5
	windows_aarch64_msvc@0.52.5
	windows_i686_gnu@0.48.5
	windows_i686_gnu@0.52.5
	windows_i686_gnullvm@0.52.5
	windows_i686_msvc@0.48.5
	windows_i686_msvc@0.52.5
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnu@0.52.5
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_gnullvm@0.52.5
	windows_x86_64_msvc@0.48.5
	windows_x86_64_msvc@0.52.5
"

inherit cargo desktop

DESCRIPTION="Unit conversion tool, similar to frink"
HOMEPAGE="https://rinkcalc.app/about"
SRC_URI="
	https://github.com/tiffany352/rink-rs/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	https://files.demize.dev/gentoo/${CATEGORY}/${PN}/${PN}-docs-${PV}.tar.gz
	${CARGO_CRATE_URIS}
"

S="${WORKDIR}/rink-rs-${PV}"

LICENSE="MPL-2.0"
# Dependent crate licenses
# owo-colors is MIT but notated as LICENCE
LICENSE+="
	Apache-2.0 BSD-2 BSD Boost-1.0 CC0-1.0 MIT MPL-2.0 Unicode-DFS-2016
"

SLOT="0"
KEYWORDS="~amd64 ~arm64"
IUSE="doc"

DEPEND+="
	net-misc/curl
	dev-libs/openssl
	sys-libs/zlib
"

QA_FLAGS_IGNORED="usr/bin/rink"

src_configure() {
	# RINK_PATH is used in the build process to define the data file location
	export RINK_PATH=/usr/share/rink
	cargo_src_configure --no-default-features
}

src_install() {
	cargo_src_install --path cli

	insinto /usr/share/rink
	doins core/definitions.units
	doins core/currency.units
	doins core/datepatterns.txt

	newicon -s 192 "${S}/web/site/images/icons/icon-192x192.png" rink.png
	newicon -s 512 "${S}/web/site/images/icons/icon-512x512.png" rink.png
	# rink.desktop is in the tree, but not part of 0.8.0
	# newmenu "cli/rink.desktop" "rink.desktop"
	make_desktop_entry "/usr/bin/rink" Rink rink "Utility;Calculator;ConsoleOnly"

	doman build/rink.1
	doman build/rink.5
	doman build/rink.7
	doman build/rink-defs.5
	doman build/rink-dates.5

	if use doc; then
		local DOCS=( README.md )
		local HTML_DOCS=(
			build/rink.1.html
			build/rink.5.html
			build/rink.7.html
			build/rink-defs.5.html
			build/rink-dates.5.html
		)
		einstalldocs
	fi
}