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

EAPI=8

PYTHON_COMPAT=( python3_{13..15} )
DISTUTILS_EXT=1
DISTUTILS_SINGLE_IMPL=true
DISTUTILS_USE_PEP517=no

DESCRIPTION="VapourSynth 3:2-pulldown removal for NTSC"
HOMEPAGE="https://github.com/theChaosCoder/vapoursynth-it"

declare -g -r -A ZBS_DEPENDENCIES=(
	[vapoursynth-4.0.0-jLYMQ6DjAgDFOODh8tdhWCw0iGHMPKiR4znTJwSyvV36.tar.gz]='https://github.com/dnjulek/vapoursynth-zig/archive/b87ff61ce680fa5a4cf7d44a9cb4b605c5037432.tar.gz'
)

ZIG_SLOT="0.16"

inherit distutils-r1 zig

SRC_URI="
	https://github.com/theChaosCoder/vapoursynth-it/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	${ZBS_DEPENDENCIES_SRC_URI}
"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""
RESTRICT="mirror test"

RDEPEND="
	media-libs/vapoursynth[${PYTHON_SINGLE_USEDEP}]
"

DOCS=( "README.md" )

# NOTE: this is a hack until zig-0.17 is packaged in Gentoo
src_prepare() {
	sed -i 's/ \.fast/ \.ReleaseFast/' build.zig || die
	zig_src_prepare
}

src_install() {
	zig_src_install --prefix-lib-dir "$(vapoursynth get-plugin-dir)"
}