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

EAPI=8

CRATES="
	addr2line@0.24.2
	adler2@2.0.0
	ahash@0.8.11
	aho-corasick@1.1.3
	allocator-api2@0.2.21
	android-tzdata@0.1.1
	android_system_properties@0.1.5
	anstream@0.6.18
	anstyle-parse@0.2.6
	anstyle-query@1.1.2
	anstyle-wincon@3.0.7
	anstyle@1.0.10
	anyhow@1.0.97
	async-compression@0.4.21
	async_zip@0.0.17
	atoi@2.0.0
	atomic-waker@1.1.2
	autocfg@1.4.0
	backtrace@0.3.74
	base64@0.21.7
	base64@0.22.1
	base64ct@1.7.3
	bitflags@2.9.0
	block-buffer@0.10.4
	bumpalo@3.17.0
	byteorder@1.5.0
	bytes@1.10.1
	cc@1.2.16
	cfg-if@1.0.0
	cfg_aliases@0.2.1
	chrono@0.4.40
	clap@4.5.32
	clap_builder@4.5.32
	clap_derive@4.5.32
	clap_lex@0.7.4
	colorchoice@1.0.3
	const-oid@0.9.6
	core-foundation-sys@0.8.7
	core-foundation@0.9.4
	cpufeatures@0.2.17
	crc-catalog@2.4.0
	crc32fast@1.4.2
	crc@3.2.1
	crossbeam-queue@0.3.12
	crossbeam-utils@0.8.21
	crypto-common@0.1.6
	data-encoding@2.8.0
	der@0.7.9
	derive-getters@0.3.0
	digest@0.10.7
	displaydoc@0.2.5
	dotenvy@0.15.7
	either@1.15.0
	encoding_rs@0.8.35
	env_filter@0.1.3
	env_logger@0.11.7
	equivalent@1.0.2
	errno@0.3.10
	etcetera@0.8.0
	event-listener@2.5.3
	fastrand@2.3.0
	flate2@1.1.0
	flume@0.11.1
	fnv@1.0.7
	form_urlencoded@1.2.1
	futures-channel@0.3.31
	futures-core@0.3.31
	futures-executor@0.3.31
	futures-intrusive@0.5.0
	futures-io@0.3.31
	futures-lite@2.6.0
	futures-macro@0.3.31
	futures-sink@0.3.31
	futures-task@0.3.31
	futures-util@0.3.31
	futures@0.3.31
	generic-array@0.14.7
	getrandom@0.2.15
	getrandom@0.3.2
	gimli@0.31.1
	h2@0.4.8
	hashbrown@0.14.5
	hashbrown@0.15.2
	hashlink@0.8.4
	heck@0.4.1
	heck@0.5.0
	hex@0.4.3
	hkdf@0.12.4
	hmac@0.12.1
	home@0.5.11
	http-body-util@0.1.3
	http-body@1.0.1
	http@1.3.1
	httparse@1.10.1
	hyper-rustls@0.27.5
	hyper-util@0.1.10
	hyper@1.6.0
	iana-time-zone-haiku@0.1.2
	iana-time-zone@0.1.61
	icu_collections@1.5.0
	icu_locid@1.5.0
	icu_locid_transform@1.5.0
	icu_locid_transform_data@1.5.0
	icu_normalizer@1.5.0
	icu_normalizer_data@1.5.0
	icu_properties@1.5.1
	icu_properties_data@1.5.0
	icu_provider@1.5.0
	icu_provider_macros@1.5.0
	idna@1.0.3
	idna_adapter@1.2.0
	indexmap@2.8.0
	ipnet@2.11.0
	is_terminal_polyfill@1.70.1
	itoa@1.0.15
	jiff-static@0.2.4
	jiff@0.2.4
	js-sys@0.3.77
	lazy_static@1.5.0
	libc@0.2.171
	libm@0.2.11
	libsqlite3-sys@0.27.0
	linux-raw-sys@0.4.15
	linux-raw-sys@0.9.3
	litemap@0.7.5
	lock_api@0.4.12
	log@0.4.26
	md-5@0.10.6
	memchr@2.7.4
	mime@0.3.17
	minimal-lexical@0.2.1
	miniz_oxide@0.8.5
	mio@1.0.3
	nom@7.1.3
	num-bigint-dig@0.8.4
	num-integer@0.1.46
	num-iter@0.1.45
	num-traits@0.2.19
	object@0.36.7
	once_cell@1.21.1
	parking@2.2.1
	parking_lot@0.12.3
	parking_lot_core@0.9.10
	paste@1.0.15
	pem-rfc7468@0.7.0
	percent-encoding@2.3.1
	pin-project-internal@1.1.10
	pin-project-lite@0.2.16
	pin-project@1.1.10
	pin-utils@0.1.0
	pkcs1@0.7.5
	pkcs8@0.10.2
	pkg-config@0.3.32
	portable-atomic-util@0.2.4
	portable-atomic@1.11.0
	ppv-lite86@0.2.21
	proc-macro2@1.0.94
	protobuf-codegen@3.7.2
	protobuf-parse@3.7.2
	protobuf-support@3.7.2
	protobuf@3.7.2
	protoc-bin-vendored-linux-aarch_64@3.1.0
	protoc-bin-vendored-linux-ppcle_64@3.1.0
	protoc-bin-vendored-linux-x86_32@3.1.0
	protoc-bin-vendored-linux-x86_64@3.1.0
	protoc-bin-vendored-macos-aarch_64@3.1.0
	protoc-bin-vendored-macos-x86_64@3.1.0
	protoc-bin-vendored-win32@3.1.0
	protoc-bin-vendored@3.1.0
	quinn-proto@0.11.10
	quinn-udp@0.5.10
	quinn@0.11.7
	quote@1.0.40
	r-efi@5.2.0
	rand@0.8.5
	rand@0.9.0
	rand_chacha@0.3.1
	rand_chacha@0.9.0
	rand_core@0.6.4
	rand_core@0.9.3
	redox_syscall@0.5.10
	regex-automata@0.4.9
	regex-syntax@0.8.5
	regex@1.11.1
	reqwest@0.12.15
	result@1.0.0
	ring@0.17.14
	rsa@0.9.8
	rustc-demangle@0.1.24
	rustc-hash@2.1.1
	rustix@0.38.44
	rustix@1.0.3
	rustls-pemfile@2.2.0
	rustls-pki-types@1.11.0
	rustls-webpki@0.102.8
	rustls-webpki@0.103.0
	rustls@0.22.4
	rustls@0.23.25
	rustversion@1.0.20
	ryu@1.0.20
	scopeguard@1.2.0
	serde@1.0.219
	serde_derive@1.0.219
	serde_ini@0.2.0
	serde_json@1.0.140
	serde_spanned@0.6.8
	serde_urlencoded@0.7.1
	sha1@0.10.6
	sha2@0.10.8
	shlex@1.3.0
	signal-hook-registry@1.4.2
	signature@2.2.0
	slab@0.4.9
	smallvec@1.14.0
	socket2@0.5.8
	spin@0.9.8
	spki@0.7.3
	sqlformat@0.2.6
	sqlx-core@0.7.4
	sqlx-macros-core@0.7.4
	sqlx-macros@0.7.4
	sqlx-mysql@0.7.4
	sqlx-postgres@0.7.4
	sqlx-sqlite@0.7.4
	sqlx@0.7.4
	stable_deref_trait@1.2.0
	stringprep@0.1.5
	strsim@0.11.1
	subtle@2.6.1
	syn@1.0.109
	syn@2.0.100
	sync_wrapper@1.0.2
	synstructure@0.13.1
	sys-locale@0.3.2
	system-configuration-sys@0.6.0
	system-configuration@0.6.1
	tempfile@3.19.1
	thiserror-impl@1.0.69
	thiserror-impl@2.0.12
	thiserror@1.0.69
	thiserror@2.0.12
	tinystr@0.7.6
	tinyvec@1.9.0
	tinyvec_macros@0.1.1
	tokio-macros@2.5.0
	tokio-rustls@0.25.0
	tokio-rustls@0.26.2
	tokio-stream@0.1.17
	tokio-tungstenite@0.21.0
	tokio-util@0.7.14
	tokio@1.44.1
	toml@0.8.20
	toml_datetime@0.6.8
	toml_edit@0.22.24
	tower-layer@0.3.3
	tower-service@0.3.3
	tower@0.5.2
	tracing-attributes@0.1.28
	tracing-core@0.1.33
	tracing@0.1.41
	try-lock@0.2.5
	tungstenite@0.21.0
	typenum@1.18.0
	unicode-bidi@0.3.18
	unicode-ident@1.0.18
	unicode-normalization@0.1.24
	unicode-properties@0.1.3
	unicode-segmentation@1.12.0
	unicode_categories@0.1.1
	untrusted@0.9.0
	url@2.5.4
	urlencoding@2.1.3
	utf-8@0.7.6
	utf16_iter@1.0.5
	utf8_iter@1.0.4
	utf8parse@0.2.2
	vcpkg@0.2.15
	version_check@0.9.5
	void@1.0.2
	want@0.3.1
	wasi@0.11.0+wasi-snapshot-preview1
	wasi@0.14.2+wasi-0.2.4
	wasite@0.1.0
	wasm-bindgen-backend@0.2.100
	wasm-bindgen-futures@0.4.50
	wasm-bindgen-macro-support@0.2.100
	wasm-bindgen-macro@0.2.100
	wasm-bindgen-shared@0.2.100
	wasm-bindgen@0.2.100
	wasm-streams@0.4.2
	web-sys@0.3.77
	web-time@1.1.0
	which@4.4.2
	whoami@1.5.2
	windows-core@0.52.0
	windows-link@0.1.1
	windows-registry@0.4.0
	windows-result@0.3.2
	windows-strings@0.3.1
	windows-sys@0.48.0
	windows-sys@0.52.0
	windows-sys@0.59.0
	windows-targets@0.48.5
	windows-targets@0.52.6
	windows-targets@0.53.0
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_gnullvm@0.53.0
	windows_aarch64_msvc@0.48.5
	windows_aarch64_msvc@0.52.6
	windows_aarch64_msvc@0.53.0
	windows_i686_gnu@0.48.5
	windows_i686_gnu@0.52.6
	windows_i686_gnu@0.53.0
	windows_i686_gnullvm@0.52.6
	windows_i686_gnullvm@0.53.0
	windows_i686_msvc@0.48.5
	windows_i686_msvc@0.52.6
	windows_i686_msvc@0.53.0
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnu@0.53.0
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_gnullvm@0.53.0
	windows_x86_64_msvc@0.48.5
	windows_x86_64_msvc@0.52.6
	windows_x86_64_msvc@0.53.0
	winnow@0.7.4
	wit-bindgen-rt@0.39.0
	write16@1.0.0
	writeable@0.5.5
	yoke-derive@0.7.5
	yoke@0.7.5
	zerocopy-derive@0.7.35
	zerocopy-derive@0.8.23
	zerocopy@0.7.35
	zerocopy@0.8.23
	zerofrom-derive@0.1.6
	zerofrom@0.1.6
	zeroize@1.8.1
	zerovec-derive@0.10.3
	zerovec@0.10.4
