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

# Autogenerated by pycargoebuild 0.10

EAPI=8

CRATES="
	adler@1.0.2
	ahash@0.7.6
	aho-corasick@0.7.20
	aho-corasick@1.0.1
	alloc-no-stdlib@2.0.4
	alloc-stdlib@0.2.2
	android_system_properties@0.1.5
	anyhow@1.0.71
	async-broadcast@0.5.1
	async-channel@1.8.0
	async-executor@1.5.1
	async-fs@1.6.0
	async-io@1.13.0
	async-lock@2.7.0
	async-process@1.7.0
	async-recursion@1.0.4
	async-task@4.4.0
	async-trait@0.1.68
	atk-sys@0.15.1
	atk@0.15.1
	atomic-waker@1.1.1
	attohttpc@0.22.0
	atty@0.2.14
	auto-launch@0.4.0
	autocfg@1.1.0
	base64@0.13.1
	base64@0.21.0
	bincode@1.3.3
	bitflags@1.3.2
	bitflags@2.2.1
	block-buffer@0.10.4
	block@0.1.6
	blocking@1.3.1
	brotli-decompressor@2.3.4
	brotli@3.3.4
	bstr@1.4.0
	bumpalo@3.12.2
	byte-unit@4.0.19
	bytemuck@1.13.1
	byteorder@1.4.3
	bytes@1.4.0
	cairo-rs@0.15.12
	cairo-sys-rs@0.15.1
	cargo_toml@0.15.2
	cc@1.0.79
	cesu8@1.1.0
	cfb@0.7.3
	cfg-expr@0.15.1
	cfg-expr@0.9.1
	cfg-if@1.0.0
	chrono@0.4.24
	cocoa-foundation@0.1.1
	cocoa@0.24.1
	color_quant@1.1.0
	colored@1.9.3
	combine@4.6.6
	concurrent-queue@2.2.0
	convert_case@0.4.0
	core-foundation-sys@0.8.4
	core-foundation@0.9.3
	core-graphics-types@0.1.1
	core-graphics@0.22.3
	cpufeatures@0.2.7
	crc32fast@1.3.2
	crossbeam-channel@0.5.8
	crossbeam-utils@0.8.15
	crypto-common@0.1.6
	cssparser-macros@0.6.0
	cssparser@0.27.2
	csv-core@0.1.10
	csv@1.2.1
	ctor@0.1.26
	cty@0.2.2
	dark-light@1.0.0
	darling@0.20.1
	darling_core@0.20.1
	darling_macro@0.20.1
	dconf_rs@0.3.0
	derivative@2.2.0
	derive_more@0.99.17
	detect-desktop-environment@0.2.0
	digest@0.10.6
	dirs-next@2.0.0
	dirs-sys-next@0.1.2
	dirs-sys@0.3.7
	dirs@4.0.0
	dispatch@0.2.0
	dlv-list@0.3.0
	dtoa-short@0.3.3
	dtoa@0.4.8
	dunce@1.0.4
	embed-resource@2.1.1
	embed_plist@1.2.2
	encoding_rs@0.8.32
	enumflags2@0.7.7
	enumflags2_derive@0.7.7
	errno-dragonfly@0.1.2
	errno@0.3.1
	event-listener@2.5.3
	fastrand@1.9.0
	fdeflate@0.3.0
	fern@0.6.2
	field-offset@0.3.5
	filetime@0.2.21
	flate2@1.0.26
	fnv@1.0.7
	foreign-types-shared@0.1.1
	foreign-types@0.3.2
	form_urlencoded@1.1.0
	futf@0.1.5
	futures-channel@0.3.28
	futures-core@0.3.28
	futures-executor@0.3.28
	futures-io@0.3.28
	futures-lite@1.13.0
	futures-macro@0.3.28
	futures-sink@0.3.28
	futures-task@0.3.28
	futures-util@0.3.28
	fxhash@0.2.1
	gdk-pixbuf-sys@0.15.10
	gdk-pixbuf@0.15.11
	gdk-sys@0.15.1
	gdk@0.15.4
	gdkwayland-sys@0.15.3
	gdkx11-sys@0.15.1
	generator@0.7.4
	generic-array@0.14.7
	getrandom@0.1.16
	getrandom@0.2.9
	gio-sys@0.15.10
	gio@0.15.12
	glib-macros@0.15.13
	glib-sys@0.15.10
	glib@0.15.12
	glob@0.3.1
	globset@0.4.10
	gobject-sys@0.15.10
	gtk-sys@0.15.3
	gtk3-macros@0.15.6
	gtk@0.15.5
	h2@0.3.19
	hashbrown@0.12.3
	heck@0.3.3
	heck@0.4.1
	hermit-abi@0.1.19
	hermit-abi@0.2.6
	hermit-abi@0.3.1
	hex@0.4.3
	html5ever@0.25.2
	http-body@0.4.5
	http-range@0.1.5
	http@0.2.9
	httparse@1.8.0
	httpdate@1.0.2
	hyper-tls@0.5.0
	hyper@0.14.26
	iana-time-zone-haiku@0.1.2
	iana-time-zone@0.1.56
	ico@0.3.0
	ident_case@1.0.1
	idna@0.3.0
	ignore@0.4.18
	image@0.24.6
	indexmap@1.9.3
	infer@0.12.0
	instant@0.1.12
	io-lifetimes@1.0.10
	ipnet@2.7.2
	itoa@0.4.8
	itoa@1.0.6
	javascriptcore-rs-sys@0.4.0
	javascriptcore-rs@0.16.0
	jni-sys@0.3.0
	jni@0.20.0
	js-sys@0.3.63
	json-patch@1.0.0
	kuchiki@0.8.1
	lazy_static@1.4.0
	libappindicator-sys@0.7.3
	libappindicator@0.7.1
	libc@0.2.144
	libloading@0.7.4
	line-wrap@0.1.1
	linux-raw-sys@0.3.7
	lock_api@0.4.9
	log@0.4.17
	loom@0.5.6
	mac@0.1.1
	malloc_buf@0.0.6
	markup5ever@0.10.1
	matchers@0.1.0
	matches@0.1.10
	memchr@2.5.0
	memoffset@0.7.1
	memoffset@0.8.0
	mime@0.3.17
	minisign-verify@0.2.1
	miniz_oxide@0.7.1
	mio@0.8.6
	native-tls@0.2.11
	ndk-context@0.1.1
	ndk-sys@0.3.0
	ndk@0.6.0
	new_debug_unreachable@1.0.4
	nix@0.26.2
	nodrop@0.1.14
	nu-ansi-term@0.46.0
	num-integer@0.1.45
	num-rational@0.4.1
	num-traits@0.2.15
	num_cpus@1.15.0
	num_enum@0.5.11
	num_enum_derive@0.5.11
	num_threads@0.1.6
	objc-foundation@0.1.1
	objc@0.2.7
	objc_exception@0.1.2
	objc_id@0.1.1
	once_cell@1.17.1
	open@3.2.0
	openssl-macros@0.1.1
	openssl-probe@0.1.5
	openssl-sys@0.9.87
	openssl@0.10.52
	ordered-multimap@0.4.3
	ordered-stream@0.2.0
	os_info@3.7.0
	os_pipe@1.1.4
	overload@0.1.1
	pango-sys@0.15.10
	pango@0.15.10
	parking@2.1.0
	parking_lot@0.12.1
	parking_lot_core@0.9.7
	pathdiff@0.2.1
	percent-encoding@2.2.0
	phf@0.10.1
	phf@0.8.0
	phf_codegen@0.8.0
	phf_generator@0.10.0
	phf_generator@0.8.0
	phf_macros@0.10.0
	phf_macros@0.8.0
	phf_shared@0.10.0
	phf_shared@0.8.0
	pin-project-lite@0.2.9
	pin-utils@0.1.0
	pkg-config@0.3.27
	plist@1.4.3
	png@0.17.8
	polling@2.8.0
	ppv-lite86@0.2.17
	precomputed-hash@0.1.1
	proc-macro-crate@1.3.1
	proc-macro-error-attr@1.0.4
	proc-macro-error@1.0.4
	proc-macro-hack@0.5.20+deprecated
	proc-macro2@1.0.57
	quick-xml@0.28.2
	quote@1.0.27
	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_hc@0.2.0
	rand_pcg@0.2.1
	raw-window-handle@0.5.0
	redox_syscall@0.2.16
	redox_syscall@0.3.5
	redox_users@0.4.3
	regex-automata@0.1.10
	regex-syntax@0.6.29
	regex-syntax@0.7.1
	regex@1.8.1
	reqwest@0.11.17
	rfd@0.10.0
	rust-ini@0.18.0
	rustc_version@0.4.0
	rustix@0.37.19
	rustversion@1.0.12
	ryu@1.0.13
	safemem@0.3.3
	same-file@1.0.6
	schannel@0.1.21
	scoped-tls@1.0.1
	scopeguard@1.1.0
	security-framework-sys@2.9.0
	security-framework@2.9.0
	selectors@0.22.0
	semver@1.0.17
	serde@1.0.163
	serde_derive@1.0.163
	serde_json@1.0.96
	serde_repr@0.1.12
	serde_spanned@0.6.1
	serde_urlencoded@0.7.1
	serde_with@2.3.3
	serde_with_macros@2.3.3
	serialize-to-javascript-impl@0.1.1
	serialize-to-javascript@0.1.1
	servo_arc@0.1.1
	sha1@0.10.5
	sha2@0.10.6
	sharded-slab@0.1.4
	shared_child@1.0.0
	signal-hook-registry@1.4.1
	signal-hook@0.3.15
	simd-adler32@0.3.5
	siphasher@0.3.10
	slab@0.4.8
	smallvec@1.10.0
	socket2@0.4.9
	soup2-sys@0.2.0
	soup2@0.2.1
	stable_deref_trait@1.2.0
	state@0.5.3
	static_assertions@1.1.0
	string_cache@0.8.7
	string_cache_codegen@0.5.2
	strsim@0.10.0
	syn@1.0.109
	syn@2.0.16
	system-deps@5.0.0
	system-deps@6.1.0
	tao-macros@0.1.1
	tao@0.16.1
	tar@0.4.38
	target-lexicon@0.12.7
	tauri-build@1.3.0
	tauri-codegen@1.3.0
	tauri-macros@1.3.0
	tauri-runtime-wry@0.13.0
	tauri-runtime@0.13.0
	tauri-utils@1.3.0
	tauri-winres@0.1.1
	tauri@1.3.0
	tempfile@3.5.0
	tendril@0.4.3
	thin-slice@0.1.1
	thiserror-impl@1.0.40
	thiserror@1.0.40
	thread_local@1.1.7
	time@0.3.15
	tinyvec@1.6.0
	tinyvec_macros@0.1.1
	tokio-macros@2.1.0
	tokio-native-tls@0.3.1
	tokio-util@0.7.8
	tokio@1.28.1
	toml@0.5.11
	toml@0.7.3
	toml_datetime@0.6.1
	toml_edit@0.19.8
	tower-service@0.3.2
	tracing-attributes@0.1.24
	tracing-core@0.1.31
	tracing-log@0.1.3
	tracing-subscriber@0.3.17
	tracing@0.1.37
	treediff@4.0.2
	try-lock@0.2.4
	typenum@1.16.0
	uds_windows@1.0.2
	unicode-bidi@0.3.13
	unicode-ident@1.0.8
	unicode-normalization@0.1.22
	unicode-segmentation@1.10.1
	url@2.3.1
	utf-8@0.7.6
	utf8-width@0.1.6
	uuid@1.3.3
	valuable@0.1.0
	value-bag@1.0.0-alpha.9
	vcpkg@0.2.15
	version-compare@0.0.11
	version-compare@0.1.1
	version_check@0.9.4
	vswhom-sys@0.1.2
	vswhom@0.1.0
	waker-fn@1.1.0
	walkdir@2.3.3
	want@0.3.0
	wasi@0.11.0+wasi-snapshot-preview1
	wasi@0.9.0+wasi-snapshot-preview1
	wasm-bindgen-backend@0.2.86
	wasm-bindgen-futures@0.4.36
	wasm-bindgen-macro-support@0.2.86
	wasm-bindgen-macro@0.2.86
	wasm-bindgen-shared@0.2.86
	wasm-bindgen@0.2.86
	web-sys@0.3.63
	webkit2gtk-sys@0.18.0
	webkit2gtk@0.18.2
	webview2-com-macros@0.6.0
	webview2-com-sys@0.19.0
	webview2-com@0.19.1
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.5
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-bindgen@0.39.0
	windows-implement@0.39.0
	windows-metadata@0.39.0
	windows-sys@0.42.0
	windows-sys@0.45.0
	windows-sys@0.48.0
	windows-targets@0.42.2
	windows-targets@0.48.0
	windows-tokens@0.39.0
	windows@0.37.0
	windows@0.39.0
	windows@0.48.0
	windows_aarch64_gnullvm@0.42.2
	windows_aarch64_gnullvm@0.48.0
	windows_aarch64_msvc@0.37.0
	windows_aarch64_msvc@0.39.0
	windows_aarch64_msvc@0.42.2
	windows_aarch64_msvc@0.48.0
	windows_i686_gnu@0.37.0
	windows_i686_gnu@0.39.0
	windows_i686_gnu@0.42.2
	windows_i686_gnu@0.48.0
	windows_i686_msvc@0.37.0
	windows_i686_msvc@0.39.0
	windows_i686_msvc@0.42.2
	windows_i686_msvc@0.48.0
	windows_x86_64_gnu@0.37.0
	windows_x86_64_gnu@0.39.0
	windows_x86_64_gnu@0.42.2
	windows_x86_64_gnu@0.48.0
	windows_x86_64_gnullvm@0.42.2
	windows_x86_64_gnullvm@0.48.0
	windows_x86_64_msvc@0.37.0
	windows_x86_64_msvc@0.39.0
	windows_x86_64_msvc@0.42.2
	windows_x86_64_msvc@0.48.0
	winnow@0.4.1
	winreg@0.10.1
	winreg@0.11.0
	wry@0.24.3
	x11-dl@2.21.0
	x11@2.21.0
	xattr@0.2.3
	xdg-home@1.0.0
	zbus@3.13.1
	zbus_macros@3.13.1
	zbus_names@2.5.1
	zip@0.6.6
	zvariant@3.14.0
	zvariant_derive@3.14.0
	zvariant_utils@1.0.1
