Fix #7 - Make SERVER_VERSION open to all versions (#22)

Signed-off-by: Joe Hu <jowhuw@amazon.com>
Co-authored-by: Joe Hu <jowhuw@amazon.com>
This commit is contained in:
Joe Hu 2024-12-09 18:14:48 -05:00 committed by GitHub
parent 1e33774dd2
commit 00c740742a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 29 additions and 21 deletions

View File

@ -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

View File

@ -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
```

View File

@ -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

View File

@ -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 "")

View File

@ -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