# Copyright 2024 Kirixetamine <revelation@krxt.dev>
# Distributed under the terms of the ISC License

# Crates autogenerated by pycargoebuild 0.13.2

EAPI=8

CRATES="
	aho-corasick@1.1.1
	anyhow@1.0.75
	ashpd@0.6.2
	async-broadcast@0.5.1
	async-channel@1.9.0
	async-executor@1.5.1
	async-fs@1.6.0
	async-global-executor@2.3.1
	async-io@1.13.0
	async-lock@2.8.0
	async-process@1.7.0
	async-recursion@1.0.5
	async-std@1.12.0
	async-task@4.4.0
	async-trait@0.1.73
	atomic-waker@1.1.1
	autocfg@1.1.0
	bitflags@1.3.2
	bitflags@2.4.0
	block-buffer@0.10.4
	block@0.1.6
	blocking@1.3.1
	bumpalo@3.14.0
	byteorder@1.4.3
	cairo-rs@0.18.2
	cairo-sys-rs@0.18.2
	cc@1.0.83
	cfg-expr@0.15.5
	cfg-if@1.0.0
	concurrent-queue@2.2.0
	cpufeatures@0.2.9
	crossbeam-utils@0.8.16
	crypto-common@0.1.6
	derivative@2.2.0
	digest@0.10.7
	enumflags2@0.7.8
	enumflags2_derive@0.7.8
	equivalent@1.0.1
	errno-dragonfly@0.1.2
	errno@0.3.3
	event-listener@2.5.3
	fastrand@1.9.0
	fastrand@2.0.0
	field-offset@0.3.6
	form_urlencoded@1.2.0
	futures-channel@0.3.28
	futures-core@0.3.28
	futures-executor@0.3.28
	futures-io@0.3.28
	futures-lite@1.13.0
	futures-macro@0.3.28
	futures-sink@0.3.28
	futures-task@0.3.28
	futures-util@0.3.28
	gdk-pixbuf-sys@0.18.0
	gdk-pixbuf@0.18.0
	gdk4-sys@0.7.2
	gdk4-wayland-sys@0.7.2
	gdk4-wayland@0.7.2
	gdk4-x11-sys@0.7.2
	gdk4-x11@0.7.2
	gdk4@0.7.3
	generic-array@0.14.7
	getrandom@0.2.10
	gettext-rs@0.7.0
	gettext-sys@0.21.3
	gio-sys@0.18.1
	gio@0.18.2
	glib-macros@0.18.2
	glib-sys@0.18.1
	glib@0.18.2
	gloo-timers@0.2.6
	gobject-sys@0.18.0
	graphene-rs@0.18.1
	graphene-sys@0.18.1
	gsk4-sys@0.7.3
	gsk4@0.7.3
	gtk4-macros@0.7.2
	gtk4-sys@0.7.3
	gtk4@0.7.3
	hashbrown@0.14.0
	heck@0.4.1
	hermit-abi@0.3.3
	hex@0.4.3
	idna@0.4.0
	indexmap@2.0.0
	instant@0.1.12
	io-lifetimes@1.0.11
	js-sys@0.3.64
	json@0.12.4
	kv-log-macro@1.0.7
	lazy_static@1.4.0
	libadwaita-sys@0.5.3
	libadwaita@0.5.3
	libc@0.2.148
	linux-raw-sys@0.3.8
	linux-raw-sys@0.4.7
	locale_config@0.3.0
	log@0.4.20
	malloc_buf@0.0.6
	memchr@2.6.3
	memoffset@0.7.1
	memoffset@0.9.0
	mime@0.3.17
	mime_guess@2.0.4
	minimal-lexical@0.2.1
	nix@0.26.4
	nom@7.1.3
	objc-foundation@0.1.1
	objc@0.2.7
	objc_id@0.1.1
	once_cell@1.18.0
	ordered-stream@0.2.0
	pango-sys@0.18.0
	pango@0.18.0
	parking@2.1.0
	percent-encoding@2.3.0
	pin-project-lite@0.2.13
	pin-utils@0.1.0
	pkg-config@0.3.27
	polling@2.8.0
	ppv-lite86@0.2.17
	proc-macro-crate@1.3.1
	proc-macro-error-attr@1.0.4
	proc-macro-error@1.0.4
	proc-macro2@1.0.67
	quote@1.0.33
	rand@0.8.5
	rand_chacha@0.3.1
	rand_core@0.6.4
	redox_syscall@0.3.5
	regex-automata@0.3.8
	regex-syntax@0.7.5
	regex@1.9.5
	rustc_version@0.4.0
	rustix@0.37.23
	rustix@0.38.14
	semver@1.0.19
	serde@1.0.188
	serde_derive@1.0.188
	serde_repr@0.1.16
	serde_spanned@0.6.3
	sha1@0.10.6
	signal-hook-registry@1.4.1
	signal-hook@0.3.17
	slab@0.4.9
	smallvec@1.11.1
	socket2@0.4.9
	static_assertions@1.1.0
	syn@1.0.109
	syn@2.0.37
	system-deps@6.1.1
	target-lexicon@0.12.11
	temp-dir@0.1.11
	tempfile@3.8.0
	thiserror-impl@1.0.48
	thiserror@1.0.48
	tinyvec@1.6.0
	tinyvec_macros@0.1.1
	toml@0.7.8
	toml_datetime@0.6.3
	toml_edit@0.19.15
	tracing-attributes@0.1.26
	tracing-core@0.1.31
	tracing@0.1.37
	typenum@1.17.0
	uds_windows@1.0.2
	unicase@2.7.0
	unicode-bidi@0.3.13
	unicode-ident@1.0.12
	unicode-normalization@0.1.22
	url@2.4.1
	value-bag@1.4.1
	version-compare@0.1.1
	version_check@0.9.4
	waker-fn@1.1.0
	wasi@0.11.0+wasi-snapshot-preview1
	wasm-bindgen-backend@0.2.87
	wasm-bindgen-futures@0.4.37
	wasm-bindgen-macro-support@0.2.87
	wasm-bindgen-macro@0.2.87
	wasm-bindgen-shared@0.2.87
	wasm-bindgen@0.2.87
	web-sys@0.3.64
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-x86_64-pc-windows-gnu@0.4.0
	winapi@0.3.9
	windows-sys@0.48.0
	windows-targets@0.48.5
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_msvc@0.48.5
	windows_i686_gnu@0.48.5
	windows_i686_msvc@0.48.5
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_msvc@0.48.5
	winnow@0.5.15
	xdg-home@1.0.0
	zbus@3.14.1
	zbus_macros@3.14.1
	zbus_names@2.6.0
	zvariant@3.15.0
	zvariant_derive@3.15.0
	zvariant_utils@1.0.1
