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

EAPI=8

RUST_MIN_VER=1.85.0
CRATES="
	Inflector@0.11.4
	addr2line@0.24.2
	adler2@2.0.0
	aes@0.8.4
	ahash@0.7.8
	ahash@0.8.11
	aho-corasick@1.1.3
	allocator-api2@0.2.21
	android-tzdata@0.1.1
	android_system_properties@0.1.5
	any_ascii@0.1.7
	anyhow@1.0.97
	arbitrary@1.4.1
	arrayref@0.3.9
	arrayvec@0.7.6
	ascii@1.1.0
	ast_node@3.0.0
	async-trait@0.1.88
	atomic-polyfill@1.0.3
	atty@0.2.14
	auto_impl@1.2.1
	autocfg@1.4.0
	backtrace@0.3.74
	base64-simd@0.7.0
	base64@0.22.1
	better_scoped_tls@1.0.0
	bincode@1.3.3
	bindgen@0.70.1
	binding_macros@21.0.0
	bitflags@1.3.2
	bitflags@2.9.0
	bitvec@1.0.1
	blake3@1.7.0
	block-buffer@0.10.4
	browserslist-rs@0.18.1
	bstr@1.11.3
	bumpalo@3.17.0
	bytecheck@0.6.12
	bytecheck@0.8.1
	bytecheck_derive@0.6.12
	bytecheck_derive@0.8.1
	byteorder@1.5.0
	bytes@1.10.1
	bytesize@1.3.2
	bzip2-sys@0.1.13+1.0.8
	bzip2@0.5.2
	camino@1.1.9
	cargo-platform@0.1.9
	cargo_metadata@0.19.2
	castaway@0.2.3
	cc@1.2.16
	cexpr@0.6.0
	cfg-if@1.0.0
	chili@0.2.1
	chrono@0.4.40
	ciborium-io@0.2.2
	ciborium-ll@0.2.2
	ciborium@0.2.2
	cipher@0.4.4
	clang-sys@1.8.1
	clap@3.2.25
	clap_derive@3.2.25
	clap_lex@0.2.4
	cmake@0.1.54
	compact_str@0.7.1
	console@0.15.11
	console_error_panic_hook@0.1.7
	const-str-proc-macro@0.3.2
	const-str@0.3.2
	constant_time_eq@0.3.1
	convert_case@0.6.0
	cooked-waker@5.0.0
	core-foundation-sys@0.8.7
	corosensei@0.2.1
	cpufeatures@0.2.17
	cranelift-bforest@0.110.2
	cranelift-bitset@0.110.3
	cranelift-codegen-meta@0.110.3
	cranelift-codegen-shared@0.110.3
	cranelift-codegen@0.110.2
	cranelift-control@0.110.3
	cranelift-entity@0.110.2
	cranelift-frontend@0.110.2
	cranelift-isle@0.110.2
	crc-catalog@1.1.1
	crc-catalog@2.4.0
	crc32fast@1.4.2
	crc@2.1.0
	crc@3.2.1
	critical-section@1.2.0
	crossbeam-channel@0.5.14
	crossbeam-deque@0.8.6
	crossbeam-epoch@0.9.18
	crossbeam-queue@0.3.12
	crossbeam-utils@0.8.21
	crunchy@0.2.3
	crypto-common@0.1.6
	cssparser-color@0.1.0
	cssparser-macros@0.6.1
	cssparser@0.33.0
	ctor@0.2.9
	darling@0.14.4
	darling@0.20.10
	darling_core@0.14.4
	darling_core@0.20.10
	darling_macro@0.14.4
	darling_macro@0.20.10
	dashmap@5.5.3
	dashmap@6.1.0
	data-encoding@2.8.0
	data-url@0.1.1
	debugid@0.8.0
	deflate64@0.1.9
	deranged@0.4.0
	derivative@2.2.0
	derive_arbitrary@1.4.1
	derive_builder@0.12.0
	derive_builder@0.20.2
	derive_builder_core@0.12.0
	derive_builder_core@0.20.2
	derive_builder_macro@0.12.0
	derive_builder_macro@0.20.2
	derive_more-impl@1.0.0
	derive_more@0.99.19
	derive_more@1.0.0
	digest@0.10.7
	displaydoc@0.2.5
	document-features@0.2.11
	dtoa-short@0.3.5
	dtoa@1.0.10
	dunce@1.0.5
	dyn-clone@1.0.19
	either@1.15.0
	encode_unicode@1.0.0
	enum-iterator-derive@0.7.0
	enum-iterator@0.7.0
	enumset@1.1.5
	enumset_derive@0.10.0
	equivalent@1.0.2
	errno@0.3.10
	fallible-iterator@0.3.0
	fastrand@2.3.0
	filetime@0.2.25
	fixedbitset@0.4.2
	fixedbitset@0.5.7
	flate2@1.1.0
	fnv@1.0.7
	form_urlencoded@1.2.1
	from_variant@2.0.0
	fs_extra@1.3.0
	funty@2.0.0
	futures-channel@0.3.31
	futures-core@0.3.31
	futures-executor@0.3.31
	futures-io@0.3.31
	futures-macro@0.3.31
	futures-sink@0.3.31
	futures-task@0.3.31
	futures-util@0.3.31
	futures@0.3.31
	generic-array@0.14.7
	getrandom@0.2.15
	getrandom@0.3.2
	gimli@0.28.1
	gimli@0.31.1
	glob@0.3.2
	globset@0.4.16
	half@2.5.0
	hash32@0.2.1
	hashbrown@0.12.3
	hashbrown@0.13.2
	hashbrown@0.14.5
	hashbrown@0.15.2
	heapless@0.7.17
	heck@0.3.3
	heck@0.4.1
	heck@0.5.0
	hermit-abi@0.1.19
	hermit-abi@0.3.9
	hex@0.4.3
	hmac@0.12.1
	hstr@1.0.0
	http@1.3.1
	iana-time-zone-haiku@0.1.2
	iana-time-zone@0.1.61
	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
	id-arena@2.2.1
	ident_case@1.0.1
	idna@1.0.3
	idna_adapter@1.2.0
	if_chain@1.0.2
	ignore@0.4.23
	indexmap@1.9.3
	indexmap@2.8.0
	inout@0.1.4
	insta@1.42.2
	io-lifetimes@1.0.11
	ipnet@2.11.0
	iprange@0.6.7
	is-macro@0.3.7
	itertools@0.10.5
	itertools@0.12.1
	itertools@0.13.0
	itoa@1.0.15
	jobserver@0.1.32
	js-sys@0.3.77
	json@0.12.4
	jsonc-parser@0.26.2
	lazy_static@1.5.0
	leb128@0.2.5
	leb128fmt@0.1.0
	lexical-core@0.8.5
	lexical-parse-float@0.8.5
	lexical-parse-integer@0.8.6
	lexical-sort@0.3.1
	lexical-util@0.8.5
	lexical-write-float@0.8.5
	lexical-write-integer@0.8.5
	lexical@6.1.1
	libc@0.2.171
	libloading@0.8.6
	libmimalloc-sys@0.1.40
	libredox@0.1.3
	libyml@0.0.5
	lightningcss-derive@1.0.0-alpha.43
	lightningcss@1.0.0-alpha.65
	linked-hash-map@0.5.6
	linked_hash_set@0.1.5
	linux-raw-sys@0.3.8
	linux-raw-sys@0.4.15
	linux-raw-sys@0.9.3
	litemap@0.7.5
	litrs@0.4.1
	lock_api@0.4.12
	lockfree-object-pool@0.1.6
	log@0.4.26
	lru@0.10.1
	lz4_flex@0.11.3
	lzma-rs@0.3.0
	lzma-sys@0.1.20
	mach2@0.4.2
	managed@0.8.0
	matchers@0.1.0
	matches@0.1.10
	memchr@2.7.4
	memmap2@0.6.2
	memoffset@0.9.1
	miette-derive@7.5.0
	miette@7.5.0
	mimalloc@0.1.44
	minimal-lexical@0.2.1
	miniz_oxide@0.8.5
	mio@1.0.3
	more-asserts@0.2.2
	munge@0.4.3
	munge_macro@0.4.3
	napi-build@2.1.5
	napi-derive-backend@1.0.75
	napi-derive@2.16.13
	napi-sys@2.4.0
	napi@2.16.16
	new_debug_unreachable@1.0.6
	nom@7.1.3
	normpath@0.2.0
	nu-ansi-term@0.46.0
	num-bigint@0.4.6
	num-conv@0.1.0
	num-integer@0.1.46
	num-traits@0.2.19
	num_cpus@1.16.0
	num_enum@0.5.11
	num_enum_derive@0.5.11
	num_threads@0.1.7
	object@0.32.2
	object@0.36.7
	once_cell@1.21.1
	os_str_bytes@6.6.1
	outref@0.1.0
	overload@0.1.1
	owo-colors@4.2.0
	par-core@1.0.3
	par-iter@1.0.2
	parcel_selectors@0.28.1
	parcel_sourcemap@2.1.1
	parking_lot@0.12.3
	parking_lot_core@0.9.10
	paste@1.0.15
	path-absolutize@3.1.1
	path-clean@0.1.0
	path-clean@1.0.1
	path-dedot@3.1.1
	pathdiff@0.2.3
	pbkdf2@0.12.2
	percent-encoding@2.3.1
	petgraph@0.6.5
	petgraph@0.7.1
	phf@0.11.3
	phf_codegen@0.11.3
	phf_generator@0.11.3
	phf_macros@0.11.3
	phf_shared@0.11.3
	pin-project-internal@1.1.10
	pin-project-lite@0.2.16
	pin-project@1.1.10
	pin-utils@0.1.0
	pkg-config@0.3.32
	powerfmt@0.2.0
	ppv-lite86@0.2.21
	precomputed-hash@0.1.1
	preset_env_base@3.0.1
	prettyplease@0.2.31
	proc-macro-crate@1.3.1
	proc-macro-error-attr2@2.0.0
	proc-macro-error-attr@1.0.4
	proc-macro-error2@2.0.1
	proc-macro-error@1.0.4
	proc-macro2@1.0.94
	psm@0.1.25
	ptr_meta@0.1.4
	ptr_meta@0.3.0
	ptr_meta_derive@0.1.4
	ptr_meta_derive@0.3.0
	pulldown-cmark@0.8.0
	quote@1.0.40
	r-efi@5.2.0
	radium@0.7.0
	radix_fmt@1.0.0
	rancor@0.1.0
	rand@0.8.5
	rand_chacha@0.3.1
	rand_core@0.6.4
	rayon-core@1.12.1
	rayon@1.10.0
	redox_syscall@0.5.10
	regalloc2@0.9.3
	regex-automata@0.1.10
	regex-automata@0.4.9
	regex-syntax@0.6.29
	regex-syntax@0.8.5
	regex@1.11.1
	region@3.0.2
	relative-path@1.9.3
	rend@0.4.2
	rend@0.5.2
	replace_with@0.1.7
	ring@0.17.14
	rkyv@0.7.45
	rkyv@0.8.10
	rkyv_derive@0.7.45
	rkyv_derive@0.8.10
	rustc-demangle@0.1.24
	rustc-hash@1.1.0
	rustc-hash@2.1.1
	rustc_version@0.2.3
	rustc_version@0.4.1
	rustix@0.37.28
	rustix@0.38.44
	rustix@1.0.3
	rustls-pki-types@1.11.0
	rustls-webpki@0.103.0
	rustls@0.23.25
	rustversion@1.0.20
	rusty_pool@0.7.0
	ruzstd@0.5.0
	ryu-js@1.0.2
	ryu@1.0.20
	same-file@1.0.6
	schemars@0.8.22
	schemars_derive@0.8.22
	scoped-tls@1.0.1
	scopeguard@1.2.0
	seahash@4.1.0
	self_cell@1.1.0
	semver-parser@0.7.0
	semver@0.9.0
	semver@1.0.26
	serde-wasm-bindgen@0.4.5
	serde-wasm-bindgen@0.6.5
	serde@1.0.219
	serde_derive@1.0.219
	serde_derive_internals@0.29.1
	serde_json@1.0.140
	serde_spanned@0.6.8
	serde_yml@0.0.12
	sha1@0.10.6
	sha2@0.10.8
	sharded-slab@0.1.7
	shared-buffer@0.1.4
	shlex@1.3.0
	simd-abstraction@0.7.1
	simd-adler32@0.3.7
	simdutf8@0.1.5
	similar@2.7.0
	siphasher@0.3.11
	siphasher@1.0.1
	slab@0.4.9
	slice-group-by@0.3.1
	smallvec@1.14.0
	smartstring@1.0.1
	smoltcp@0.8.2
	socket2@0.5.8
	sourcemap@8.0.1
	sourcemap@9.1.2
	spin@0.9.8
	st-map@0.2.4
	stable_deref_trait@1.2.0
	stacker@0.1.20
	static-map-macro@0.3.4
	static_assertions@1.1.0
	string_enum@1.0.0
	strsim@0.10.0
	strsim@0.11.1
	subtle@2.6.1
	swc@21.0.0
	swc_allocator@4.0.0
	swc_atoms@5.0.0
	swc_bundler@15.0.0
	swc_cached@2.0.0
	swc_cli_impl@22.0.0
	swc_common@8.1.1
	swc_compiler_base@18.0.0
	swc_config@2.0.0
	swc_config_macro@1.0.0
	swc_core@22.5.4
	swc_css_ast@8.0.0
	swc_css_codegen@8.0.0
	swc_css_codegen_macros@1.0.0
	swc_css_minifier@8.0.0
	swc_css_parser@8.0.0
	swc_css_utils@8.0.0
	swc_css_visit@8.0.0
	swc_ecma_ast@8.1.2
	swc_ecma_codegen@10.0.1
	swc_ecma_codegen_macros@2.0.0
	swc_ecma_compat_bugfixes@12.0.0
	swc_ecma_compat_common@12.0.0
	swc_ecma_compat_es2015@12.0.1
	swc_ecma_compat_es2016@12.0.1
	swc_ecma_compat_es2017@12.2.2
	swc_ecma_compat_es2018@12.0.1
	swc_ecma_compat_es2019@12.0.0
	swc_ecma_compat_es2020@13.0.1
	swc_ecma_compat_es2021@12.0.0
	swc_ecma_compat_es2022@13.0.0
	swc_ecma_compat_es3@12.0.0
	swc_ecma_ext_transforms@12.0.0
	swc_ecma_lexer@11.1.3
	swc_ecma_lints@12.1.0
	swc_ecma_loader@8.0.0
	swc_ecma_minifier@16.1.1
	swc_ecma_parser@11.1.4
	swc_ecma_preset_env@16.0.0
	swc_ecma_transforms@15.0.0
	swc_ecma_transforms_base@12.2.0
	swc_ecma_transforms_classes@12.0.0
	swc_ecma_transforms_compat@13.0.0
	swc_ecma_transforms_macros@1.0.0
	swc_ecma_transforms_module@13.0.0
	swc_ecma_transforms_optimization@12.0.1
	swc_ecma_transforms_proposal@12.0.3
	swc_ecma_transforms_react@13.0.1
	swc_ecma_transforms_typescript@13.0.0
	swc_ecma_usage_analyzer@13.1.1
	swc_ecma_utils@12.0.1
	swc_ecma_visit@8.0.0
	swc_eq_ignore_macros@1.0.0
	swc_error_reporters@10.0.0
	swc_fast_ts_strip@15.0.0
	swc_graph_analyzer@9.0.0
	swc_html@16.0.0
	swc_html_ast@8.0.0
	swc_html_codegen@8.0.0
	swc_html_codegen_macros@1.0.0
	swc_html_minifier@16.0.0
	swc_html_parser@8.0.0
	swc_html_utils@8.0.0
	swc_html_visit@8.0.0
	swc_macros_common@1.0.0
	swc_malloc@1.2.2
	swc_node_bundler@22.0.0
	swc_node_comments@8.0.0
	swc_nodejs_common@1.0.0
	swc_plugin_proxy@8.0.0
	swc_plugin_runner@10.0.0
	swc_timer@1.0.0
	swc_trace_macro@2.0.1
	swc_transform_common@2.0.0
	swc_typescript@11.0.1
	swc_visit@2.0.0
	syn@1.0.109
	syn@2.0.100
	synstructure@0.13.1
	tap@1.0.1
	tar@0.4.44
	target-lexicon@0.12.16
	tempfile@3.19.1
	termcolor@1.4.1
	terminal_size@0.2.6
	terminal_size@0.3.0
	terminal_size@0.4.2
	termios@0.3.3
	textwrap@0.16.2
	thiserror-impl@1.0.69
	thiserror-impl@2.0.12
	thiserror@1.0.69
	thiserror@2.0.12
	thread_local@1.1.8
	tikv-jemalloc-sys@0.5.4+5.3.0-patched
	tikv-jemallocator@0.5.4
	time-core@0.1.4
	time-macros@0.2.21
	time@0.3.40
	tinystr@0.7.6
	tinyvec@1.9.0
	tinyvec_macros@0.1.1
	tokio-macros@2.5.0
	tokio-stream@0.1.17
	tokio-util@0.7.14
	tokio@1.44.1
	toml@0.8.20
	toml_datetime@0.6.8
	toml_edit@0.19.15
	toml_edit@0.22.24
	tracing-attributes@0.1.28
	tracing-chrome@0.5.0
	tracing-chrome@0.7.2
	tracing-core@0.1.33
	tracing-futures@0.2.5
	tracing-log@0.2.0
	tracing-subscriber@0.3.19
	tracing@0.1.41
	triomphe@0.1.14
	twox-hash@1.6.3
	typed-arena@2.0.2
	typenum@1.18.0
	unicase@2.8.1
	unicode-id-start@1.3.1
	unicode-id@0.3.5
	unicode-ident@1.0.18
	unicode-linebreak@0.1.5
	unicode-normalization@0.1.24
	unicode-segmentation@1.12.0
	unicode-width@0.1.14
	unicode-width@0.2.0
	unicode-xid@0.2.6
	untrusted@0.9.0
	ureq@2.12.1
	url@2.5.4
	urlencoding@2.1.3
	utf16_iter@1.0.5
	utf8_iter@1.0.4
	uuid@1.16.0
	valuable@0.1.1
	vergen-lib@0.1.6
	vergen@9.0.4
	version_check@0.9.5
	virtual-fs@0.19.0
	virtual-fs@0.21.0
	virtual-mio@0.7.0
	virtual-net@0.14.0
	vlq@0.5.1
	wai-bindgen-gen-core@0.2.3
	wai-bindgen-gen-rust-wasm@0.2.3
	wai-bindgen-gen-rust@0.2.3
	wai-bindgen-rust-impl@0.2.3
	wai-bindgen-rust@0.2.3
	wai-parser@0.2.3
	waker-fn@1.2.0
	walkdir@2.5.0
	wasi@0.11.0+wasi-snapshot-preview1
	wasi@0.14.2+wasi-0.2.4
	wasm-bindgen-backend@0.2.100
	wasm-bindgen-futures@0.4.50
	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-encoder@0.227.1
	wasmer-cache@5.0.5-rc1
	wasmer-compiler-cranelift@5.0.5-rc1
	wasmer-compiler@5.0.5-rc1
	wasmer-config@0.10.0
	wasmer-config@0.12.0
	wasmer-derive@5.0.5-rc1
	wasmer-journal@0.18.0
	wasmer-package@0.2.0
	wasmer-package@0.4.0
	wasmer-types@5.0.5-rc1
	wasmer-vm@5.0.5-rc1
	wasmer-wasix-types@0.35.0
	wasmer-wasix@0.35.0
	wasmer@5.0.5-rc1
	wasmparser@0.216.1
	wasmparser@0.227.1
	wast@227.0.1
	wat@1.227.1
	web-sys@0.3.77
	webc@7.1.0
	webpki-roots@0.26.8
	weezl@0.1.8
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.9
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-core@0.52.0
	windows-link@0.1.1
	windows-sys@0.48.0
	windows-sys@0.52.0
	windows-sys@0.59.0
	windows-targets@0.48.5
	windows-targets@0.52.6
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_msvc@0.48.5
	windows_aarch64_msvc@0.52.6
	windows_i686_gnu@0.48.5
	windows_i686_gnu@0.52.6
	windows_i686_gnullvm@0.52.6
	windows_i686_msvc@0.48.5
	windows_i686_msvc@0.52.6
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_msvc@0.48.5
	windows_x86_64_msvc@0.52.6
	winnow@0.5.40
	winnow@0.7.4
	wit-bindgen-rt@0.39.0
	write16@1.0.0
	writeable@0.5.5
	wyz@0.5.1
	xattr@1.5.0
	xxhash-rust@0.8.15
	xz2@0.1.7
	xz@0.1.0
	yoke-derive@0.7.5
	yoke@0.7.5
	zerocopy-derive@0.7.35
	zerocopy-derive@0.8.23
	zerocopy@0.7.35
	zerocopy@0.8.23
	zerofrom-derive@0.1.6
	zerofrom@0.1.6
	zeroize@1.8.1
	zeroize_derive@1.4.2
	zerovec-derive@0.10.3
	zerovec@0.10.4
	zip@2.4.2
	zopfli@0.8.1
	zstd-safe@7.2.4
	zstd-sys@2.0.15+zstd.1.5.7
	zstd@0.13.3
