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

# Autogenerated by pycargoebuild 0.13.4

EAPI=8

CRATES="
	ab_glyph_rasterizer@0.1.8
	adler2@2.0.0
	adler@1.0.2
	ansi_term@0.12.1
	anstream@0.6.15
	anstyle-parse@0.2.5
	anstyle-query@1.1.1
	anstyle-wincon@3.0.4
	anstyle@1.0.8
	anyhow@1.0.89
	approx@0.5.1
	atty@0.2.14
	autocfg@1.3.0
	base64@0.22.1
	bincode@1.3.3
	bitflags@1.3.2
	bitflags@2.6.0
	block@0.1.6
	bytemuck@1.18.0
	byteorder@1.5.0
	cc@1.1.21
	cfg-if@1.0.0
	clap@2.34.0
	clipboard-win@2.2.0
	clipboard-win@5.4.0
	clipboard@0.5.0
	cocoa-foundation@0.1.2
	cocoa@0.24.1
	color_quant@1.1.0
	colorchoice@1.0.2
	conv@0.3.3
	core-foundation-sys@0.8.7
	core-foundation@0.9.4
	core-graphics-types@0.1.3
	core-graphics@0.22.3
	core-text@19.2.0
	crc32fast@1.4.2
	crossbeam-deque@0.8.5
	crossbeam-epoch@0.9.18
	crossbeam-utils@0.8.20
	cstr@0.2.12
	custom_derive@0.1.7
	deranged@0.3.11
	dirs-next@2.0.0
	dirs-sys-next@0.1.2
	dirs-sys@0.4.1
	dirs@5.0.1
	dlib@0.5.2
	dwrote@0.11.1
	either@1.13.0
	env_filter@0.1.2
	env_logger@0.11.5
	equivalent@1.0.1
	errno@0.3.9
	error-code@3.3.1
	fastrand@2.1.1
	fdeflate@0.3.5
	flate2@1.0.33
	float-ord@0.3.2
	fnv@1.0.7
	font-kit@0.12.0
	foreign-types-shared@0.1.1
	foreign-types@0.3.2
	freetype-sys@0.20.1
	freetype@0.7.2
	getrandom@0.1.16
	getrandom@0.2.15
	harfbuzz-sys@0.5.0
	hashbrown@0.14.5
	heck@0.3.3
	hermit-abi@0.1.19
	humantime@2.1.0
	image@0.24.9
	imageproc@0.23.0
	indexmap@2.5.0
	is_terminal_polyfill@1.70.1
	itertools@0.10.5
	itoa@1.0.11
	jpeg-decoder@0.3.1
	lazy_static@1.5.0
	libc@0.2.159
	libloading@0.8.5
	libredox@0.1.3
	linked-hash-map@0.5.6
	linux-raw-sys@0.4.14
	log@0.4.22
	malloc_buf@0.0.6
	matrixmultiply@0.3.9
	memchr@2.7.4
	miniz_oxide@0.7.4
	miniz_oxide@0.8.0
	nalgebra@0.30.1
	num-bigint@0.4.6
	num-complex@0.4.6
	num-conv@0.1.0
	num-integer@0.1.46
	num-iter@0.1.45
	num-rational@0.4.2
	num-traits@0.2.19
	num@0.4.3
	objc-foundation@0.1.1
	objc@0.2.7
	objc_id@0.1.1
	once_cell@1.19.0
	onig@6.4.0
	onig_sys@69.8.1
	option-ext@0.2.0
	os_info@3.8.2
	owned_ttf_parser@0.15.2
	paste@1.0.15
	pasteboard@0.1.3
	pathfinder_geometry@0.5.1
	pathfinder_simd@0.5.4
	pkg-config@0.3.31
	plist@1.7.0
	png@0.17.13
	powerfmt@0.2.0
	ppv-lite86@0.2.20
	proc-macro-error-attr@1.0.4
	proc-macro-error@1.0.4
	proc-macro2@1.0.86
	quick-xml@0.32.0
	quote@1.0.37
	rand@0.7.3
	rand_chacha@0.2.2
	rand_core@0.5.1
	rand_distr@0.2.2
	rand_hc@0.2.0
	rawpointer@0.2.1
	rayon-core@1.12.1
	rayon@1.10.0
	redox_users@0.4.6
	regex-syntax@0.8.4
	rustc_version@0.4.1
	rustix@0.38.37
	rusttype@0.9.3
	ryu@1.0.18
	safe_arch@0.7.2
	same-file@1.0.6
	semver@1.0.23
	serde@1.0.210
	serde_derive@1.0.210
	serde_json@1.0.128
	shell-words@1.1.0
	shlex@1.3.0
	simba@0.7.3
	simd-adler32@0.3.7
	strsim@0.8.0
	structopt-derive@0.4.18
	structopt@0.3.26
	syn@1.0.109
	syn@2.0.77
	syntect@5.2.0
	tempfile@3.12.0
	term_size@0.3.2
	textwrap@0.11.0
	thiserror-impl@1.0.64
	thiserror@1.0.64
	time-core@0.1.2
	time-macros@0.2.18
	time@0.3.36
	ttf-parser@0.15.2
	typenum@1.17.0
	unicode-ident@1.0.13
	unicode-segmentation@1.12.0
	unicode-width@0.1.14
	utf8parse@0.2.2
	vec_map@0.8.2
	version_check@0.9.5
	walkdir@2.5.0
	wasi@0.11.0+wasi-snapshot-preview1
	wasi@0.9.0+wasi-snapshot-preview1
	wide@0.7.28
	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-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
	wio@0.2.2
	x11-clipboard@0.3.3
	xcb@0.8.2
	yaml-rust@0.4.5
	yeslogic-fontconfig-sys@5.0.0
	zerocopy-derive@0.7.35
	zerocopy@0.7.35