"

declare -A GIT_CRATES=(
	[tauri-plugin-autostart]='https://github.com/lencx/tauri-plugins-workspace;bec9f6091a5a5233bc464754ebb215d07363b747;tauri-plugins-workspace-%commit%/plugins/autostart'
	[tauri-plugin-log]='https://github.com/lencx/tauri-plugins-workspace;bec9f6091a5a5233bc464754ebb215d07363b747;tauri-plugins-workspace-%commit%/plugins/log'
	[tauri-plugin-positioner]='https://github.com/lencx/tauri-plugins-workspace;bec9f6091a5a5233bc464754ebb215d07363b747;tauri-plugins-workspace-%commit%/plugins/positioner'
	[tauri-plugin-window-state]='https://github.com/lencx/tauri-plugins-workspace;bec9f6091a5a5233bc464754ebb215d07363b747;tauri-plugins-workspace-%commit%/plugins/window-state'
)

inherit cargo xdg desktop toolchain-funcs

MY_PN="ChatGPT"
DESCRIPTION="ChatGPT Desktop Application"
HOMEPAGE="
	https://nofwl.com
	https://github.com/lencx/ChatGPT
"
SRC_URI="
	https://github.com/lencx/${MY_PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}
"
SRC_URI+="
	https://github.com/liuyujielol/gentoo-go-deps/releases/download/${P}/${P}-node_modules.tar.xz
