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

EAPI=8

CRATES="
	addr2line@0.20.0
	adler2@2.0.0
	adler@1.0.2
	ahash@0.7.8
	ahash@0.8.11
	aho-corasick@1.0.3
	allocator-api2@0.2.16
	android-tzdata@0.1.1
	android_system_properties@0.1.5
	anes@0.1.6
	ansi_term@0.12.1
	anstream@0.6.15
	anstyle-parse@0.2.6
	anstyle-query@1.1.1
	anstyle-wincon@3.0.4
	anstyle@1.0.10
	anyhow@1.0.98
	arrayvec@0.5.2
	arrayvec@0.7.4
	ascii@0.9.3
	async-native-tls@0.4.0
	async-trait@0.1.88
	asynchronous-codec@0.6.2
	atoi@2.0.0
	atty@0.2.14
	autocfg@1.1.0
	backtrace@0.3.68
	base-x@0.2.11
	base36@0.0.1
	base64@0.13.1
	base64@0.21.2
	base64@0.22.1
	bigdecimal@0.3.1
	bindgen@0.59.2
	bit-vec@0.6.3
	bitflags@1.3.2
	bitflags@2.9.1
	bitvec@1.0.1
	block-buffer@0.10.4
	bon-macros@3.6.4
	bon@3.6.4
	borsh-derive-internal@0.10.3
	borsh-derive@0.10.3
	borsh-schema-derive-internal@0.10.3
	borsh@0.10.3
	bson@2.11.0
	bstr@1.11.3
	bumpalo@3.13.0
	bytecheck@0.6.11
	bytecheck_derive@0.6.11
	byteorder@1.5.0
	bytes@1.10.1
	cast@0.3.0
	cbindgen@0.29.0
	cc@1.1.30
	cexpr@0.6.0
	cfg-if@1.0.1
	cfg_aliases@0.2.1
	chrono@0.4.41
	ciborium-io@0.2.1
	ciborium-ll@0.2.1
	ciborium@0.2.1
	clang-sys@1.6.1
	clap@2.34.0
	clap@3.2.25
	clap@4.5.41
	clap_builder@4.5.41
	clap_lex@0.2.4
	clap_lex@0.7.5
	cmake@0.1.50
	codspeed-criterion-compat@1.1.0
	codspeed@1.1.0
	colorchoice@1.0.3
	colored@2.2.0
	colored@3.0.0
	combine@3.8.1
	concat-idents@1.1.5
	concurrent-queue@2.5.0
	connection-string@0.2.0
	console@0.15.7
	convert_case@0.4.0
	convert_case@0.6.0
	core-foundation-sys@0.8.4
	core-foundation@0.9.3
	cpufeatures@0.2.9
	crc32fast@1.3.2
	criterion-plot@0.5.0
	criterion@0.4.0
	crossbeam-channel@0.5.15
	crossbeam-deque@0.8.3
	crossbeam-epoch@0.9.15
	crossbeam-queue@0.3.8
	crossbeam-utils@0.8.21
	crossbeam@0.8.2
	crypto-common@0.1.6
	ctor@0.2.9
	darling@0.20.11
	darling_core@0.20.11
	darling_macro@0.20.11
	dashmap@5.5.0
	data-encoding@2.4.0
	deranged@0.3.11
	derivative@2.2.0
	derive_more@0.99.20
	diff@0.1.13
	digest@0.10.7
	displaydoc@0.2.5
	dissimilar@1.0.10
	either@1.15.0
	encode_unicode@0.3.6
	encoding_rs@0.8.32
	endian-type@0.1.2
	enum-as-inner@0.6.0
	enumflags2@0.7.12
	enumflags2_derive@0.7.12
	env_filter@0.1.3
	env_logger@0.11.6
	equivalent@1.0.1
	errno@0.3.11
	event-listener@5.3.1
	expect-test@1.5.1
	failure@0.1.8
	failure_derive@0.1.8
	fallible-iterator@0.2.0
	fallible-iterator@0.3.0
	fallible-streaming-iterator@0.1.9
	fastrand@2.3.0
	fixedbitset@0.5.7
	flate2@1.1.2
	flume@0.11.0
	fnv@1.0.7
	foldhash@0.1.4
	foldhash@0.2.0
	foreign-types-shared@0.1.1
	foreign-types@0.3.2
	form_urlencoded@1.2.1
	frunk@0.4.2
	frunk_core@0.4.2
	frunk_derives@0.4.2
	frunk_proc_macro_helpers@0.1.2
	frunk_proc_macros@0.1.2
	fuchsia-cprng@0.1.1
	funty@2.0.0
	futures-channel@0.3.28
	futures-core@0.3.28
	futures-executor@0.3.28
	futures-intrusive@0.5.0
	futures-io@0.3.28
	futures-macro@0.3.28
	futures-sink@0.3.28
	futures-task@0.3.28
	futures-timer@3.0.2
	futures-util@0.3.28
	futures@0.3.28
	generic-array@0.14.7
	getrandom@0.1.16
	getrandom@0.2.11
	getrandom@0.3.2
	gimli@0.27.3
	glob@0.3.1
	globset@0.4.13
	h2@0.3.26
	half@1.8.2
	hashbrown@0.12.3
	hashbrown@0.14.5
	hashbrown@0.15.2
	hashbrown@0.16.0
	hashlink@0.10.0
	hashlink@0.9.1
	heck@0.3.3
	heck@0.4.1
	heck@0.5.0
	hermit-abi@0.1.19
	hermit-abi@0.5.1
	hex@0.4.3
	hickory-proto@0.24.1
	hickory-resolver@0.24.1
	hmac@0.12.1
	hostname@0.3.1
	hostname@0.4.0
	html-escape@0.2.13
	http-body@0.4.5
	http@0.2.9
	http@1.1.0
	httparse@1.8.0
	httpdate@1.0.2
	humantime@2.1.0
	hyper-tls@0.5.0
	hyper@0.14.27
	iana-time-zone-haiku@0.1.2
	iana-time-zone@0.1.57
	icu_collections@1.5.0
	icu_locid@1.5.0
	icu_locid_transform@1.5.0
	icu_locid_transform_data@1.5.0
	icu_normalizer@1.5.0
	icu_normalizer_data@1.5.0
	icu_properties@1.5.1
	icu_properties_data@1.5.0
	icu_provider@1.5.0
	icu_provider_macros@1.5.0
	ident_case@1.0.1
	idna@0.4.0
	idna@1.0.3
	idna_adapter@1.2.0
	indexmap@1.9.3
	indexmap@2.10.0
	indoc@2.0.6
	insta@1.41.1
	ipconfig@0.3.2
	ipnet@2.8.0
	is_terminal_polyfill@1.70.1
	itertools@0.10.5
	itertools@0.13.0
	itoa@1.0.9
	jobserver@0.1.32
	js-sys@0.3.77
	jsonrpc-core@17.1.0
	keccak@0.1.4
	lazy_static@1.4.0
	lazycell@1.3.0
	lexical-core@0.8.5
	lexical-parse-float@0.8.5
	lexical-parse-integer@0.8.6
	lexical-util@0.8.5
	lexical-write-float@0.8.5
	lexical-write-integer@0.8.5
	lexical@6.1.1
	libc@0.2.172
	libloading@0.7.4
	libloading@0.8.1
	libsqlite3-sys@0.30.1
	libz-sys@1.1.21
	linked-hash-map@0.5.6
	linux-raw-sys@0.9.4
	litemap@0.7.5
	lock_api@0.4.10
	log@0.4.27
	lru-cache@0.1.2
	lru@0.7.8
	lru@0.8.1
	lsp-types@0.95.1
	match_cfg@0.1.0
	matchers@0.1.0
	md-5@0.10.5
	md5@0.6.1
	memchr@2.7.1
	memoffset@0.9.0
	metrics-exporter-prometheus@0.15.3
	metrics-util@0.17.0
	metrics@0.23.0
	mime@0.3.17
	minimal-lexical@0.2.1
	miniz_oxide@0.7.1
	miniz_oxide@0.8.5
	mio@0.8.11
	mio@1.0.3
	mobc@0.8.5
	mysql_common@0.29.2
	names@0.11.0
	nanoid@0.4.0
	napi-build@1.2.1
	napi-derive-backend@1.0.75
	napi-derive@2.16.13
	napi-sys@2.4.0
	napi@2.16.13
	native-tls@0.2.14
	nibble_vec@0.1.0
	nom@7.1.3
	nu-ansi-term@0.46.0
	num-bigint@0.4.3
	num-complex@0.4.3
	num-conv@0.1.0
	num-integer@0.1.45
	num-iter@0.1.43
	num-rational@0.4.1
	num-traits@0.2.16
	num@0.4.1
	num_cpus@1.17.0
	object@0.31.1
	once_cell@1.19.0
	oorandom@11.1.3
	openssl-macros@0.1.1
	openssl-probe@0.1.5
	openssl-src@300.4.2+3.4.1
	openssl-sys@0.9.106
	openssl@0.10.71
	opentls@0.2.1
	ordered-float@4.3.0
	os_str_bytes@6.5.1
	overload@0.1.1
	parking@2.2.0
	parking_lot@0.12.3
	parking_lot_core@0.9.8
	parse-hyperlinks@0.23.4
	paste@1.0.15
	pbkdf2@0.11.0
	peeking_take_while@0.1.2
	pem@1.1.1
	percent-encoding@2.3.1
	pest@2.8.1
	pest_derive@2.8.1
	pest_generator@2.8.1
	pest_meta@2.8.1
	petgraph@0.8.2
	phf@0.11.2
	phf_shared@0.11.2
	pin-project-internal@1.1.10
	pin-project-lite@0.2.12
	pin-project@1.1.10
	pin-utils@0.1.0
	pkg-config@0.3.27
	plotters-backend@0.3.5
	plotters-svg@0.3.5
	plotters@0.3.5
	portable-atomic@1.9.0
	powerfmt@0.2.0
	ppv-lite86@0.2.17
	pretty-hex@0.3.0
	pretty@0.12.4
	pretty_assertions@1.4.1
	prettyplease@0.2.32
	priority-queue@1.3.2
	proc-macro-crate@0.1.5
	proc-macro-error-attr@1.0.4
	proc-macro-error@1.0.4
	proc-macro2@1.0.95
	ptr_meta@0.1.4
	ptr_meta_derive@0.1.4
	quanta@0.12.3
	quick-error@1.2.3
	quote@1.0.40
	r-efi@5.2.0
	radium@0.7.0
	radix_trie@0.2.1
	rand@0.3.23
	rand@0.4.6
	rand@0.7.3
	rand@0.8.5
	rand@0.9.1
	rand_chacha@0.2.2
	rand_chacha@0.3.1
	rand_chacha@0.9.0
	rand_core@0.3.1
	rand_core@0.4.2
	rand_core@0.5.1
	rand_core@0.6.4
	rand_core@0.9.3
	rand_hc@0.2.0
	raw-cpuid@11.2.0
	rayon-core@1.11.0
	rayon@1.7.0
	rdrand@0.4.0
	redox_syscall@0.3.5
	redox_syscall@0.5.7
	regex-automata@0.1.10
	regex-automata@0.4.9
	regex-syntax@0.6.29
	regex-syntax@0.8.5
	regex@1.11.1
	rend@0.4.0
	reqwest@0.11.18
	resolv-conf@0.7.0
	ring@0.16.20
	ring@0.17.7
	rkyv@0.7.42
	rkyv_derive@0.7.42
	ron@0.7.1
	rusqlite@0.32.1
	rust_decimal@1.31.0
	rustc-demangle@0.1.23
	rustc-hash@1.1.0
	rustc_version@0.4.0
	rustc_version_runtime@0.3.0
	rustix@1.0.5
	rustls-pemfile@1.0.3
	rustls-webpki@0.101.7
	rustls@0.21.10
	rustversion@1.0.19
	ryu@1.0.15
	same-file@1.0.6
	saturating@0.1.0
	schannel@0.1.22
	scopeguard@1.2.0
	sct@0.7.0
	seahash@4.1.0
	security-framework-sys@2.9.1
	security-framework@2.9.2
	semver@1.0.18
	serde-wasm-bindgen@0.6.5
	serde@1.0.219
	serde_bytes@0.11.12
	serde_derive@1.0.219
	serde_derive_internals@0.29.1
	serde_json@1.0.104
	serde_repr@0.1.20
	serde_spanned@0.6.9
	serde_urlencoded@0.7.1
	serde_with@3.9.0
	serde_with_macros@3.9.0
	serial_test@2.0.0
	serial_test_derive@2.0.0
	sha-1@0.10.1
	sha1@0.10.5
	sha2@0.10.9
	sha3@0.10.8
	sharded-slab@0.1.4
	shlex@1.3.0
	signal-hook-registry@1.4.1
	simdutf8@0.1.4
	similar@2.7.0
	siphasher@0.3.10
	sketches-ddsketch@0.2.2
	slab@0.4.8
	smallvec@1.15.1
	snap@1.1.1
	socket2@0.4.9
	socket2@0.5.7
	spin@0.5.2
	spin@0.9.8
	sqlformat@0.2.6
	sqlparser@0.32.0
	sqlx-core@0.8.3
	sqlx-sqlite@0.8.3
	stable_deref_trait@1.2.0
	static_assertions@1.1.0
	stringprep@0.1.3
	strip-ansi-escapes@0.1.1
	strsim@0.11.1
	strsim@0.8.0
	structopt-derive@0.4.18
	structopt@0.3.26
	subprocess@0.2.9
	subtle@2.5.0
	syn@1.0.109
	syn@2.0.104
	synstructure@0.12.6
	synstructure@0.13.1
	take_mut@0.2.2
	tap@1.0.1
	tempfile@3.20.0
	termcolor@1.4.0
	textwrap@0.11.0
	textwrap@0.16.0
	thiserror-impl@1.0.69
	thiserror-impl@2.0.12
	thiserror@1.0.69
	thiserror@2.0.12
	thread_local@1.1.7
	time-core@0.1.2
	time-macros@0.2.18
	time@0.3.36
	tinystr@0.7.6
	tinytemplate@1.2.1
	tinyvec@1.6.0
	tinyvec_macros@0.1.1
	tokio-macros@2.5.0
	tokio-native-tls@0.3.1
	tokio-rustls@0.24.1
	tokio-tungstenite@0.26.1
	tokio-util@0.7.15
	tokio@1.45.1
	toml@0.5.11
	toml@0.8.19
	toml_datetime@0.6.11
	toml_edit@0.22.20
	tower-service@0.3.2
	tracing-attributes@0.1.28
	tracing-core@0.1.34
	tracing-error@0.2.0
	tracing-futures@0.2.5
	tracing-log@0.2.0
	tracing-serde@0.1.3
	tracing-subscriber@0.3.18
	tracing-test-macro@0.2.5
	tracing-test@0.2.5
	tracing@0.1.41
	try-lock@0.2.4
	tsify-macros@0.5.5
	tsify@0.5.5
	tungstenite@0.26.1
	twox-hash@1.6.3
	typed-arena@2.0.2
	typed-builder@0.10.0
	typenum@1.16.0
	ucd-trie@0.1.6
	ulid@1.1.3
	unicode-bidi@0.3.13
	unicode-ident@1.0.11
	unicode-normalization@0.1.22
	unicode-segmentation@1.10.1
	unicode-width@0.1.10
	unicode-xid@0.2.4
	unicode_categories@0.1.1
	unreachable@1.0.0
	untrusted@0.7.1
	untrusted@0.9.0
	url@2.5.4
	utf-8@0.7.6
	utf16_iter@1.0.5
	utf8-width@0.1.6
	utf8_iter@1.0.4
	utf8parse@0.2.1
	uuid@1.10.0
	valuable@0.1.0
	vcpkg@0.2.15
	vec_map@0.8.2
	version_check@0.9.4
	versions@6.3.2
	void@1.0.2
	vte@0.10.1
	vte_generate_state_changes@0.1.1
	walkdir@2.3.3
	want@0.3.1
	wasi@0.11.0+wasi-snapshot-preview1
	wasi@0.14.2+wasi-0.2.4
	wasi@0.9.0+wasi-snapshot-preview1
	wasite@0.1.0
	wasm-bindgen-backend@0.2.100
	wasm-bindgen-futures@0.4.45
	wasm-bindgen-macro-support@0.2.100
	wasm-bindgen-macro@0.2.100
	wasm-bindgen-shared@0.2.100
	wasm-bindgen@0.2.100
	wasm-logger@0.2.0
	wasm-rs-dbg@0.1.2
	web-sys@0.3.65
	web-time@1.1.0
	webpki-roots@0.25.3
	whoami@1.5.2
	widestring@1.0.2
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.5
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	winauth@0.0.4
	windows-core@0.52.0
	windows-link@0.1.0
	windows-sys@0.45.0
	windows-sys@0.48.0
	windows-sys@0.52.0
	windows-targets@0.42.2
	windows-targets@0.48.1
	windows-targets@0.52.0
	windows@0.48.0
	windows@0.52.0
	windows_aarch64_gnullvm@0.42.2
	windows_aarch64_gnullvm@0.48.0
	windows_aarch64_gnullvm@0.52.0
	windows_aarch64_msvc@0.42.2
	windows_aarch64_msvc@0.48.0
	windows_aarch64_msvc@0.52.0
	windows_i686_gnu@0.42.2
	windows_i686_gnu@0.48.0
	windows_i686_gnu@0.52.0
	windows_i686_msvc@0.42.2
	windows_i686_msvc@0.48.0
	windows_i686_msvc@0.52.0
	windows_x86_64_gnu@0.42.2
	windows_x86_64_gnu@0.48.0
	windows_x86_64_gnu@0.52.0
	windows_x86_64_gnullvm@0.42.2
	windows_x86_64_gnullvm@0.48.0
	windows_x86_64_gnullvm@0.52.0
	windows_x86_64_msvc@0.42.2
	windows_x86_64_msvc@0.48.0
	windows_x86_64_msvc@0.52.0
	winnow@0.6.26
	winreg@0.10.1
	winreg@0.50.0
	wit-bindgen-rt@0.39.0
	write16@1.0.0
	writeable@0.5.5
	wyz@0.5.1
	yansi@1.0.1
	yoke-derive@0.7.5
	yoke@0.7.5
	zerocopy-derive@0.7.32
	zerocopy@0.7.32
	zerofrom-derive@0.1.6
	zerofrom@0.1.6
	zerovec-derive@0.10.3
	zerovec@0.10.4
	zstd-safe@5.0.2+zstd.1.5.2
	zstd-sys@2.0.13+zstd.1.5.6
	zstd@0.11.2+zstd.1.5.2