"

# Yepoleb/gog_protocols submodule commit at v${PV}
PROTO_COMMIT="923e8a0008603365d29002db611559190da5bf99"

inherit cargo

DESCRIPTION="Open source implementation of GOG Galaxy's Communication Service"
HOMEPAGE="https://github.com/imLinguin/comet"
SRC_URI="
	https://github.com/imLinguin/comet/archive/v${PV}.tar.gz -> ${P}.gh.tar.gz
	https://github.com/Yepoleb/gog_protocols/archive/${PROTO_COMMIT}.tar.gz
		-> gog_protocols-${PROTO_COMMIT}.gh.tar.gz
	${CARGO_CRATE_URIS}
"

LICENSE="GPL-3"
# Dependent crate licenses
LICENSE+=" Apache-2.0 BSD ISC MIT MPL-2.0 Unicode-3.0 ZLIB"
SLOT="0"
KEYWORDS="~amd64 ~arm64"
RESTRICT="mirror"

BDEPEND="dev-libs/protobuf"

QA_FLAGS_IGNORED="usr/bin/comet"

src_unpack() {
	cargo_src_unpack
	rmdir "${S}/proto" || die
	mv "${WORKDIR}/gog_protocols-${PROTO_COMMIT}" "${S}/proto" || die
}

src_prepare() {
	default
	# Only sets a cross linker for CI
	rm .cargo/config.toml || die
}

src_compile() {
	# Use the system protoc, not the prebuilt one from protoc-bin-vendored
	export PROTOC="${BROOT}/usr/bin/protoc"
	cargo_src_compile
}

src_install() {
	cargo_src_install
	dodoc README.md
}