"

LICENSE="MIT"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD ISC MIT MPL-2.0
	Unicode-DFS-2016
"
SLOT="0"
KEYWORDS="~amd64"

RESTRICT="mirror strip"

DEPEND="
	net-libs/webkit-gtk:4
	x11-misc/appmenu-gtk-module
	x11-libs/gtk+:3
	gnome-base/librsvg
	media-libs/vips
	dev-libs/libayatana-appindicator
	dev-libs/openssl
"
RDEPEND="${DEPEND}"
BDEPEND="
	>=dev-util/tauri-cli-1.3.1
	<dev-util/tauri-cli-2
	net-libs/nodejs[npm]
	dev-lang/typescript
"

S="${WORKDIR}/${MY_PN}-${PV}"

src_prepare() {
	ln -sv "${WORKDIR}/node_modules" "${S}/node_modules" || die
	mkdir -v "${S}/dist" || die
	default
}

src_compile() {
	debug-print-function ${FUNCNAME} "$@"

	[[ ${_CARGO_GEN_CONFIG_HAS_RUN} ]] ||
		die "FATAL: please call cargo_gen_config before using ${FUNCNAME}"

	tc-export AR CC CXX PKG_CONFIG

	set -- cargo tauri build --bundles app $(usex debug --debug "") ${ECARGO_ARGS[@]} "$@"
	einfo "${@}"
	"${@}" || die "cargo build failed"
}

src_install() {
	newbin "${S}/target/$(usex debug debug release)/chat-gpt" "${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"

	make_desktop_entry "${PN}" "ChatGPT Desktop" "${PN}" "Development;"
}