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

EAPI=8

CRATES="
	Inflector@0.11.4
	addr2line@0.27.1
	adler2@2.0.1
	aho-corasick@1.1.5
	allocator-api2@0.2.21
	anes@0.1.6
	anstream@1.0.0
	anstyle@1.0.14
	anstyle-parse@1.0.0
	anstyle-query@1.1.5
	anstyle-wincon@3.0.11
	anyhow@1.0.104
	approx@0.5.1
	ariadne@0.6.0
	arrayvec@0.7.8
	autocfg@1.5.1
	backtrace@0.3.77
	base64@0.23.1
	bincode@2.0.1
	bincode_derive@2.0.1
	bit-set@0.11.1
	bit-vec@0.10.2
	bitflags@2.13.2
	blake3@1.8.7
	blink-alloc@0.3.1
	block-buffer@0.12.1
	borsh@1.8.1
	borsh-derive@1.8.1
	bstr@1.13.1
	bumpalo@3.20.3
	bytes@1.12.1
	cast@0.3.0
	cc@1.11.1
	cfg-if@1.0.5
	cfg_aliases@0.2.2
	chacha20@0.10.2
	ciborium@0.2.2
	ciborium-io@0.2.2
	ciborium-ll@0.2.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
	codespan-reporting@0.13.1
	codspeed@4.7.0
	codspeed-criterion-compat@4.7.0
	codspeed-criterion-compat-walltime@4.7.0
	colorchoice@1.0.5
	colored@2.2.0
	colored@3.1.1
	console@0.16.6
	const-oid@0.10.3
	constant_time_eq@0.4.2
	cookie@0.18.2
	cookie_store@0.22.1
	core_detect@1.0.0
	cpufeatures@0.3.1
	crc32fast@1.5.5
	criterion-plot@0.5.0
	crossbeam-deque@0.8.8
	crossbeam-epoch@0.9.21
	crossbeam-utils@0.8.23
	crunchy@0.2.4
	crypto-common@0.2.2
	deranged@0.5.9
	dhat@0.3.3
	dialoguer@0.12.0
	diff@0.1.13
	diffy@0.5.2
	digest@0.11.3
	dirs@6.0.0
	dirs-sys@0.5.0
	displaydoc@0.2.7
	document-features@0.2.12
	dyn-clone@1.0.20
	either@1.19.0
	encode_unicode@1.0.0
	equivalent@1.0.3
	errno@0.3.15
	escape8259@0.5.4
	fastrand@2.5.0
	filetime@0.2.29
	find-msvc-tools@0.1.15
	flate2@1.1.11
	fnv@1.0.7
	foldhash@0.2.0
	form_urlencoded@1.2.2
	futures-core@0.3.34
	futures-task@0.3.34
	futures-util@0.3.34
	getopts@0.2.24
	getrandom@0.2.17
	getrandom@0.4.3
	gimli@0.34.0
	glob@0.3.4
	globset@0.4.21
	half@2.7.1
	hashbrown@0.17.1
	heck@0.5.0
	hermit-abi@0.5.3
	http@1.5.0
	httparse@1.10.1
	hybrid-array@0.4.15
	icu_collections@2.4.0
	icu_locale_core@2.4.0
	icu_normalizer@2.4.0
	icu_normalizer_data@2.4.0
	icu_properties@2.4.0
	icu_properties_data@2.4.0
	icu_provider@2.4.0
	idna@1.1.0
	idna_adapter@1.2.2
	ignore@0.4.34
	indexmap@2.14.2
	indicatif@0.18.6
	indoc@2.0.8
	inotify@0.11.5
	inotify-sys@0.1.8
	is-terminal@0.4.17
	is_terminal_polyfill@1.70.2
	itertools@0.10.5
	itertools@0.15.0
	itoa@1.0.19
	jobserver@0.1.35
	js-sys@0.3.107
	kqueue@1.2.1
	kqueue-sys@1.1.2
	lazy_static@1.5.1
	libc@0.2.189
	libmimalloc-sys@0.1.49
	libredox@0.1.25
	libtest-mimic@0.8.2
	linux-raw-sys@0.12.1
	litemap@0.8.3
	litrs@1.0.1
	lock_api@0.4.14
	log@0.4.35
	matchers@0.2.0
	memchr@2.8.3
	mimalloc@0.1.52
	mime@0.3.18
	mime_guess@2.0.5
	miniz_oxide@0.9.1
	mintex@0.1.4
	mio@1.2.4
	nix@0.31.3
	notify@8.2.2
	notify-types@2.3.0
	nu-ansi-term@0.50.3
	num-conv@0.2.2
	num-traits@0.2.19
	objc2-core-foundation@0.3.2
	objc2-core-services@0.3.2
	object@0.40.0
	once_cell@1.21.4
	once_cell_polyfill@1.70.2
	oorandom@11.1.5
	option-ext@0.2.0
	ordered-float@5.5.1
	parking_lot@0.12.5
	parking_lot_core@0.9.12
	paste@1.0.15
	percent-encoding@2.3.2
	pin-project-lite@0.2.17
	pkg-config@0.3.34
	plotters@0.3.7
	plotters-backend@0.3.7
	plotters-svg@0.3.7
	portable-atomic@1.15.0
	potential_utf@0.1.6
	powerfmt@0.2.1
	pretty_assertions@1.4.1
	prettyplease@0.2.37
	proc-macro-crate@3.5.0
	proc-macro2@1.0.107
	proptest@1.12.0
	pulldown-cmark@0.13.6
	pulldown-cmark-escape@0.11.0
	quick-error@1.2.3
	quote@1.0.47
	r-efi@6.0.0
	rand@0.10.3
	rand@0.8.8
	rand_core@0.10.1
	rand_core@0.6.4
	rand_xorshift@0.5.0
	rayon@1.12.0
	rayon-core@1.13.0
	redox_syscall@0.5.18
	redox_users@0.5.3
	ref-cast@1.0.27
	ref-cast-impl@1.0.27
	regex@1.13.1
	regex-automata@0.4.18
	regex-syntax@0.8.11
	ring@0.17.14
	rust-embed@8.14.0
	rust-embed-impl@8.14.0
	rust-embed-utils@8.14.0
	rustc-demangle@0.1.28
	rustc-hash@1.1.0
	rustix@1.1.6
	rustls@0.23.46
	rustls-pki-types@1.16.0
	rustls-webpki@0.103.17
	rustversion@1.0.23
	rusty-fork@0.3.1
	ryu@1.0.23
	same-file@1.0.6
	schemafy_core@0.6.0
	schemafy_lib@0.6.0
	schemars@1.2.3
	schemars_derive@1.2.3
	scopeguard@1.2.0
	self-replace@1.5.1
	semver@1.0.28
	serde@1.0.229
	serde-sarif@0.8.0
	serde-wasm-bindgen@0.6.5
	serde_core@1.0.229
	serde_derive@1.0.229
	serde_derive_internals@0.30.0
	serde_json@1.0.154
	serde_norway@0.9.42
	serde_spanned@1.1.3
	sha2@0.11.1
	sharded-slab@0.1.7
	shell-words@1.1.1
	shellexpand@3.1.2
	shlex@2.0.1
	simd-adler32@0.3.10
	slab@0.4.12
	smallvec@1.16.5
	stable_deref_trait@1.2.1
	statrs@0.18.0
	streaming-iterator@0.1.9
	strsim@0.11.1
	strum@0.27.2
	strum@0.28.0
	strum_macros@0.27.2
	strum_macros@0.28.0
	subtle@2.6.1
	syn@1.0.109
	syn@2.0.119
	syn@3.0.10
	synstructure@0.14.0
	tar@0.4.46
	temp-env@0.3.6
	tempfile@3.27.0
	tera@2.4.0
	termcolor@1.4.1
	terminal_size@0.4.4
	termtree@1.0.0
	thiserror@2.0.21
	thiserror-impl@2.0.21
	thousands@0.2.0
	thread_local@1.1.10
	time@0.3.55
	time-core@0.1.9
	time-macros@0.2.32
	tinystr@0.8.5
	tinytemplate@1.2.1
	toml@1.2.1+spec-1.1.0
	toml_datetime@1.1.3+spec-1.1.0
	toml_edit@0.25.19+spec-1.1.0
	toml_parser@1.1.5+spec-1.1.0
	toml_writer@1.2.0+spec-1.1.0
	tracing@0.1.44
	tracing-attributes@0.1.31
	tracing-core@0.1.36
	tracing-log@0.2.0
	tracing-subscriber@0.3.23
	tree-sitter@0.27.1
	tree-sitter-language@0.1.9
	tree-sitter-php@0.25.1
	typed-builder@0.21.2
	typed-builder-macro@0.21.2
	typed-path@0.13.0
	typenum@1.20.1
	unarray@0.1.4
	unicase@2.10.0
	unicode-ident@1.0.27
	unicode-width@0.2.3
	unit-prefix@0.5.2
	unsafe-libyaml-norway@0.2.15
	untrusted@0.9.0
	unty@0.0.4
	ureq@3.5.2
	ureq-proto@0.7.1
	uriparse@0.6.4
	url@2.5.8
	utf8-zero@0.8.1
	utf8_iter@1.1.0
	utf8parse@0.2.2
	utf_types@1.0.0
	valuable@0.1.1
	version_check@0.9.5
	virtue@0.0.18
	wait-timeout@0.2.1
	walkdir@2.5.0
	wasi@0.11.1+wasi-snapshot-preview1
	wasm-bindgen@0.2.130
	wasm-bindgen-macro@0.2.130
	wasm-bindgen-macro-support@0.2.130
	wasm-bindgen-shared@0.2.130
	web-sys@0.3.107
	web-time@1.1.0
	webpki-roots@1.0.12
	winapi-util@0.1.11
	windows-link@0.2.1
	windows-sys@0.52.0
	windows-sys@0.59.0
	windows-sys@0.61.2
	windows-targets@0.52.6
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_msvc@0.52.6
	windows_i686_gnu@0.52.6
	windows_i686_gnullvm@0.52.6
	windows_i686_msvc@0.52.6
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_msvc@0.52.6
	winnow@1.0.5
	writeable@0.6.4
	xattr@1.7.0
	xxhash-rust@0.8.19
	yansi@1.0.1
	yoke@0.8.4
	yoke-derive@0.8.4
	zerocopy@0.8.63
	zerocopy-derive@0.8.63
	zerofrom@0.1.8
	zerofrom-derive@0.1.8
	zeroize@1.9.1
	zerotrie@0.2.5
	zerovec@0.11.9
	zerovec-derive@0.11.7
	zip@9.4.0
	zlib-rs@0.6.8
	zmij@1.0.23
	zopfli@0.8.4
	zstd@0.13.5
	zstd-safe@7.4.1
	zstd-sys@2.1.3+zstd.1.5.7
