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

# Autogenerated by pycargoebuild 0.15.0

EAPI=8

CRATES="
"

RUST_MIN_VER="1.88.0"

inherit cargo shell-completion

DESCRIPTION="A fast static site generator with everything built-in"
HOMEPAGE="https://www.getzola.org"
SRC_URI="
	https://github.com/getzola/zola/archive/refs/tags/v${PV}.tar.gz
		-> ${P}.gh.tar.gz
	https://envs.net/~zyx/files/distfiles/${CATEGORY}/${PN}/${P}-vendor.tar.xz
" # make sure to update the webp crate like in commit 93fcc8668b0d before
  # making the crates tarball!

# Code prior to version 0.22 is MIT
LICENSE="EUPL-1.2 MIT"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD-2 BSD CC0-1.0 CDLA-Permissive-2.0 EUPL-1.2 ISC MIT
	MPL-2.0 UoI-NCSA Unicode-3.0 ZLIB
	|| ( Apache-2.0-with-LLVM-exceptions Boost-1.0 )
"

SLOT="0"
KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv"
IUSE="cjk"

RDEPEND="
	dev-libs/oniguruma:=
	media-libs/libwebp:=
"
DEPEND="${RDEPEND}"

BDEPEND="virtual/pkgconfig"

PATCHES=(
	"${FILESDIR}"/${PN}-0.22.1-always-build-manpages.patch
)

src_configure() {
	# Use system libraries
	export RUSTONIG_SYSTEM_LIBONIG=1

	local myfeatures=(
		# usev only takes 2 args
		$(usev cjk indexing-ja )
		$(usev cjk indexing-zh )
	)

	cargo_src_configure
}

src_compile() {
	cargo_src_compile

	echo "Generating shell completion files"
	for sh in bash fish zsh; do
		"$(cargo_target_dir)/${PN}" completion ${sh} > ${sh}.completion || die
	done
}

src_install() {
	cargo_src_install

	newbashcomp bash.completion ${PN}
	newfishcomp fish.completion ${PN}.fish
	newzshcomp zsh.completion _${PN}

	doman "$(cargo_target_dir)/build/${PN}-"*/out/${PN}{,-build,-check,-init,-serve}.1
}

pkg_postinst() {
	einfo "See https://github.com/getzola/zola/blob/master/CHANGELOG.md#0230-2026-08-05"
	einfo "For breaking changes with newer versions of zola using Terra 2.0 templates"
}