"

inherit cargo

DESCRIPTION="Native Node.js binding of the SWC JavaScript and TypeScript compiler"
HOMEPAGE="https://swc.rs/"
SRC_URI="
	https://github.com/swc-project/swc/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}
"
S="${WORKDIR}/swc-${PV}/bindings"

LICENSE="Apache-2.0"
# Dependent crate licenses
LICENSE+="
	0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD BSD-2 Boost-1.0
	CC0-1.0 ISC MIT MPL-2.0 Unicode-3.0
"
SLOT="${PV}"
KEYWORDS="~amd64 ~arm64"

src_prepare() {
	default
	# Upstream builds with nightly; -Zshare-generics is nightly only
	sed -i "s/, *\"-Zshare-generics=y\"//; s/\"-Zshare-generics=y\", *//; s/\[\"-Zshare-generics=y\"\]/[]/" \
		../.cargo/config.toml || die
}

src_configure() {
	cargo_src_configure --frozen
}

src_compile() {
	# The wasm plugin host (wasmer) calls __rust_probestack, which current
	# Rust no longer provides, so the addon would not load
	cargo_src_compile -p binding_core_node --no-default-features --features swc_v1
}

src_test() {
	:
}

src_install() {
	insinto /usr/$(get_libdir)/${P}
	newins "$(cargo_target_dir)/libbinding_core_node.so" swc.node
	fperms 0755 /usr/$(get_libdir)/${P}/swc.node
}