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

# Autogenerated by pycargoebuild 0.15.1

EAPI=8

RUST_MIN_VER="1.88.0"

CRATES="
"

inherit cargo

DESCRIPTION="TUI Program for Custom Proton Download and installation written in rust"
HOMEPAGE="https://github.com/auyer/Protonup-rs"

SRC_URI="
	https://github.com/auyer/Protonup-rs/archive/v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/gentoo-crate-dist/Protonup-rs/releases/download/v${PV}/Protonup-rs-${PV}-crates.tar.xz ->
	${P}-crates.tar.xz
"

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

LICENSE="GPL-3"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD CDLA-Permissive-2.0 ISC MIT MPL-2.0 Unicode-3.0 ZLIB
"
SLOT="0"
KEYWORDS="~amd64"
# apply-crates-fixes start
DEPEND="
	>=app-arch/zstd-1.5.7
"
RDEPEND="
	>=app-arch/zstd-1.5.7
"
# apply-crates-fixes end

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

DOCS=( README.md docs )

# apply-crates-fixes start
src_compile(){
	export ZSTD_SYS_USE_PKG_CONFIG=1 # fix for zstd-sys crate
	export AWS_LC_SYS_CFLAGS="${CFLAGS} -O0"
	# aws-lc-sys bundles aws-lc, which bundles quite a lot of dependencies, jitterentropy among them
	# https://github.com/aws/aws-lc-rs/issues/936 -> "Please add support to use system-provided aws-lc library"
	# jitterentropy can not be built without -O0, the script does not have the logic to unbundle dependencies right now
	# but what it can do is use set the AWS_LC_SYS_CFLAGS var to override CFLAGS
	cargo_src_compile
}
# apply-crates-fixes end
src_test(){
	local CARGO_SKIP_TESTS=(
		'downloads::tests::test_get_release'
		'downloads::tests::test_list_releases'
	)
	cargo_src_test
}

src_install(){
	cargo_src_install --path "${S}/${PN}"
	einstalldocs
}