Skip to content

Commit

Permalink
Fix #7 - Make SERVER_VERSION open to all versions
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Hu <[email protected]>
  • Loading branch information
Joe Hu committed Dec 7, 2024
1 parent 1e33774 commit f952cb8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
11 changes: 3 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 "")
Expand Down
2 changes: 1 addition & 1 deletion tst/integration/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f952cb8

Please sign in to comment.