diff options
-rw-r--r-- | .gitignore | 9 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | valkey-json-offline.patch | 49 | ||||
-rw-r--r-- | valkey-json.spec | 111 |
4 files changed, 173 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01f0400 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +clog +package-*.xml +*.tgz +*.tar.bz2 +*.tar.gz +*.tar.xz +*.tar.xz.asc +*.src.rpm +*/*rpm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..91b0fd5 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../common/Makefile + diff --git a/valkey-json-offline.patch b/valkey-json-offline.patch new file mode 100644 index 0000000..e4933bd --- /dev/null +++ b/valkey-json-offline.patch @@ -0,0 +1,49 @@ +diff -up ./CMakeLists.txt.old ./CMakeLists.txt +--- ./CMakeLists.txt.old 2025-08-06 09:38:41.575001413 +0200 ++++ ./CMakeLists.txt 2025-08-06 10:49:15.720138781 +0200 +@@ -69,6 +69,10 @@ else() + endif() + endif() + ++if(BUILD_RELEASE) ++ file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/include") ++ file(COPY_FILE "/usr/include/valkeymodule.h" "${CMAKE_CURRENT_SOURCE_DIR}/src/include/valkeymodule.h") ++else() + ExternalProject_Add( + valkey + GIT_REPOSITORY https://github.com/valkey-io/valkey.git +@@ -94,6 +98,7 @@ ExternalProject_Add_Step( + COMMAND ${CMAKE_COMMAND} -E copy ${VALKEY_DOWNLOAD_DIR}/src/valkey/src/valkeymodule.h ${VALKEY_INCLUDE_DIR}/valkeymodule.h + ALWAYS 1 + ) ++endif() + + # Integration tests require the valkey-test-framework which is only needed when + # building Valkey from source. +@@ -171,11 +176,18 @@ message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS} + message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") + + # Fetch RapidJSON ++if(BUILD_RELEASE) ++FetchContent_Declare( ++ rapidjson ++ SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rapidjson-ebd87cb468fb4cb060b37e579718c4a4125416c1" ++) ++else() + FetchContent_Declare( + rapidjson + GIT_REPOSITORY https://github.com/Tencent/rapidjson.git + GIT_TAG ebd87cb468fb4cb060b37e579718c4a4125416c1 + ) ++endif() + + # Disable RapidJSON tests and examples + set(RAPIDJSON_BUILD_TESTS OFF CACHE BOOL "Build rapidjson tests" FORCE) +diff -up ./src/CMakeLists.txt.old ./src/CMakeLists.txt +--- ./src/CMakeLists.txt.old 2025-08-06 09:46:37.672820317 +0200 ++++ ./src/CMakeLists.txt 2025-08-06 09:46:46.976759840 +0200 +@@ -39,4 +39,3 @@ target_sources(${OBJECT_TARGET} + ) + + add_library(${JSON_MODULE_LIB} SHARED $<TARGET_OBJECTS:${OBJECT_TARGET}>) +-add_dependencies(${OBJECT_TARGET} valkey) diff --git a/valkey-json.spec b/valkey-json.spec new file mode 100644 index 0000000..c8aa269 --- /dev/null +++ b/valkey-json.spec @@ -0,0 +1,111 @@ +# remirepo/fedora spec file for valkey-json +# +# SPDX-FileCopyrightText: Copyright 2025 Remi Collet +# SPDX-License-Identifier: CECILL-2.1 +# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +# +# Please, preserve the changelog entries +# + +%global cfgname json.conf +%global libname json.so +# Github forge +%global gh_vend valkey-io +%global gh_proj valkey-json +%global forgeurl https://github.com/%{gh_vend}/%{gh_proj} +#global commit afe5de4ce52bb2b80af565a6f297bf330a65d0d8 +%global tag %{version} + +# see CMakeLists.txt for commit ref +# change will also require patch update +%global rapidjson_url https://github.com/Tencent/rapidjson +%global rapidjson_commit ebd87cb468fb4cb060b37e579718c4a4125416c1 + +Name: valkey-json +Version: 1.0.1 +%forgemeta +Release: 1%{?dist} +Summary: JSON as native data type +# this module is BSD-3-Clause +# RapidJSON is MIT +License: BSD-3-Clause AND MIT +URL: %{forgeurl} +Source0: %{forgesource} +Source1: %{rapidjson_url}/archive/%{rapidjson_commit}/rapidjson-%{rapidjson_commit}.tar.gz + +# use header from valkey-devel to avoid downloading valkey sources +# use rapidjson git snapshot to avoid download +Patch0: %{name}-offline.patch + +BuildRequires: valkey-devel >= 8.0 +BuildRequires: cmake >= 3.17 +BuildRequires: gcc-c++ + +Requires: valkey(modules_abi)%{?_isa} = %{valkey_modules_abi} +Requires: valkey >= 8.0 +Supplements: valkey + +Provides: bundled(RapidJSON) + + +%description +Valkey-json is a Valkey module written in C++ that provides native JSON +(JavaScript Object Notation) support for Valkey. + +The implementation complies with RFC7159 and ECMA-404 JSON data interchange +standards. Users can natively store, query, and modify JSON data structures +using the JSONPath query language. The query expressions support advanced +capabilities including wildcard selections, filter expressions, array slices, +union operations, and recursive searches. + +Valkey-json leverages RapidJSON, a high-performance JSON parser and generator +for C++, chosen for its small footprint and exceptional performance and memory +efficiency. As a header-only library with no external dependencies, RapidJSON +provides robust Unicode support while maintaining a compact memory profile of +just 16 bytes per JSON value on most 32/64-bit machines. + +See https://rapidjson.org/ + + +%prep +%setup -q -n %{gh_proj}-%{version} -a1 +%patch -P0 -p1 + +: Configuration file +cat << EOF | tee %{cfgname} +# %{gh_proj} +loadmodule %{valkey_modules_dir}/%{libname} +EOF + +cp -p src/rapidjson/license.txt LICENSE.rapidjson + + +%build +%cmake \ + -DVALKEY_VERSION=8.1 \ + -DBUILD_RELEASE:BOOL=ON \ + -DENABLE_UNIT_TESTS:BOOL=OFF \ + -DENABLE_INTEGRATION_TESTS:BOOL=OFF + +%cmake_build + + +%install +%if 0%{?rhel} == 8 +install -Dpm755 src/*%{libname} %{buildroot}%{valkey_modules_dir}/%{libname} +%else +install -Dpm755 *build/src/*%{libname} %{buildroot}%{valkey_modules_dir}/%{libname} +%endif +install -Dpm640 %{cfgname} %{buildroot}%{valkey_modules_cfg}/%{cfgname} + + +%files +%license LICENSE* +%doc *.md +%attr(0640, valkey, root) %config(noreplace) %{valkey_modules_cfg}/%{cfgname} +%{valkey_modules_dir}/%{libname} + + +%changelog +* Wed Aug 6 2025 Remi Collet <remi@remirepo.net> - 1.0.1-1 +- initial package |