dev-libs/marisa: add 0.3.1

Build system switched to cmake.
Backport SWIG binding fix (https://github.com/s-yata/marisa-trie/pull/123).
Add tools USE flag.

Part-of: https://github.com/gentoo/gentoo/pull/46052
Signed-off-by: Huang Rui <vowstar@gmail.com>
Signed-off-by: Yixun Lan <dlan@gentoo.org>
This commit is contained in:
Huang Rui
2026-04-01 19:31:11 +08:00
committed by Yixun Lan
parent 7f7c195e71
commit c5e8ea356c
5 changed files with 468 additions and 0 deletions

View File

@@ -1,2 +1,3 @@
DIST marisa-0.2.6.tar.gz 168332 BLAKE2B 3b8a89a9a0b344d9de96edb5bf17c50db07da373e75eba098f48c9064321d579ac104db622608119377084c79165bf558c804eaff591903b67330b13bc8acf55 SHA512 c094e4b22e1457efdd20f2b978ee421b53e36ed94e4fdbd8944136c0ba23da4f6ba9fe3a2c64729c1426aee4dbe8098bfa5eebb943ae7fdaa4eec760485c564d
DIST marisa-0.2.7.tar.gz 214468 BLAKE2B 58a3f5a38099e16aaccd523df4e3fa49a7222d41a3b242dc7d328eca6d3fae09aaaa092b94e5e83d8a21ee36be86abe37007860271369e3de95b722f556e0570 SHA512 5e162d1e4b6e78e60354c19dbb419088d1d832591a701ee5a844f9e61747b0ec0333732d2832a771e2a1bae7cc9e199a9eae5098e430ff331b4de372ccce4798
DIST marisa-0.3.1.tar.gz 212791 BLAKE2B 130735eb3743a78a32e9e2389da84b8cd251031c8362843d1fb26f32ee2d1a3a0acf1de413e0554959e0488b8f445bac92c41c3fa54b6c1dad5bb245dfe1584f SHA512 60757e354e4f0ff47662930af5c32a762c5f348c60019abb2d502c6c21ec220731edd9be8ea36e3ec68df90a6584eb311fe1e3d4258b3392609a87b0ef427121

View File

@@ -0,0 +1,353 @@
https://github.com/s-yata/marisa-trie/pull/123
https://github.com/s-yata/marisa-trie/commit/cf4602f08df49861d987d122bd85bfdb456fe7a0
From cf4602f08df49861d987d122bd85bfdb456fe7a0 Mon Sep 17 00:00:00 2001
From: Weng Xuetian <wengxt@gmail.com>
Date: Sat, 9 Aug 2025 02:31:06 -0700
Subject: [PATCH] Fix binding build and add CI to test it on linux. (#123)
Fix #121
Fix #122
---
.github/workflows/linux.yml | 23 +++++++++++++++++++++++
bindings/marisa-swig-python3.cxx | 15 +++++----------
bindings/marisa-swig.cxx | 15 +++++----------
bindings/perl/marisa-swig.cxx | 15 +++++----------
bindings/python/marisa-swig.cxx | 17 ++++++-----------
bindings/python3/marisa-swig-python3.cxx | 15 +++++----------
bindings/ruby/marisa-swig.cxx | 15 +++++----------
7 files changed, 54 insertions(+), 61 deletions(-)
diff --git a/bindings/marisa-swig-python3.cxx b/bindings/marisa-swig-python3.cxx
index 50ab6b0..10bbad3 100644
--- a/bindings/marisa-swig-python3.cxx
+++ b/bindings/marisa-swig-python3.cxx
@@ -27,8 +27,7 @@ size_t Query::query_id() const {
return query_.id();
}
-Keyset::Keyset() : keyset_(new (std::nothrow) marisa::Keyset) {
- MARISA_THROW_IF(keyset_ == NULL, ::MARISA_MEMORY_ERROR);
+Keyset::Keyset() : keyset_(new marisa::Keyset) {
}
Keyset::~Keyset() {
@@ -82,8 +81,7 @@ void Keyset::clear() {
}
Agent::Agent()
- : agent_(new (std::nothrow) marisa::Agent), buf_(NULL), buf_size_(0) {
- MARISA_THROW_IF(agent_ == NULL, ::MARISA_MEMORY_ERROR);
+ : agent_(new marisa::Agent), buf_(NULL), buf_size_(0) {
}
Agent::~Agent() {
@@ -101,8 +99,7 @@ void Agent::set_query(const char *ptr, size_t length) {
new_buf_size *= 2;
}
}
- char *new_buf = new (std::nothrow) char[new_buf_size];
- MARISA_THROW_IF(new_buf == NULL, MARISA_MEMORY_ERROR);
+ char *new_buf = new char[new_buf_size];
delete [] buf_;
buf_ = new_buf;
buf_size_ = new_buf_size;
@@ -141,8 +138,7 @@ size_t Agent::query_id() const {
return agent_->query().id();
}
-Trie::Trie() : trie_(new (std::nothrow) marisa::Trie) {
- MARISA_THROW_IF(trie_ == NULL, ::MARISA_MEMORY_ERROR);
+Trie::Trie() : trie_(new marisa::Trie) {
}
Trie::~Trie() {
@@ -195,8 +191,7 @@ void Trie::reverse_lookup(size_t id,
marisa::Agent agent;
agent.set_query(id);
trie_->reverse_lookup(agent);
- char * const buf = new (std::nothrow) char[agent.key().length()];
- MARISA_THROW_IF(buf == NULL, MARISA_MEMORY_ERROR);
+ char * const buf = new char[agent.key().length()];
std::memcpy(buf, agent.key().ptr(), agent.key().length());
*ptr_out_to_be_deleted = buf;
*length_out = agent.key().length();
diff --git a/bindings/marisa-swig.cxx b/bindings/marisa-swig.cxx
index 6c9037c..593f5f0 100644
--- a/bindings/marisa-swig.cxx
+++ b/bindings/marisa-swig.cxx
@@ -27,8 +27,7 @@ size_t Query::id() const {
return query_.id();
}
-Keyset::Keyset() : keyset_(new (std::nothrow) marisa::Keyset) {
- MARISA_THROW_IF(keyset_ == NULL, ::MARISA_MEMORY_ERROR);
+Keyset::Keyset() : keyset_(new marisa::Keyset) {
}
Keyset::~Keyset() {
@@ -82,8 +81,7 @@ void Keyset::clear() {
}
Agent::Agent()
- : agent_(new (std::nothrow) marisa::Agent), buf_(NULL), buf_size_(0) {
- MARISA_THROW_IF(agent_ == NULL, ::MARISA_MEMORY_ERROR);
+ : agent_(new marisa::Agent), buf_(NULL), buf_size_(0) {
}
Agent::~Agent() {
@@ -101,8 +99,7 @@ void Agent::set_query(const char *ptr, size_t length) {
new_buf_size *= 2;
}
}
- char *new_buf = new (std::nothrow) char[new_buf_size];
- MARISA_THROW_IF(new_buf == NULL, MARISA_MEMORY_ERROR);
+ char *new_buf = new char[new_buf_size];
delete [] buf_;
buf_ = new_buf;
buf_size_ = new_buf_size;
@@ -141,8 +138,7 @@ size_t Agent::query_id() const {
return agent_->query().id();
}
-Trie::Trie() : trie_(new (std::nothrow) marisa::Trie) {
- MARISA_THROW_IF(trie_ == NULL, ::MARISA_MEMORY_ERROR);
+Trie::Trie() : trie_(new marisa::Trie) {
}
Trie::~Trie() {
@@ -195,8 +191,7 @@ void Trie::reverse_lookup(size_t id,
marisa::Agent agent;
agent.set_query(id);
trie_->reverse_lookup(agent);
- char * const buf = new (std::nothrow) char[agent.key().length()];
- MARISA_THROW_IF(buf == NULL, MARISA_MEMORY_ERROR);
+ char * const buf = new char[agent.key().length()];
std::memcpy(buf, agent.key().ptr(), agent.key().length());
*ptr_out_to_be_deleted = buf;
*length_out = agent.key().length();
diff --git a/bindings/perl/marisa-swig.cxx b/bindings/perl/marisa-swig.cxx
index 6c9037c..593f5f0 100644
--- a/bindings/perl/marisa-swig.cxx
+++ b/bindings/perl/marisa-swig.cxx
@@ -27,8 +27,7 @@ size_t Query::id() const {
return query_.id();
}
-Keyset::Keyset() : keyset_(new (std::nothrow) marisa::Keyset) {
- MARISA_THROW_IF(keyset_ == NULL, ::MARISA_MEMORY_ERROR);
+Keyset::Keyset() : keyset_(new marisa::Keyset) {
}
Keyset::~Keyset() {
@@ -82,8 +81,7 @@ void Keyset::clear() {
}
Agent::Agent()
- : agent_(new (std::nothrow) marisa::Agent), buf_(NULL), buf_size_(0) {
- MARISA_THROW_IF(agent_ == NULL, ::MARISA_MEMORY_ERROR);
+ : agent_(new marisa::Agent), buf_(NULL), buf_size_(0) {
}
Agent::~Agent() {
@@ -101,8 +99,7 @@ void Agent::set_query(const char *ptr, size_t length) {
new_buf_size *= 2;
}
}
- char *new_buf = new (std::nothrow) char[new_buf_size];
- MARISA_THROW_IF(new_buf == NULL, MARISA_MEMORY_ERROR);
+ char *new_buf = new char[new_buf_size];
delete [] buf_;
buf_ = new_buf;
buf_size_ = new_buf_size;
@@ -141,8 +138,7 @@ size_t Agent::query_id() const {
return agent_->query().id();
}
-Trie::Trie() : trie_(new (std::nothrow) marisa::Trie) {
- MARISA_THROW_IF(trie_ == NULL, ::MARISA_MEMORY_ERROR);
+Trie::Trie() : trie_(new marisa::Trie) {
}
Trie::~Trie() {
@@ -195,8 +191,7 @@ void Trie::reverse_lookup(size_t id,
marisa::Agent agent;
agent.set_query(id);
trie_->reverse_lookup(agent);
- char * const buf = new (std::nothrow) char[agent.key().length()];
- MARISA_THROW_IF(buf == NULL, MARISA_MEMORY_ERROR);
+ char * const buf = new char[agent.key().length()];
std::memcpy(buf, agent.key().ptr(), agent.key().length());
*ptr_out_to_be_deleted = buf;
*length_out = agent.key().length();
diff --git a/bindings/python/marisa-swig.cxx b/bindings/python/marisa-swig.cxx
index ec7460a..593f5f0 100644
--- a/bindings/python/marisa-swig.cxx
+++ b/bindings/python/marisa-swig.cxx
@@ -27,8 +27,7 @@ size_t Query::id() const {
return query_.id();
}
-Keyset::Keyset() : keyset_(new (std::nothrow) marisa::Keyset) {
- MARISA_THROW_IF(keyset_ == NULL, ::MARISA_MEMORY_ERROR);
+Keyset::Keyset() : keyset_(new marisa::Keyset) {
}
Keyset::~Keyset() {
@@ -82,8 +81,7 @@ void Keyset::clear() {
}
Agent::Agent()
- : agent_(new (std::nothrow) marisa::Agent), buf_(NULL), buf_size_(0) {
- MARISA_THROW_IF(agent_ == NULL, ::MARISA_MEMORY_ERROR);
+ : agent_(new marisa::Agent), buf_(NULL), buf_size_(0) {
}
Agent::~Agent() {
@@ -101,8 +99,7 @@ void Agent::set_query(const char *ptr, size_t length) {
new_buf_size *= 2;
}
}
- char *new_buf = new (std::nothrow) char[new_buf_size];
- MARISA_THROW_IF(new_buf == NULL, MARISA_MEMORY_ERROR);
+ char *new_buf = new char[new_buf_size];
delete [] buf_;
buf_ = new_buf;
buf_size_ = new_buf_size;
@@ -141,8 +138,7 @@ size_t Agent::query_id() const {
return agent_->query().id();
}
-Trie::Trie() : trie_(new (std::nothrow) marisa::Trie) {
- MARISA_THROW_IF(trie_ == NULL, ::MARISA_MEMORY_ERROR);
+Trie::Trie() : trie_(new marisa::Trie) {
}
Trie::~Trie() {
@@ -153,7 +149,7 @@ void Trie::build(Keyset &keyset, int config_flags) {
trie_->build(*keyset.keyset_, config_flags);
}
-void Trie::mmap(const char *filename, , int flags) {
+void Trie::mmap(const char *filename, int flags) {
trie_->mmap(filename, flags);
}
@@ -195,8 +191,7 @@ void Trie::reverse_lookup(size_t id,
marisa::Agent agent;
agent.set_query(id);
trie_->reverse_lookup(agent);
- char * const buf = new (std::nothrow) char[agent.key().length()];
- MARISA_THROW_IF(buf == NULL, MARISA_MEMORY_ERROR);
+ char * const buf = new char[agent.key().length()];
std::memcpy(buf, agent.key().ptr(), agent.key().length());
*ptr_out_to_be_deleted = buf;
*length_out = agent.key().length();
diff --git a/bindings/python3/marisa-swig-python3.cxx b/bindings/python3/marisa-swig-python3.cxx
index 50ab6b0..10bbad3 100644
--- a/bindings/python3/marisa-swig-python3.cxx
+++ b/bindings/python3/marisa-swig-python3.cxx
@@ -27,8 +27,7 @@ size_t Query::query_id() const {
return query_.id();
}
-Keyset::Keyset() : keyset_(new (std::nothrow) marisa::Keyset) {
- MARISA_THROW_IF(keyset_ == NULL, ::MARISA_MEMORY_ERROR);
+Keyset::Keyset() : keyset_(new marisa::Keyset) {
}
Keyset::~Keyset() {
@@ -82,8 +81,7 @@ void Keyset::clear() {
}
Agent::Agent()
- : agent_(new (std::nothrow) marisa::Agent), buf_(NULL), buf_size_(0) {
- MARISA_THROW_IF(agent_ == NULL, ::MARISA_MEMORY_ERROR);
+ : agent_(new marisa::Agent), buf_(NULL), buf_size_(0) {
}
Agent::~Agent() {
@@ -101,8 +99,7 @@ void Agent::set_query(const char *ptr, size_t length) {
new_buf_size *= 2;
}
}
- char *new_buf = new (std::nothrow) char[new_buf_size];
- MARISA_THROW_IF(new_buf == NULL, MARISA_MEMORY_ERROR);
+ char *new_buf = new char[new_buf_size];
delete [] buf_;
buf_ = new_buf;
buf_size_ = new_buf_size;
@@ -141,8 +138,7 @@ size_t Agent::query_id() const {
return agent_->query().id();
}
-Trie::Trie() : trie_(new (std::nothrow) marisa::Trie) {
- MARISA_THROW_IF(trie_ == NULL, ::MARISA_MEMORY_ERROR);
+Trie::Trie() : trie_(new marisa::Trie) {
}
Trie::~Trie() {
@@ -195,8 +191,7 @@ void Trie::reverse_lookup(size_t id,
marisa::Agent agent;
agent.set_query(id);
trie_->reverse_lookup(agent);
- char * const buf = new (std::nothrow) char[agent.key().length()];
- MARISA_THROW_IF(buf == NULL, MARISA_MEMORY_ERROR);
+ char * const buf = new char[agent.key().length()];
std::memcpy(buf, agent.key().ptr(), agent.key().length());
*ptr_out_to_be_deleted = buf;
*length_out = agent.key().length();
diff --git a/bindings/ruby/marisa-swig.cxx b/bindings/ruby/marisa-swig.cxx
index 6c9037c..593f5f0 100644
--- a/bindings/ruby/marisa-swig.cxx
+++ b/bindings/ruby/marisa-swig.cxx
@@ -27,8 +27,7 @@ size_t Query::id() const {
return query_.id();
}
-Keyset::Keyset() : keyset_(new (std::nothrow) marisa::Keyset) {
- MARISA_THROW_IF(keyset_ == NULL, ::MARISA_MEMORY_ERROR);
+Keyset::Keyset() : keyset_(new marisa::Keyset) {
}
Keyset::~Keyset() {
@@ -82,8 +81,7 @@ void Keyset::clear() {
}
Agent::Agent()
- : agent_(new (std::nothrow) marisa::Agent), buf_(NULL), buf_size_(0) {
- MARISA_THROW_IF(agent_ == NULL, ::MARISA_MEMORY_ERROR);
+ : agent_(new marisa::Agent), buf_(NULL), buf_size_(0) {
}
Agent::~Agent() {
@@ -101,8 +99,7 @@ void Agent::set_query(const char *ptr, size_t length) {
new_buf_size *= 2;
}
}
- char *new_buf = new (std::nothrow) char[new_buf_size];
- MARISA_THROW_IF(new_buf == NULL, MARISA_MEMORY_ERROR);
+ char *new_buf = new char[new_buf_size];
delete [] buf_;
buf_ = new_buf;
buf_size_ = new_buf_size;
@@ -141,8 +138,7 @@ size_t Agent::query_id() const {
return agent_->query().id();
}
-Trie::Trie() : trie_(new (std::nothrow) marisa::Trie) {
- MARISA_THROW_IF(trie_ == NULL, ::MARISA_MEMORY_ERROR);
+Trie::Trie() : trie_(new marisa::Trie) {
}
Trie::~Trie() {
@@ -195,8 +191,7 @@ void Trie::reverse_lookup(size_t id,
marisa::Agent agent;
agent.set_query(id);
trie_->reverse_lookup(agent);
- char * const buf = new (std::nothrow) char[agent.key().length()];
- MARISA_THROW_IF(buf == NULL, MARISA_MEMORY_ERROR);
+ char * const buf = new char[agent.key().length()];
std::memcpy(buf, agent.key().ptr(), agent.key().length());
*ptr_out_to_be_deleted = buf;
*length_out = agent.key().length();

View File

@@ -0,0 +1,21 @@
Remove CONFIGURATIONS Release from install() so the library and tools
are installed regardless of the cmake build type (e.g. RelWithDebInfo).
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -258,7 +258,6 @@
install(
TARGETS marisa
EXPORT MarisaTargets
- CONFIGURATIONS Release
DESTINATION ${LIB_INSTALL_DIR}
COMPONENT Library
)
@@ -272,7 +271,6 @@
if(ENABLE_TOOLS)
install(
TARGETS ${MARISA_TOOLS}
- CONFIGURATIONS Release
COMPONENT Binaries
)
endif()

View File

@@ -0,0 +1,90 @@
# Copyright 2014-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI="8"
PYTHON_COMPAT=( python3_{12..14} )
DISTUTILS_USE_PEP517="setuptools"
DISTUTILS_OPTIONAL="1"
DISTUTILS_EXT=1
inherit cmake distutils-r1
DESCRIPTION="Matching Algorithm with Recursively Implemented StorAge"
HOMEPAGE="https://github.com/s-yata/marisa-trie"
SRC_URI="https://github.com/s-yata/marisa-trie/archive/v${PV}.tar.gz -> ${P}.tar.gz"
S="${WORKDIR}/marisa-trie-${PV}"
LICENSE="|| ( BSD-2 LGPL-2.1+ )"
SLOT="0"
KEYWORDS="~amd64 ~arm64 ~hppa ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86"
IUSE="python tools"
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
BDEPEND="python? (
${PYTHON_DEPS}
${DISTUTILS_DEPS}
dev-lang/swig
)"
DEPEND="python? ( ${PYTHON_DEPS} )"
RDEPEND="${DEPEND}"
PATCHES=(
"${FILESDIR}/${P}-install-all-configs.patch"
"${FILESDIR}/${P}-fix-swig-bindings.patch"
)
src_prepare() {
cmake_src_prepare
sed -e "s:^\([[:space:]]*\)libraries=:\1include_dirs=[\"../../include\"],\n\1library_dirs=[\"../../lib/marisa\"],\n&:" \
-e "s:setup(name = \"marisa\":setup(name = \"marisa\", version = \"${PV}\":" \
-i bindings/python/setup.py || die
if use python; then
pushd bindings/python > /dev/null || die
distutils-r1_src_prepare
popd > /dev/null || die
fi
}
src_configure() {
local mycmakeargs=(
-DLIB_INSTALL_DIR="$(get_libdir)"
-DENABLE_TOOLS=$(usex tools)
-DBUILD_TESTING=OFF
)
cmake_src_configure
if use python; then
pushd bindings/python > /dev/null || die
distutils-r1_src_configure
popd > /dev/null || die
fi
}
src_compile() {
cmake_src_compile
if use python; then
emake -C bindings swig-python
pushd bindings/python > /dev/null || die
distutils-r1_src_compile
popd > /dev/null || die
fi
}
src_install() {
cmake_src_install
(
docinto html
dodoc docs/*
)
if use python; then
pushd bindings/python > /dev/null || die
distutils-r1_src_install
popd > /dev/null || die
fi
}

View File

@@ -13,6 +13,9 @@
<email>proxy-maint@gentoo.org</email>
<name>Proxy Maintainers</name>
</maintainer>
<use>
<flag name="tools">Build command-line tools</flag>
</use>
<upstream>
<remote-id type="github">s-yata/marisa-trie</remote-id>
</upstream>