"

RUST_MIN_VER="1.100.0"

inherit cargo

DESCRIPTION="Linter, formatter and static analyzer for PHP, written in Rust"
HOMEPAGE="
	https://mago.carthage.software/
	https://github.com/carthage-software/mago
"
SRC_URI="
	https://github.com/carthage-software/mago/releases/download/${PV}/source-code.tar.gz
		-> ${P}.tar.gz
	${CARGO_CRATE_URIS}
"

LICENSE="|| ( Apache-2.0 MIT )"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD BSD-2 Boost-1.0 CC0-1.0 CDLA-Permissive-2.0 ISC MIT MPL-2.0
	Unicode-3.0 ZLIB
"
SLOT="0"
KEYWORDS="~amd64 ~arm64"

RDEPEND="!dev-util/mago-bin"

PATCHES=(
	# Portage owns the binary: keep self-update from overwriting it.
	# TODO: drop when upstream adds a build switch for self-update:
	# https://github.com/carthage-software/mago/issues/2884
	"${FILESDIR}"/mago-disable-self-update.patch
)

src_compile() {
	# The upstream release profile strips symbols and sets an RPATH;
	# let Portage strip the binary, and leave the RPATH out.
	export CARGO_PROFILE_RELEASE_STRIP=false
	export CARGO_PROFILE_RELEASE_RPATH=false
	cargo_src_compile --bin mago
}

src_install() {
	dobin "$(cargo_target_dir)/mago"
	einstalldocs
}