Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build complete library #24

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 32 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ jobs:

- name: Install dependencies
run: |
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install -y redis-server valgrind libevent-dev
sudo apt-get install -y valgrind libevent-dev cmake libssl-dev

# TODO: Test against Redis and KeyDB in addition to Valkey
- name: Install Valkey
run: |
git clone --depth 1 --branch 7.2.5 https://github.com/valkey-io/valkey.git
cd valkey && sudo BUILD_TLS=yes make install

- name: Build using cmake
env:
Expand All @@ -26,10 +30,11 @@ jobs:
run: USE_SSL=1 TEST_ASYNC=1 make

- name: Run tests
working-directory: tests
env:
SKIPS_AS_FAILS: 1
TEST_SSL: 1
run: $GITHUB_WORKSPACE/test.sh
run: ./test.sh

# - name: Run tests under valgrind
# env:
Expand All @@ -48,7 +53,12 @@ jobs:
run: |
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y --enablerepo=remi install redis
yum -y install gcc gcc-c++ make openssl openssl-devel cmake3 valgrind libevent-devel
yum -y install git gcc gcc-c++ make openssl openssl-devel cmake3 valgrind libevent-devel

- name: Install Valkey
run: |
git clone --depth 1 --branch 7.2.5 https://github.com/valkey-io/valkey.git
cd valkey && BUILD_TLS=yes make install

- name: Build using cmake
env:
Expand All @@ -61,17 +71,19 @@ jobs:
run: USE_SSL=1 TEST_ASYNC=1 make

- name: Run tests
working-directory: tests
env:
SKIPS_AS_FAILS: 1
TEST_SSL: 1
run: $GITHUB_WORKSPACE/test.sh
run: ./test.sh

- name: Run tests under valgrind
working-directory: tests
env:
SKIPS_AS_FAILS: 1
TEST_SSL: 1
TEST_PREFIX: valgrind --error-exitcode=99 --track-origins=yes --leak-check=full
run: $GITHUB_WORKSPACE/test.sh
run: ./test.sh

centos8:
name: RockyLinux 8
Expand All @@ -88,6 +100,11 @@ jobs:
dnf -y group install "Development Tools"
dnf -y install openssl-devel cmake valgrind libevent-devel

- name: Install Valkey
run: |
git clone --depth 1 --branch 7.2.5 https://github.com/valkey-io/valkey.git
cd valkey && BUILD_TLS=yes make install

- name: Build using cmake
env:
EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON -DENABLE_ASYNC_TESTS:BOOL=ON
Expand All @@ -99,17 +116,19 @@ jobs:
run: USE_SSL=1 TEST_ASYNC=1 make

- name: Run tests
working-directory: tests
env:
SKIPS_AS_FAILS: 1
TEST_SSL: 1
run: $GITHUB_WORKSPACE/test.sh
run: ./test.sh

- name: Run tests under valgrind
working-directory: tests
env:
SKIPS_AS_FAILS: 1
TEST_SSL: 1
TEST_PREFIX: valgrind --error-exitcode=99 --track-origins=yes --leak-check=full
run: $GITHUB_WORKSPACE/test.sh
run: ./test.sh

freebsd:
runs-on: ubuntu-latest
Expand All @@ -133,16 +152,16 @@ jobs:

- name: Install dependencies
run: |
brew install openssl [email protected]
brew link [email protected] --force
brew install openssl valkey

- name: Build hiredis
run: USE_SSL=1 make

- name: Run tests
working-directory: tests
env:
TEST_SSL: 1
run: $GITHUB_WORKSPACE/test.sh
run: ./test.sh

windows:
name: Windows
Expand All @@ -163,7 +182,7 @@ jobs:

- name: Run tests
run: |
./build/hiredis-test.exe
./build/test.exe

- name: Install Cygwin Action
uses: cygwin/cygwin-install-action@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ jobs:
- uses: actions/checkout@v3
- name: Run CMake (shared lib)
run: cmake -Wno-dev CMakeLists.txt
- name: Build hiredis (shared lib)
- name: Build shared library
run: MSBuild hiredis.vcxproj /p:Configuration=Debug
- name: Run CMake (static lib)
run: cmake -Wno-dev CMakeLists.txt -DBUILD_SHARED_LIBS=OFF
- name: Build hiredis (static lib)
- name: Build static library
run: MSBuild hiredis.vcxproj /p:Configuration=Debug
- name: Build hiredis-test
- name: Build test.exe
run: MSBuild hiredis-test.vcxproj /p:Configuration=Debug
# use memurai, redis compatible server, since it is easy to install. Can't
# install official redis containers on the windows runner
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
obj
lib
compile_commands.json
.cache
69 changes: 43 additions & 26 deletions libvalkey/CMakeLists.txt → CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)

