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

# Autogenerated by pycargoebuild 0.15.1

EAPI=8

CRATES="
	adler2@2.0.1
	anstream@1.0.0
	anstyle-parse@1.0.0
	anstyle-query@1.1.5
	anstyle-wincon@3.0.11
	anstyle@1.0.14
	autocfg@1.5.0
	bitflags@2.11.1
	bitvec@1.0.1
	bumpalo@3.20.2
	bytemuck@1.25.0
	byteorder-lite@0.1.0
	cc@1.2.60
	cfg-if@1.0.4
	clap@4.6.1
	clap_builder@4.6.0
	clap_lex@1.1.0
	colorchoice@1.0.5
	crc32fast@1.5.0
	crossbeam-deque@0.8.6
	crossbeam-epoch@0.9.18
	crossbeam-utils@0.8.21
	either@1.15.0
	env_filter@1.0.1
	env_logger@0.11.10
	equivalent@1.0.2
	errno@0.3.14
	fdeflate@0.3.7
	find-msvc-tools@0.1.9
	flate2@1.1.9
	funty@2.0.0
	glob@0.3.3
	hashbrown@0.17.0
	image@0.25.9
	indexmap@2.14.0
	is_terminal_polyfill@1.70.2
	itoa@1.0.18
	libc@0.2.185
	libdeflate-sys@1.25.2
	libdeflater@1.25.2
	linux-raw-sys@0.12.1
	log@0.4.29
	memchr@2.8.0
	miniz_oxide@0.8.9
	moxcms@0.7.11
	num-traits@0.2.19
	once_cell_polyfill@1.70.2
	parse-size@1.1.0
	pkg-config@0.3.33
	png@0.18.1
	proc-macro2@1.0.106
	pxfm@0.1.29
	quote@1.0.45
	radium@0.7.0
	rayon-core@1.13.0
	rayon@1.12.0
	rgb@0.8.53
	rustc-hash@2.1.2
	rustix@1.1.4
	serde@1.0.228
	serde_core@1.0.228
	serde_derive@1.0.228
	serde_json@1.0.149
	shlex@1.3.0
	simd-adler32@0.3.9
	strsim@0.11.1
	syn@2.0.117
	tap@1.0.1
	terminal_size@0.4.4
	unicode-ident@1.0.24
	utf8parse@0.2.2
	windows-link@0.2.1
	windows-sys@0.61.2
	wyz@0.5.1
	zmij@1.0.21
	zopfli@0.8.3
"

RUST_MIN_VER="1.85.1"

inherit cargo

DESCRIPTION="Multithreaded lossless PNG compression optimizer written in Rust"
HOMEPAGE="https://github.com/oxipng/oxipng"
SRC_URI="
	https://github.com/oxipng/oxipng/archive/v${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}
"

LICENSE="MIT"
# Dependent crate licenses
LICENSE+=" Apache-2.0 MIT Unicode-3.0"
SLOT="0"
KEYWORDS="~amd64 ~arm64 ~riscv ~x86"

BDEPEND="virtual/pkgconfig"
DEPEND=">=app-arch/libdeflate-1.23"
RDEPEND="${DEPEND}"

PATCHES=(
	"${FILESDIR}"/oxipng-10.0.0-nostrip.patch
)

# 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() {
	pushd "${WORKDIR}" || die
	eapply "${FILESDIR}"/oxipng-10.1.1-libdeflater-1.25.2-relax-libdeflate-sys-version.patch
	popd > /dev/null || die

	# Remove the linker configs (in `.cargo/config.toml`) specific to GitHub CI.
	# https://bugs.gentoo.org/924946
	rm -rv "${S}/.cargo/config.toml" || die

	default_src_prepare
}

src_configure() {
	export PKG_CONFIG_ALLOW_CROSS=1
	local myfeatures=(
		system-libdeflate
	)

	cargo_src_configure
}

src_install() {
	cargo_src_install

	dodoc CHANGELOG.md README.md
}
