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

# Auto-Generated by cargo-ebuild 0.5.4

EAPI=8

CRATES="
	adler@1.0.2
	adler32@1.2.0
	aho-corasick@0.7.18
	alloc-no-stdlib@2.0.3
	alloc-stdlib@0.2.1
	ansi_term@0.12.1
	anyhow@1.0.58
	async-trait@0.1.56
	atk@0.15.1
	atk-sys@0.15.1
	attohttpc@0.22.0
	atty@0.2.14
	autocfg@0.1.8
	autocfg@1.1.0
	base-x@0.2.11
	base64@0.13.0
	base64ct@1.1.1
	biliup@0.1.11
	bitflags@1.3.2
	block@0.1.6
	block-buffer@0.9.0
	block-buffer@0.10.2
	brotli@3.3.4
	brotli-decompressor@2.3.2
	bstr@0.2.17
	bumpalo@3.10.0
	bytemuck@1.10.0
	byteorder@1.4.3
	bytes@1.1.0
	cairo-rs@0.15.12
	cairo-sys-rs@0.15.1
	cargo_toml@0.13.0
	cc@1.0.73
	cesu8@1.1.0
	cfb@0.6.1
	cfg-expr@0.9.1
	cfg-expr@0.10.3
	cfg-if@1.0.0
	checked_int_cast@1.0.0
	chrono@0.4.19
	clap@3.2.12
	clap_derive@3.2.7
	clap_lex@0.2.4
	cocoa@0.24.0
	cocoa-foundation@0.1.0
	color_quant@1.1.0
	combine@4.6.4
	console@0.15.0
	const-oid@0.6.2
	const_fn@0.4.9
	convert_case@0.4.0
	cookie@0.15.1
	cookie@0.16.0
	cookie_store@0.15.1
	cookie_store@0.16.1
	core-foundation@0.9.3
	core-foundation-sys@0.8.3
	core-graphics@0.22.3
	core-graphics-types@0.1.1
	cpufeatures@0.2.2
	crc32fast@1.3.2
	crossbeam-channel@0.5.5
	crossbeam-deque@0.8.1
	crossbeam-epoch@0.9.9
	crossbeam-utils@0.8.10
	crypto-bigint@0.2.11
	crypto-common@0.1.6
	cssparser@0.27.2
	cssparser-macros@0.6.0
	ctor@0.1.22
	cty@0.2.2
	darling@0.13.4
	darling_core@0.13.4
	darling_macro@0.13.4
	dbus@0.9.6
	deflate@0.7.20
	deflate@0.8.6
	deflate@1.0.0
	der@0.4.5
	derive_more@0.99.17
	dialoguer@0.9.0
	digest@0.9.0
	digest@0.10.3
	dirs-next@2.0.0
	dirs-sys-next@0.1.2
	discard@1.0.4
	dispatch@0.2.0
	dtoa@0.4.8
	dtoa-short@0.3.3
	dunce@1.0.3
	either@1.7.0
	embed_plist@1.2.2
	encode_unicode@0.3.6
	encoding_rs@0.8.31
	fastrand@1.7.0
	field-offset@0.3.4
	filetime@0.2.17
	flate2@1.0.24
	fnv@1.0.7
	foreign-types@0.3.2
	foreign-types-shared@0.1.1
	form_urlencoded@1.1.0
	futf@0.1.5
	futures@0.3.21
	futures-channel@0.3.21
	futures-core@0.3.21
	futures-executor@0.3.21
	futures-io@0.3.21
	futures-macro@0.3.21
	futures-sink@0.3.21
	futures-task@0.3.21
	futures-util@0.3.21
	fxhash@0.2.1
	gdk@0.15.4
	gdk-pixbuf@0.15.11
	gdk-pixbuf-sys@0.15.10
	gdk-sys@0.15.1
	gdkx11-sys@0.15.1
	generator@0.7.1
	generic-array@0.14.5
	getrandom@0.1.16
	getrandom@0.2.7
	gif@0.11.4
	gio@0.15.12
	gio-sys@0.15.10
	glib@0.15.12
	glib-macros@0.15.11
	glib-sys@0.15.10
	glob@0.3.0
	globset@0.4.9
	gobject-sys@0.15.10
	gtk@0.15.5
	gtk-sys@0.15.3
	gtk3-macros@0.15.4
	h2@0.3.13
	hashbrown@0.11.2
	hashbrown@0.12.3
	heck@0.3.3
	heck@0.4.0
	hermit-abi@0.1.19
	html5ever@0.25.2
	http@0.2.8
	http-body@0.4.5
	http-range@0.1.5
	httparse@1.7.1
	httpdate@1.0.2
	hyper@0.14.20
	hyper-rustls@0.23.0
	hyper-tls@0.5.0
	ico@0.1.0
	ident_case@1.0.1
	idna@0.2.3
	idna@0.3.0
	ignore@0.4.18
	image@0.23.14
	image@0.24.2
	indexmap@1.9.1
	indicatif@0.17.0-rc.11
	infer@0.7.0
	inflate@0.3.4
	instant@0.1.12
	ipnet@2.5.0
	itoa@0.4.8
	itoa@1.0.2
	javascriptcore-rs@0.16.0
	javascriptcore-rs-sys@0.4.0
	jni@0.20.0
	jni-sys@0.3.0
	jpeg-decoder@0.1.22
	js-sys@0.3.58
	json-patch@0.2.6
	kuchiki@0.8.1
	lazy_static@1.4.0
	libc@0.2.126
	libdbus-sys@0.2.2
	libm@0.2.2
	line-wrap@0.1.1
	linked-hash-map@0.5.6
	lock_api@0.4.7
	log@0.4.17
	loom@0.5.6
	mac@0.1.1
	mac-notification-sys@0.5.5
	malloc_buf@0.0.6
	markup5ever@0.10.1
	matchers@0.1.0
	matches@0.1.9
	md-5@0.9.1
	memchr@2.5.0
	memoffset@0.6.5
	mime@0.3.16
	mime_guess@2.0.4
	miniz_oxide@0.3.7
	miniz_oxide@0.4.4
	miniz_oxide@0.5.3
	mio@0.8.4
	native-tls@0.2.10
	ndk@0.6.0
	ndk-context@0.1.1
	ndk-sys@0.3.0
	new_debug_unreachable@1.0.4
	nodrop@0.1.14
	notify-rust@4.5.8
	num-bigint-dig@0.7.0
	num-integer@0.1.45
	num-iter@0.1.43
	num-rational@0.3.2
	num-rational@0.4.1
	num-traits@0.2.15
	num_cpus@1.13.1
	num_enum@0.5.7
	num_enum_derive@0.5.7
	num_threads@0.1.6
	number_prefix@0.4.0
	objc@0.2.7
	objc-foundation@0.1.1
	objc_exception@0.1.2
	objc_id@0.1.1
	once_cell@1.16.0
	opaque-debug@0.3.0
	open@3.0.1
	openssl@0.10.41
	openssl-macros@0.1.0
	openssl-probe@0.1.5
	openssl-sys@0.9.75
	os_info@3.5.1
	os_pipe@1.0.1
	os_str_bytes@6.2.0
	pango@0.15.10
	pango-sys@0.15.10
	parking_lot@0.12.1
	parking_lot_core@0.9.3
	paste@1.0.7
	pathdiff@0.2.1
	pem-rfc7468@0.2.4
	percent-encoding@2.2.0
	pest@2.1.3
	phf@0.8.0
	phf@0.10.1
	phf_codegen@0.8.0
	phf_generator@0.8.0
	phf_generator@0.10.0
	phf_macros@0.8.0
	phf_macros@0.10.0
	phf_shared@0.8.0
	phf_shared@0.10.0
	pin-project-lite@0.2.9
	pin-utils@0.1.0
	pkcs1@0.2.4
	pkcs8@0.7.6
	pkg-config@0.3.25
	plist@1.3.1
	png@0.11.0
	png@0.16.8
	png@0.17.5
	ppv-lite86@0.2.16
	precomputed-hash@0.1.1
	proc-macro-crate@1.1.3
	proc-macro-error@1.0.4
	proc-macro-error-attr@1.0.4
	proc-macro-hack@0.5.19
	proc-macro2@1.0.40
	psl-types@2.0.10
	publicsuffix@2.1.1
	qrcode@0.12.0
	quote@1.0.20
	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.3
	rand_hc@0.2.0
	rand_pcg@0.2.1
	raw-window-handle@0.5.0
	rayon@1.5.3
	rayon-core@1.9.3
	redox_syscall@0.2.13
	redox_users@0.4.3
	regex@1.6.0
	regex-automata@0.1.10
	regex-syntax@0.6.27
	remove_dir_all@0.5.3
	reqwest@0.11.11
	reqwest-middleware@0.1.6
	reqwest-retry@0.1.5
	reqwest_cookie_store@0.2.0
	retry-policies@0.1.1
	rfd@0.10.0
	ring@0.16.20
	rsa@0.5.0
	rustc_version@0.2.3
	rustc_version@0.3.3
	rustc_version@0.4.0
	rustls@0.20.6
	rustls-pemfile@1.0.0
	rustversion@1.0.8
	ryu@1.0.10
	safemem@0.3.3
	same-file@1.0.6
	schannel@0.1.20
	scoped-tls@1.0.0
	scoped_threadpool@0.1.9
	scopeguard@1.1.0
	sct@0.7.0
	security-framework@2.6.1
	security-framework-sys@2.6.1
	selectors@0.22.0
	semver@0.9.0
	semver@0.11.0
	semver@1.0.12
	semver-parser@0.7.0
	semver-parser@0.10.2
	serde@1.0.147
	serde_derive@1.0.147
	serde_json@1.0.82
	serde_repr@0.1.8
	serde_urlencoded@0.7.1
	serde_with@1.14.0
	serde_with_macros@1.5.2
	serde_yaml@0.8.26
	serialize-to-javascript@0.1.1
	serialize-to-javascript-impl@0.1.1
	servo_arc@0.1.1
	sha1@0.6.1
	sha1_smol@1.0.0
	sha2@0.10.2
	sharded-slab@0.1.4
	shared_child@1.0.0
	signal-hook-registry@1.4.0
	siphasher@0.3.10
	slab@0.4.6
	smallvec@1.9.0
	socket2@0.4.4
	soup2@0.2.1
	soup2-sys@0.2.0
	spin@0.5.2
	spki@0.4.1
	stable_deref_trait@1.2.0
	standback@0.2.17
	state@0.5.3
	stdweb@0.4.20
	stdweb-derive@0.5.3
	stdweb-internal-macros@0.2.9
	stdweb-internal-runtime@0.1.5
	string_cache@0.8.4
	string_cache_codegen@0.5.2
	strsim@0.10.0
	strum@0.22.0
	strum_macros@0.22.0
	subtle@2.4.1
	syn@1.0.98
	synstructure@0.12.6
	system-deps@5.0.0
	system-deps@6.0.2
	tao@0.15.3
	tar@0.4.38
	task-local-extensions@0.1.1
	tauri@1.2.0
	tauri-build@1.2.0
	tauri-codegen@1.2.0
	tauri-macros@1.2.0
	tauri-runtime@0.12.0
	tauri-runtime-wry@0.12.0
	tauri-utils@1.2.0
	tempfile@3.3.0
	tendril@0.4.3
	termcolor@1.1.3
	terminal_size@0.1.17
	textwrap@0.15.0
	thin-slice@0.1.1
	thiserror@1.0.31
	thiserror-impl@1.0.31
	thread_local@1.1.4
	tiff@0.6.1
	time@0.2.27
	time@0.3.11
	time-macros@0.1.1
	time-macros@0.2.4
	time-macros-impl@0.1.2
	tinyvec@1.6.0
	tinyvec_macros@0.1.0
	tokio@1.20.0
	tokio-macros@1.8.0
	tokio-native-tls@0.3.0
	tokio-rustls@0.23.4
	tokio-util@0.7.3
	toml@0.5.9
	tower-service@0.3.2
	tracing@0.1.35
	tracing-appender@0.2.2
	tracing-attributes@0.1.22
	tracing-core@0.1.28
	tracing-log@0.1.3
	tracing-subscriber@0.3.14
	treediff@3.0.2
	try-lock@0.2.3
	typed-builder@0.9.1
	typenum@1.15.0
	ucd-trie@0.1.4
	unicase@2.6.0
	unicode-bidi@0.3.8
	unicode-ident@1.0.2
	unicode-normalization@0.1.21
	unicode-segmentation@1.10.0
	unicode-width@0.1.9
	unicode-xid@0.2.3
	untrusted@0.7.1
	url@2.3.1
	utf-8@0.7.6
	uuid@0.8.2
	uuid@1.2.1
	valuable@0.1.0
	vcpkg@0.2.15
	version-compare@0.0.11
	version-compare@0.1.0
	version_check@0.9.4
	walkdir@2.3.2
	want@0.3.0
	wasi@0.9.0+wasi-snapshot-preview1
	wasi@0.11.0+wasi-snapshot-preview1
	wasm-bindgen@0.2.81
	wasm-bindgen-backend@0.2.81
	wasm-bindgen-futures@0.4.31
	wasm-bindgen-macro@0.2.81
	wasm-bindgen-macro-support@0.2.81
	wasm-bindgen-shared@0.2.81
	web-sys@0.3.58
	webkit2gtk@0.18.2
	webkit2gtk-sys@0.18.0
	webpki@0.22.0
	webpki-roots@0.22.4
	webview2-com@0.19.1
	webview2-com-macros@0.6.0
	webview2-com-sys@0.19.0
	weezl@0.1.7
	winapi@0.3.9
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.5
	winapi-x86_64-pc-windows-gnu@0.4.0
	windows@0.24.0
	windows@0.32.0
	windows@0.37.0
	windows@0.39.0
	windows-bindgen@0.39.0
	windows-implement@0.39.0
	windows-metadata@0.39.0
	windows-sys@0.36.1
	windows-tokens@0.39.0
	windows_aarch64_msvc@0.32.0
	windows_aarch64_msvc@0.36.1
	windows_aarch64_msvc@0.37.0
	windows_aarch64_msvc@0.39.0
	windows_i686_gnu@0.24.0
	windows_i686_gnu@0.32.0
	windows_i686_gnu@0.36.1
	windows_i686_gnu@0.37.0
	windows_i686_gnu@0.39.0
	windows_i686_msvc@0.24.0
	windows_i686_msvc@0.32.0
	windows_i686_msvc@0.36.1
	windows_i686_msvc@0.37.0
	windows_i686_msvc@0.39.0
	windows_x86_64_gnu@0.24.0
	windows_x86_64_gnu@0.32.0
	windows_x86_64_gnu@0.36.1
	windows_x86_64_gnu@0.37.0
	windows_x86_64_gnu@0.39.0
	windows_x86_64_msvc@0.24.0
	windows_x86_64_msvc@0.32.0
	windows_x86_64_msvc@0.36.1
	windows_x86_64_msvc@0.37.0
	windows_x86_64_msvc@0.39.0
	winreg@0.10.1
	winres@0.1.12
	winrt-notification@0.5.1
	wry@0.22.0
	x11@2.19.1
	x11-dl@2.20.0
	xattr@0.2.3
	xml-rs@0.8.4
	yaml-rust@0.4.5
	zeroize@1.4.3
	zeroize_derive@1.3.2