MACRO(getVersionBit name)
SET(VERSION_REGEX "^#define ${name} (.+)$")
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/valkey.h"
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/valkey/valkey.h"
VERSION_BIT REGEX ${VERSION_REGEX})
STRING(REGEX REPLACE ${VERSION_REGEX} "\\1" ${name} "${VERSION_BIT}")
ENDMACRO(getVersionBit)
Expand Down Expand Up @@ -32,13 +32,20 @@ SET(CMAKE_C_STANDARD 99)
SET(CMAKE_DEBUG_POSTFIX d)

SET(valkey_sources
alloc.c
async.c
valkey.c
net.c
read.c
sds.c
sockcompat.c)
src/adlist.c
src/alloc.c
src/async.c
src/command.c
src/crc16.c
src/dict.c
src/net.c
src/read.c
src/sds.c
src/sockcompat.c
src/valkey.c
src/valkeycluster.c
src/vkarray.c
src/vkutil.c)

SET(valkey_sources ${valkey_sources})

Expand Down Expand Up @@ -66,7 +73,11 @@ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
TARGET_LINK_LIBRARIES(valkey PUBLIC socket)
ENDIF()

TARGET_INCLUDE_DIRECTORIES(valkey PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
TARGET_INCLUDE_DIRECTORIES(valkey
PUBLIC
$<INSTALL_INTERFACE:include/valkey>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/valkey>
)

CONFIGURE_FILE(valkey.pc.in valkey.pc @ONLY)

Expand Down Expand Up @@ -158,10 +169,16 @@ IF(ENABLE_SSL)
ENDIF()
FIND_PACKAGE(OpenSSL REQUIRED)
SET(valkey_ssl_sources
ssl.c)
src/ssl.c)
ADD_LIBRARY(valkey_ssl ${valkey_ssl_sources})
ADD_LIBRARY(valkey::valkey_ssl ALIAS valkey_ssl)

TARGET_INCLUDE_DIRECTORIES(valkey_ssl
PRIVATE
$<INSTALL_INTERFACE:include/valkey>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/valkey>
)

IF (APPLE AND BUILD_SHARED_LIBS)
SET_PROPERTY(TARGET valkey_ssl PROPERTY LINK_FLAGS "-Wl,-undefined -Wl,dynamic_lookup")
ENDIF()
Expand Down Expand Up @@ -192,7 +209,7 @@ IF(ENABLE_SSL)
CONFIGURATIONS Debug RelWithDebInfo)
endif()

INSTALL(FILES valkey_ssl.h
INSTALL(FILES valkey_ssl.h valkeycluster_ssl.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/valkey)

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/valkey_ssl.pc
Expand Down Expand Up @@ -220,21 +237,21 @@ IF(ENABLE_SSL)
DESTINATION ${CMAKE_CONF_INSTALL_DIR})
ENDIF()

IF(NOT DISABLE_TESTS)
ENABLE_TESTING()
ADD_EXECUTABLE(libvalkey-test test.c)
TARGET_LINK_LIBRARIES(libvalkey-test valkey)
IF(ENABLE_SSL_TESTS)
ADD_DEFINITIONS(-DVALKEY_TEST_SSL=1)
TARGET_LINK_LIBRARIES(libvalkey-test valkey_ssl)
ENDIF()
IF(ENABLE_ASYNC_TESTS)
ADD_DEFINITIONS(-DVALKEY_TEST_ASYNC=1)
TARGET_LINK_LIBRARIES(libvalkey-test event)
ENDIF()
ADD_TEST(NAME libvalkey-test
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh)
ENDIF()
#IF(NOT DISABLE_TESTS)
# ENABLE_TESTING()
# ADD_EXECUTABLE(libvalkey-test test.c)
# TARGET_LINK_LIBRARIES(libvalkey-test valkey)
# IF(ENABLE_SSL_TESTS)
# ADD_DEFINITIONS(-DVALKEY_TEST_SSL=1)
# TARGET_LINK_LIBRARIES(libvalkey-test valkey_ssl)
# ENDIF()
# IF(ENABLE_ASYNC_TESTS)
# ADD_DEFINITIONS(-DVALKEY_TEST_ASYNC=1)
# TARGET_LINK_LIBRARIES(libvalkey-test event)
# ENDIF()
# ADD_TEST(NAME libvalkey-test
# COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh)
#ENDIF()

# Add examples
IF(ENABLE_EXAMPLES)
Expand Down
Loading
Loading