"

# FIXME: Why is this here...?
PYTHON_COMPAT=( python3_{9..13} )

inherit gnome2-utils meson cargo xdg

DESCRIPTION="Trim videos quickly"
HOMEPAGE="https://gitlab.gnome.org/YaLTeR/video-trimmer"
REPO_URI="https://gitlab.gnome.org/YaLTeR/video-trimmer"

MY_P="${PN}-v${PV}"

SRC_URI="
	${REPO_URI}/-/archive/v${PV}/${MY_P}.tar.gz
	${CARGO_CRATE_URIS}"
S="${WORKDIR}/${MY_P}"

LICENSE="GPL-3"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD MIT Unicode-DFS-2016
"
SLOT="0"
KEYWORDS="~amd64"

DEPEND="
	>=gui-libs/libadwaita-1.4.0
	gui-libs/gtk
"

RDEPEND="${DEPEND}"

BDEPEND="
	virtual/rust
	dev-util/blueprint-compiler
"

PATCHES="${FILESDIR}/cargo-frozen-flag.patch"

RESTRICT="test mirror"

src_prepare() {
	default
	xdg_environment_reset
}

src_unpack() {
	cargo_src_unpack
}

src_configure() {
	meson_src_configure # Required for config.rs.in replacements
	cargo_src_configure
}

# Both meson and cargo compile commands are needed
# as we heavily modify the repo, but meson is still needed for configuration
# outside of src_configure (wish it wasn't here though)
src_compile() {
	meson_src_compile
	cargo_src_compile --frozen --all-features
}

src_install() {
	meson_src_install
	cargo_src_install
}

pkg_postinst() {
	gnome2_schemas_update
	xdg_icon_cache_update
	xdg_desktop_database_update
	xdg_mimeinfo_database_update
}

pkg_postrm() {
	gnome2_schemas_update
	xdg_icon_cache_update
	xdg_desktop_database_update
	xdg_mimeinfo_database_update
}

QA_PRESTRIPPED="/usr/bin/${PN}"