"

declare -A GIT_CRATES=(
	[barrel]='https://github.com/prisma/barrel;4e84cf3d5013b4c92eb81d7ba90cd1c1c01c6805;barrel-%commit%'
	[cuid-util]='https://github.com/prisma/cuid-rust;dc68c4f47a3dbcd511f605135ac7c948775a3ab9;cuid-rust-%commit%/crates/cuid-util'
	[cuid1]='https://github.com/prisma/cuid-rust;dc68c4f47a3dbcd511f605135ac7c948775a3ab9;cuid-rust-%commit%/crates/cuid1'
	[cuid2]='https://github.com/prisma/cuid-rust;dc68c4f47a3dbcd511f605135ac7c948775a3ab9;cuid-rust-%commit%/crates/cuid2'
	[cuid]='https://github.com/prisma/cuid-rust;dc68c4f47a3dbcd511f605135ac7c948775a3ab9;cuid-rust-%commit%/crates/cuid'
	[graphql-parser]='https://github.com/prisma/graphql-parser;6a3f58bd879065588e710cb02b5bd30c1ce182c3;graphql-parser-%commit%'
	[mongodb-internal-macros]='https://github.com/prisma/mongo-rust-driver;31e0356391a7871bec000ae35fe0edc35582449e;mongo-rust-driver-%commit%/macros'
	[mongodb]='https://github.com/prisma/mongo-rust-driver;31e0356391a7871bec000ae35fe0edc35582449e;mongo-rust-driver-%commit%'
	[mysql_async]='https://github.com/prisma/mysql_async;c4c841c9d03e361df7377264a075335a823534ee;mysql_async-%commit%'
	[postgres-native-tls]='https://github.com/prisma/rust-postgres;278641fa1a08b7e7d35841342ab4426c5b063d9a;rust-postgres-%commit%/postgres-native-tls'
	[postgres-protocol]='https://github.com/prisma/rust-postgres;278641fa1a08b7e7d35841342ab4426c5b063d9a;rust-postgres-%commit%/postgres-protocol'
	[postgres-types]='https://github.com/prisma/rust-postgres;278641fa1a08b7e7d35841342ab4426c5b063d9a;rust-postgres-%commit%/postgres-types'
	[tiberius]='https://github.com/prisma/tiberius;59db57960a14b422fb3a1309aa4aa47880896ff8;tiberius-%commit%'
	[tokio-postgres]='https://github.com/prisma/rust-postgres;278641fa1a08b7e7d35841342ab4426c5b063d9a;rust-postgres-%commit%/tokio-postgres'
)
RUST_MIN_VER="1.85.0"

inherit cargo

DESCRIPTION="Prisma's database engines."
HOMEPAGE="https://github.com/prisma/prisma-engines"
SRC_URI="https://github.com/prisma/prisma-engines/archive/${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}"

LICENSE="Apache-2.0 BSD ISC MIT MPL-2.0 Unicode-3.0 Unicode-DFS-2016 ZLIB"
SLOT="0"
KEYWORDS="~amd64"

DEPEND="dev-libs/openssl:="
RDEPEND="${DEPEND}"
BDEPEND="virtual/pkgconfig"

PATCHES=(
	"${FILESDIR}/${PN}-getrandom.patch"
)

QA_FLAGS_IGNORED="usr/bin/.*"

src_prepare() {
	default
	export GIT_HASH="${PV}"
	find . -name build.rs -exec sed -re '/.*build_utils::store_git.*;$/d' -i {} ';'
}

src_install() {
	dobin target/release/{prisma-fmt,query-compiler-playground,query-engine,schema-engine}
	mkdir -p "${D}/usr/$(get_libdir)/${PN}" || die
	cp target/release/*.so "${D}/usr/$(get_libdir)/${PN}/" || die
}