"

inherit desktop cargo xdg

MY_P="${PN}-app-v${PV}"

DESCRIPTION="A Tool for Upload video to bilibili"
# Double check the homepage as the cargo_metadata crate
# does not provide this value so instead repository is used
# tauri package need node_modules, see https://github.com/123485k/gentoo-tauri-node-dep
HOMEPAGE="https://github.com/ForgQi/biliup-app"
SRC_URI="
	https://github.com/ForgQi/${PN}/archive/refs/tags/app-v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/123485k/gentoo-tauri-node-dep/releases/download/${P}/${P}-node_modules.tar.xz
	${CARGO_CRATE_URIS}"
S="${WORKDIR}/${MY_P}"
# License set may be more restrictive as OR is not respected
# use cargo-license for a more accurate license picture
LICENSE="0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD Boost-1.0 CC0-1.0 ISC MIT MIT-0 MPL-2.0 Unicode-DFS-2016 Unlicense ZLIB"
SLOT="0"
KEYWORDS="~amd64 ~arm64"
IUSE="debug"
DEPEND="
	net-libs/webkit-gtk:4
	x11-libs/gtk+:3
	net-libs/nodejs[npm]
"
RDEPEND="
	${DEPEND}
	!net-misc/biliup-app-bin
"

# rust does not use *FLAGS from make.conf, silence portage warning
# update with proper path to binaries this crate installs, omit leading /
QA_FLAGS_IGNORED="usr/bin/${PN}"

src_prepare() {
	eapply_user
	ln -sf "${WORKDIR}/node_modules" "${S}/" || die
}

src_configure() {
	local myfeatures=(
	# use tauri build and run ps -ef | grep cargo | head to get features
		custom-protocol
	)
	cargo_src_configure
}

src_compile() {
	npm run build || die
	cd "${WORKDIR}/${MY_P}"/src-tauri || die
	cargo_src_compile
}

src_install() {
	cd "${WORKDIR}/${MY_P}"/src-tauri || die
	MY_CARGO_BUILD_DIR=$(cargo_target_dir)
	newbin "${MY_CARGO_BUILD_DIR}"/app "${PN}"
	newicon -s 256 "${S}/src-tauri/icons/128x128@2x.png" "${PN}.png"
	newicon -s 128 "${S}/src-tauri/icons/128x128.png" "${PN}.png"
	newicon -s 32 "${S}/src-tauri/icons/32x32.png" "${PN}.png"
	domenu "${FILESDIR}/${PN}.desktop"
}