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

# Autogenerated by pycargoebuild 0.16.0

EAPI=8

RUST_MIN_VER="1.91.0"
CRATES="
	aho-corasick@1.1.5
	annotate-snippets@0.12.16
	anstyle@1.0.14
	anyhow@1.0.104
	arraydeque@0.5.1
	assert_cmd@2.2.2
	assert_fs@1.1.4
	autocfg@1.5.1
	base64@0.23.1
	bit-set@0.11.1
	bit-vec@0.10.1
	bitflags@2.13.2
	borsh-derive@1.8.1
	borsh@1.8.1
	bstr@1.13.1
	bytes@1.12.1
	cc@1.10.0
	cfg-if@1.0.5
	cfg_aliases@0.2.2
	chacha20@0.10.2
	clap@4.6.7
	clap_builder@4.6.7
	clap_complete@4.6.11
	clap_derive@4.6.7
	clap_lex@1.1.1
	console@0.16.6
	core_detect@1.0.0
	cpufeatures@0.3.1
	crossbeam-deque@0.8.8
	crossbeam-epoch@0.9.21
	crossbeam-utils@0.8.23
	ctor@1.0.13
	difflib@0.4.0
	downcast@0.11.0
	encode_unicode@1.0.0
	encoding_rs@0.8.42
	encoding_rs_io@0.1.8
	env_filter@2.0.0
	env_logger@0.11.11
	equivalent@1.0.3
	errno@0.3.14
	fastrand@2.5.0
	find-msvc-tools@0.1.15
	float-cmp@0.10.0
	fnv@1.0.7
	fragile@2.1.0
	futures-core@0.3.34
	getrandom@0.4.3
	glob@0.3.4
	globset@0.4.20
	globwalk@0.9.1
	granit-parser@2.0.0
	hashbrown@0.17.1
	heck@0.5.0
	ignore@0.4.33
	indexmap@2.14.2
	insta@1.49.0
	itoa@1.0.18
	libc@0.2.191
	link-section@0.19.3
	linktime-proc-macro@0.2.3
	linux-raw-sys@0.12.1
	log@0.4.34
	memchr@2.8.3
	mockall@0.15.0
	mockall_derive@0.15.0
	multiversion_no_op@1.0.0
	nohash-hasher@0.2.0
	normalize-line-endings@0.3.0
	num-traits@0.2.19
	once_cell@1.21.4
	predicates-core@1.0.10
	predicates-tree@1.0.13
	predicates@3.1.4
	proc-macro-crate@3.5.0
	proc-macro2@1.0.107
	proptest@1.12.0
	quick-error@1.2.3
	quote@1.0.47
	r-efi@6.0.0
	rand@0.10.3
	rand_core@0.10.1
	rand_xorshift@0.5.0
	regex-automata@0.4.18
	regex-lite@0.1.9
	regex-syntax@0.8.11
	regex@1.13.1
	rustix@1.1.6
	rustversion@1.0.23
	rusty-fork@0.3.1
	same-file@1.0.6
	scopeguard@1.2.0
	serde-saphyr@2.0.0
	serde@1.0.229
	serde_core@1.0.229
	serde_derive@1.0.229
	serde_json@1.0.154
	shell-words@1.1.1
	shlex@2.0.1
	signal-hook-registry@1.4.8
	signal-hook@0.4.5
	simdutf8@0.1.5
	similar@2.7.0
	smallvec@1.16.3
	strsim@0.11.1
	syn@2.0.119
	syn@3.0.9
	tempfile@3.27.0
	termtree@0.5.1
	thiserror-impl@2.0.21
	thiserror@2.0.21
	toml_datetime@1.1.2+spec-1.1.0
	toml_edit@0.25.17+spec-1.1.0
	toml_parser@1.1.5+spec-1.1.0
	unarray@0.1.4
	unicode-ident@1.0.27
	unicode-width@0.2.2
	wait-timeout@0.2.1
	walkdir@2.5.0
	which@8.0.6
	winapi-util@0.1.11
	windows-link@0.2.1
	windows-sys@0.61.2
	winnow@1.0.4
	zmij@1.0.23
"

inherit cargo prefix toolchain-funcs

DESCRIPTION="A tool that generates a compilation database for clang tooling"
HOMEPAGE="https://github.com/rizsotto/Bear"
SRC_URI="
	https://github.com/rizsotto/Bear/archive/${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}
"
S="${WORKDIR}/${P^}"

LICENSE="GPL-3+"
# Dependent crate licenses
LICENSE+=" Apache-2.0 BSD MIT Unicode-3.0"
SLOT="0"
KEYWORDS="~amd64 ~arm64 ~loong ~ppc64 ~riscv ~x86"
RESTRICT="test"  # https://bugs.gentoo.org/973619

BDEPEND="llvm-core/lld"

QA_FLAGS_IGNORED="
	usr/libexec/bear/.*/libexec.so
	usr/libexec/bear/bin/bear-driver
	usr/libexec/bear/bin/bear-wrapper
"

src_compile() {
	gencompletions() {
		cargo_src_compile -p bear-completions

		# cargo_target_dir has different value in cross, but install
		# script expects generated completions to be in the same target dir
		"$(cargo_target_dir)"/generate-completions \
			"${T}"/completions || die
	}
	tc-env_build gencompletions

	cargo_src_compile
}

src_install() {
	mv "${T}/completions" "$(cargo_target_dir)/completions" || die

	SRCDIR="$(cargo_target_dir)" \
		DESTDIR="${D}" \
		PREFIX="${EPREFIX}/usr" \
		scripts/install.sh

	rm -r "${ED}"/usr/share/doc || die
	local DOCS=( *.md )
	default

	# use /bin/sh from prefix
	hprefixify "${ED}"/usr/bin/bear
}
