2024-06-08 22:30:15 +02:00
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI = 8
2024-06-27 02:42:21 +02:00
PYTHON_COMPAT = ( python3_{ 10..12} )
inherit cmake python-any-r1
2024-06-08 22:30:15 +02:00
DESCRIPTION = "Client library written in C for MongoDB"
HOMEPAGE = "https://github.com/mongodb/mongo-c-driver"
2024-06-27 02:42:21 +02:00
SRC_URI = " https://github.com/mongodb/mongo-c-driver/releases/download/ ${ PV } / ${ P } .tar.gz "
2024-06-08 22:30:15 +02:00
LICENSE = "Apache-2.0"
SLOT = "0"
KEYWORDS = "~amd64 ~arm64 ~hppa ~riscv ~x86"
2024-06-25 18:05:22 +02:00
IUSE = "debug examples +s3 sasl +ssl static-libs test +test-full"
2024-06-22 00:57:50 +02:00
REQUIRED_USE = "
s3? ( ssl )
test? ( static-libs ) "
2024-06-08 22:30:15 +02:00
2024-06-25 01:51:24 +02:00
RESTRICT = "!test? ( test )"
2024-06-08 22:30:15 +02:00
2024-06-22 00:57:50 +02:00
RDEPEND = "
app-arch/snappy:=
2024-06-08 22:30:15 +02:00
app-arch/zstd:=
>= dev-libs/libbson-${ PV } [ static-libs?]
2024-06-27 02:42:21 +02:00
>= dev-libs/libmongocrypt-1.10.1
2024-06-08 22:30:15 +02:00
>= dev-libs/libutf8proc-2.8.0:= [ static-libs?]
sys-libs/zlib:=
sasl? ( dev-libs/cyrus-sasl:= )
2024-06-22 00:57:50 +02:00
ssl? ( dev-libs/openssl:= )
"
DEPEND = "
${ RDEPEND }
2024-06-08 22:30:15 +02:00
test? (
dev-libs/libbson[ static-libs]
2024-06-27 02:47:44 +02:00
dev-libs/libmongocrypt[ static-libs]
dev-libs/libutf8proc[ static-libs]
2024-06-25 01:41:24 +02:00
test-full? (
dev-db/mongodb
)
2024-06-22 00:57:50 +02:00
)
"
2024-06-08 22:30:15 +02:00
2024-06-27 02:42:21 +02:00
BDEPEND = "
$( python_gen_any_dep '
dev-python/sphinx[ ${ PYTHON_USEDEP } ]
' )
"
python_check_deps( ) {
python_has_version -b " dev-python/sphinx[ ${ PYTHON_USEDEP } ] "
}
2024-06-08 22:30:15 +02:00
src_prepare( ) {
cmake_src_prepare
# copy private headers for tests since we don't build libbson
if use test; then
mkdir -p src/libbson/tests/bson || die
cp src/libbson/src/bson/bson-*.h src/libbson/tests/bson/ || die
fi
# remove doc files
sed -i '/^\s*install\s*(FILES COPYING NEWS/,/^\s*)/{d}' CMakeLists.txt || die
# enable tests
sed -i '/message (STATUS "disabling test-libmongoc since using system libbson")/{d}' CMakeLists.txt || die
sed -i '/SET (ENABLE_TESTS OFF)/{d}' CMakeLists.txt || die
sed -i 's/message (FATAL_ERROR "System libbson built without static library target")/message (STATUS "System libbson built without static library target")/' CMakeLists.txt || die
sed -i 's#<bson/bson-private.h>#"bson/bson-private.h"#' src/libbson/tests/test-bson.c || die
}
src_configure( ) {
local mycmakeargs = (
-DCMAKE_SKIP_RPATH= ON # mongoc-stat insecure runpath
-DUSE_SYSTEM_LIBBSON= ON
2024-06-22 00:57:50 +02:00
-DENABLE_CLIENT_SIDE_ENCRYPTION= ON
2024-06-08 22:30:15 +02:00
-DENABLE_EXAMPLES= OFF
-DENABLE_MAN_PAGES= ON
-DENABLE_MONGOC= ON
2024-06-22 00:57:50 +02:00
-DENABLE_MONGODB_AWS_AUTH= " $( usex s3 ON OFF) "
2024-06-08 22:30:15 +02:00
-DENABLE_SNAPPY= AUTO
-DENABLE_ZLIB= SYSTEM
-DENABLE_SASL= " $( usex sasl CYRUS OFF) "
-DENABLE_SRV= ON
-DENABLE_SSL= " $( usex ssl $( usex ssl OPENSSL) OFF) "
-DENABLE_STATIC= " $( usex static-libs ON OFF) "
-DENABLE_TESTS= " $( usex test ON OFF) "
-DENABLE_TRACING= " $( usex debug ON OFF) "
-DENABLE_UNINSTALL= OFF
-DENABLE_ZSTD= ON
-DUSE_BUNDLED_UTF8PROC= OFF
)
cmake_src_configure
}
# FEATURES="test -network-sandbox" USE="static-libs" emerge dev-libs/mongo-c-driver
src_test( ) {
2024-06-25 01:41:24 +02:00
if ! use test-full; then
export MONGOC_TEST_SKIP_LIVE = on
else
local PORT = 27099
export MONGOC_TEST_URI = " mongodb://[127.0.0.1]: ${ PORT } "
export MONGOC_ENABLE_MAJORITY_READ_CONCERN = on
LC_ALL = C \
mongod --setParameter enableTestCommands = 1 \
2024-06-25 18:05:22 +02:00
--port ${ PORT } --bind_ip 127.0.0.1 --nounixsocket \
--fork --dbpath= " ${ T } " \
--logpath= " ${ T } /mongod.log " || die
2024-06-25 01:41:24 +02:00
fi
../mongo-c-driver-${ PV } _build/src/libmongoc/test-libmongoc \
--skip-tests " ${ FILESDIR } /skip-tests.txt " || die
2024-06-08 22:30:15 +02:00
kill $( <" ${ T } /mongod.lock " )
}
src_install( ) {
if use examples; then
docinto examples
dodoc src/libmongoc/examples/*.c
fi
cmake_src_install
}