"

PYTHON_COMPAT=( python3_{12..13} )

inherit cargo python-any-r1

DESCRIPTION="Create beautiful image of your code"
HOMEPAGE="https://github.com/Aloxaf/silicon"
SRC_URI="
	https://github.com/Aloxaf/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
	${CARGO_CRATE_URIS}
"

LICENSE="MIT"
# Dependent crate licenses
LICENSE+=" Apache-2.0 BSD Boost-1.0 ISC MIT MPL-2.0 Unicode-DFS-2016"
SLOT="0"
KEYWORDS="~amd64"
# Prevent portage from trying to fetch bunch of *.crate from mirror despite they are not mirrored.
RESTRICT="mirror"
PATCHES=(
	"${FILESDIR}/silicon-0.5.3-cargo-toml-version.patch"
	"${FILESDIR}/silicon-0.5.3-remove-pathfinder_simd-patch.patch"
)

BDEPEND="
	virtual/pkgconfig
	${PYTHON_DEPS}"
DEPEND="
	dev-libs/oniguruma:=
	media-libs/fontconfig:=
	media-libs/freetype:=
	media-libs/harfbuzz:=
	x11-libs/libxcb:="
RDEPEND="${DEPEND}
	x11-misc/xclip"

QA_FLAGS_IGNORED="usr/bin/silicon"

pkg_setup() {
	python-any-r1_pkg_setup
	rust_pkg_setup
}

src_prepare() {
	# Apply patch <https://github.com/rust-x-bindings/rust-xcb/pull/87> for python 3.9 and above.
	( cd "${WORKDIR}"/cargo_home/gentoo/xcb-0.8.2 && \
		eapply "${FILESDIR}"/rust-xcb-0.8.2-python-3.9.patch )

	default_src_prepare
}

src_compile() {
	# onig_sys crate (as of silicon-0.5.2-r1 and onig_sys 69.8.1) does not support
	# gcc-15. See #945303.
	export RUSTONIG_SYSTEM_LIBONIG=1
	cargo_src_compile
}

src_install() {
	cargo_src_install

	dodoc README.md
}
