From 00c740742a1979d92de4eabf7c750b54eed15648 Mon Sep 17 00:00:00 2001 From: Joe Hu Date: Mon, 9 Dec 2024 18:14:48 -0500 Subject: [PATCH] Fix #7 - Make SERVER_VERSION open to all versions (#22) Signed-off-by: Joe Hu Co-authored-by: Joe Hu --- CMakeLists.txt | 14 +++++++++----- README.md | 21 +++++++++++++++------ build.sh | 11 +++-------- src/CMakeLists.txt | 2 +- tst/integration/run.sh | 2 +- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b29ac9e..73a5bd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,12 +10,10 @@ EXECUTE_PROCESS( OUTPUT_VARIABLE ARCHITECTURE ) -if("${ARCHITECTURE}" STREQUAL "x86_64") - message("Building JSON for x86_64") -elseif("${ARCHITECTURE}" STREQUAL "aarch64") - message("Building JSON for aarch64") +if("${ARCHITECTURE}" STREQUAL "x86_64" OR "${ARCHITECTURE}" STREQUAL "aarch64") + message("Building valkeyJSON for ${ARCHITECTURE}") else() - message(FATAL_ERROR "Unsupported architecture: ${ARCHITECTURE}. JSON is only supported on x86_64 and aarch64.") + message(FATAL_ERROR "Unsupported architecture: ${ARCHITECTURE}. valkeyJSON is only supported on x86_64 and aarch64.") endif() # Project definition @@ -28,6 +26,12 @@ set(JSON_MODULE_LIB json) set(VALKEY_DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/_deps/valkey-src") set(VALKEY_BIN_DIR "${CMAKE_BINARY_DIR}/_deps/valkey-src/src/valkey/src") +# Valkey version +if(NOT VALKEY_VERSION) + set(VALKEY_VERSION unstable) +endif() +message("Valkey version: ${VALKEY_VERSION}") + # Download and build Valkey ExternalProject_Add( valkey diff --git a/README.md b/README.md index 25f7f98..c1e2e22 100644 --- a/README.md +++ b/README.md @@ -8,20 +8,29 @@ ValkeyJSON leverages [RapidJSON](https://rapidjson.org/), a high-performance JSO #### To build the module and run tests ```text -# Builds the valkey-server (unstable) for integration testing. -export SERVER_VERSION=unstable +# Build valkey-server (unstable) and run integration tests ./build.sh +``` -# Builds the valkey-server (8.0.0) for integration testing. -export SERVER_VERSION=8.0.0 -./build.sh +The default valkey version is "unstable". To override it, do: +```text +# Build valkey-server (8.0.0) and run integration tests +SERVER_VERSION=8.0.0 ./build.sh ``` #### To build just the module ```text mdkir build cd build -cmake .. -DVALKEY_VERSION=unstable +cmake .. +make +``` + +The default valkey version is "unstable". To override it, do: +```text +mdkir build +cd build +cmake .. -DVALKEY_VERSION=8.0.0 make ``` diff --git a/build.sh b/build.sh index 674e879..ead9c5a 100755 --- a/build.sh +++ b/build.sh @@ -8,22 +8,17 @@ set -e SCRIPT_DIR=$(pwd) echo "Script Directory: $SCRIPT_DIR" -# Ensure SERVER_VERSION environment variable is set +# If environment variable SERVER_VERSION is not set, default to "unstable" if [ -z "$SERVER_VERSION" ]; then - echo "WARNING: SERVER_VERSION environment variable is not set. Defaulting to unstable." + echo "SERVER_VERSION environment variable is not set. Defaulting to \"unstable\"." export SERVER_VERSION="unstable" fi -if [ "$SERVER_VERSION" != "unstable" ] && [ "$SERVER_VERSION" != "8.0.0" ] ; then - echo "ERROR: Unsupported version - $SERVER_VERSION" - exit 1 -fi - # Variables BUILD_DIR="$SCRIPT_DIR/build" # Build the Valkey JSON module using CMake -echo "Building ValkeyJSON module..." +echo "Building valkeyJSON..." if [ ! -d "$BUILD_DIR" ]; then mkdir $BUILD_DIR fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a812131..4b4a1ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -message("src/CMakeLists.txt: Build JSON") +message("src/CMakeLists.txt: Build valkeyJSON") set(OBJECT_TARGET json-objects CACHE INTERNAL "Object target for json module") add_library(${OBJECT_TARGET} OBJECT "") diff --git a/tst/integration/run.sh b/tst/integration/run.sh index 358bdbd..9513964 100755 --- a/tst/integration/run.sh +++ b/tst/integration/run.sh @@ -10,7 +10,7 @@ pkill -9 -f "valkey-benchmark" || true # If environment variable SERVER_VERSION is not set, default to "unstable" if [ -z "$SERVER_VERSION" ]; then - echo "WARNING: SERVER_VERSION environment variable is not set. Defaulting to \"unstable\"." + echo "SERVER_VERSION environment variable is not set. Defaulting to \"unstable\"." export SERVER_VERSION="unstable" fi