diff --git a/dev-libs/blake3/blake3-1.5.3.ebuild b/dev-libs/blake3/blake3-1.5.3.ebuild index 073d73e0061b58..4218df1950031f 100644 --- a/dev-libs/blake3/blake3-1.5.3.ebuild +++ b/dev-libs/blake3/blake3-1.5.3.ebuild @@ -3,7 +3,8 @@ EAPI=8 -inherit cmake +PYTHON_COMPAT=( python3_{11..13} ) +inherit cmake python-any-r1 DESCRIPTION="a fast cryptographic hash function" HOMEPAGE="https://github.com/BLAKE3-team/BLAKE3" @@ -13,3 +14,14 @@ S="${WORKDIR}/BLAKE3-${PV}/c" LICENSE="|| ( CC0-1.0 Apache-2.0 )" SLOT="0/0" KEYWORDS="~amd64 ~arm ~arm64 ~ia64 ~loong ~m68k ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" +IUSE="test" +RESTRICT="!test? ( test )" +PATCHES=( "${FILESDIR}/${PN}-1.5.3-backport-pr405.patch" ) +BDEPEND="test? ( ${PYTHON_DEPS} )" + +src_configure() { + local mycmakeargs=( + -DBLAKE3_BUILD_TESTING="$(usex test)" + ) + cmake_src_configure +} diff --git a/dev-libs/blake3/files/blake3-1.5.3-backport-pr405.patch b/dev-libs/blake3/files/blake3-1.5.3-backport-pr405.patch new file mode 100644 index 00000000000000..53db4816a85934 --- /dev/null +++ b/dev-libs/blake3/files/blake3-1.5.3-backport-pr405.patch @@ -0,0 +1,57 @@ +https://bugs.gentoo.org/935370 +https://github.com/BLAKE3-team/BLAKE3/pull/405 + +From aad68f7f009b7e0607b3eee3b8b8e3021fa38bd7 Mon Sep 17 00:00:00 2001 +From: matoro +Date: Tue, 2 Jul 2024 19:36:45 -0400 +Subject: [PATCH] build(CMake): support running tests with ctest + +--- + CMakeLists.txt | 11 +++++++++++ + test.py | 4 ++-- + 2 files changed, 13 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3a3b232d..e778e3d7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -168,6 +168,17 @@ else() + BLAKE3_DISABLE_SIMD() + endif() + ++# cmake test support ++if (BLAKE3_BUILD_TESTING) ++ find_package(Python3 REQUIRED) ++ get_target_property(BLAKE3_SOURCES blake3 SOURCES) ++ add_executable(blake3-testing ${BLAKE3_SOURCES} main.c) ++ set_property(TARGET blake3-testing PROPERTY OUTPUT_NAME blake3) ++ target_compile_definitions(blake3-testing PRIVATE BLAKE3_TESTING=1) ++ enable_testing() ++ add_test(test_vectors "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/test.py" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") ++endif() ++ + # cmake install support + install(FILES blake3.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + install(TARGETS blake3 EXPORT blake3-targets) +diff --git a/test.py b/test.py +index 98b1c3df..2eb1f07e 100755 +--- a/test.py ++++ b/test.py +@@ -2,7 +2,7 @@ + + from binascii import hexlify + import json +-from os import path ++from os import getcwd, path + import subprocess + + HERE = path.dirname(__file__) +@@ -11,7 +11,7 @@ + + + def run_blake3(args, input): +- output = subprocess.run([path.join(HERE, "blake3")] + args, ++ output = subprocess.run([path.join(getcwd(), "blake3")] + args, + input=input, + stdout=subprocess.PIPE, + check=True)