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

# Crate list and dependent-crate licenses autogenerated by pycargoebuild 0.16.0

EAPI=8

CRATES="
	aho-corasick@1.1.5
	anyhow@1.0.104
	autocfg@1.5.1
	bitflags@2.13.2
	bstr@1.13.1
	build-context@0.1.4
	camino@1.2.5
	cargo-config2@0.1.45
	cfg-if@1.0.4
	duct@1.1.2
	errno@0.3.14
	fastrand@2.5.0
	filetime@0.2.29
	fs-err@3.3.1
	glob@0.3.4
	itoa@1.0.18
	lcov2cobertura@1.0.9
	lexopt@0.3.2
	libc@0.2.189
	linux-raw-sys@0.12.1
	memchr@2.8.3
	normpath@1.5.1
	once_cell@1.21.4
	opener@0.8.5
	os_pipe@1.2.3
	proc-macro2@1.0.107
	quick-xml@0.39.4
	quote@1.0.47
	regex-automata@0.4.18
	regex-syntax@0.8.11
	regex@1.13.1
	rustc-demangle@0.1.28
	rustix@1.1.4
	rustversion@1.0.23
	ruzstd@0.9.0
	same-file@1.0.6
	serde@1.0.229
	serde_core@1.0.229
	serde_derive@1.0.229
	serde_json@1.0.151
	serde_spanned@1.1.1
	shared_child@1.1.2
	shared_thread@0.2.1
	shell-escape@0.1.5
	syn@3.0.5
	tar@0.4.46
	tempfile@3.27.0
	termcolor@1.4.1
	toml@1.1.6+spec-1.1.0
	toml_datetime@1.1.1+spec-1.1.0
	toml_parser@1.1.3+spec-1.1.0
	unicode-ident@1.0.24
	walkdir@2.5.0
	winapi-util@0.1.11
	windows-link@0.2.1
	windows-sys@0.61.2
	winnow@1.0.4
	xattr@1.6.1
	zmij@1.0.23
"

RUST_MIN_VER="1.87.0"

inherit cargo

DESCRIPTION="Cargo subcommand for LLVM source-based code coverage"
HOMEPAGE="https://github.com/taiki-e/cargo-llvm-cov"
SRC_URI="https://github.com/taiki-e/cargo-llvm-cov/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
SRC_URI+=" ${CARGO_CRATE_URIS}"

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

# The .crate files are not mirrored by Gentoo.
RESTRICT="mirror"
# The suite needs the test-helper dev-dependency dropped in src_prepare,
# and drives cargo against fixture crates over the network.
RESTRICT+=" test"

# Rust does not use *FLAGS from make.conf; silence the portage warning.
QA_FLAGS_IGNORED="usr/bin/cargo-llvm-cov"

src_prepare() {
	default

	# test-helper is a dev-dependency pulled straight from git at a pinned
	# rev. cargo.eclass can vendor it, but its [patch] entry does not
	# substitute a git source pinned with `rev`, so cargo insists on reaching
	# the network even with the tarball unpacked next to it. Since cargo
	# resolves the whole graph before it knows we only want the binary, the
	# dependency has to go rather than merely be ignored -- which is harmless
	# here because it is only ever used by the test suite, and that suite is
	# restricted below.
	grep -qF 'test-helper = {' Cargo.toml ||
		die "test-helper dev-dependency not found in Cargo.toml"
	sed -i '/^test-helper = {/d' Cargo.toml || die
}

pkg_postinst() {
	elog "cargo-llvm-cov drives llvm-profdata and llvm-cov, and those must"
	elog "match the LLVM that built your Rust toolchain. dev-lang/rust ships"
	elog "them; with dev-lang/rust-bin you may need llvm-core/llvm installed"
	elog "at the matching major version."
}