Apocrypha

libchewing-0.10.3gentoo

# Copyright 2004-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

# Build dir should be inside of source dir for tests
BUILD_DIR="${WORKDIR}/${P}/build"

RUST_MIN_VER="1.88.0"

# from pycargoebuild
CRATES="
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]+wasi-0.2.4
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
	[email protected]
"

inherit cargo cmake unpacker

DESCRIPTION="The intelligent phonetic input method library"
HOMEPAGE="https://chewing.im/ https://github.com/chewing/libchewing"
SRC_URI="https://github.com/chewing/libchewing/releases/download/v${PV}/${P}.tar.zst
	${CARGO_CRATE_URIS}"

LICENSE="LGPL-2.1"
# Dependent crate licenses
LICENSE+=" MIT Unicode-3.0 ZLIB"
SLOT="0/3"
KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86"
IUSE="test"
RESTRICT="!test? ( test )"

BDEPEND="
	>=dev-build/cmake-3.21.0
	dev-build/corrosion
"
RDEPEND="dev-db/sqlite:3"
DEPEND="${RDEPEND}
	test? ( sys-libs/ncurses[unicode(+)] )"

PATCHES=(
	"${FILESDIR}/libchewing-0.10.3_man-compression.patch"
)

src_unpack() {
	unpacker ${P}.tar.zst
	cargo_src_unpack
}

src_configure() {
	local mycmakeargs=(
		-DCMAKE_DISABLE_FIND_PACKAGE_Git=ON
		-DBUILD_SHARED_LIBS=ON
		-DBUILD_TESTING=$(usex test)
		-DCOMPRESS_MANS=OFF
		-DENABLE_GCOV=OFF
		-DWITH_SQLITE3=ON	# use system sqlite
		-DUSE_VALGRIND=OFF	# only for testing purpose
	)
	cmake_src_configure
}

src_compile() {
	cargo_env cmake_src_compile
}

src_test() {
	# https://github.com/chewing/libchewing/issues/293
	cmake_src_test -j1
}

src_install() {
	cargo_env cmake_src_install
}