Skip to content
This repository was archived by the owner on Apr 6, 2019. It is now read-only.
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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ before_install:

install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
- ./install_deps.sh
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install redis; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then (redis-server&); fi

Expand Down
40 changes: 26 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
###
cmake_minimum_required(VERSION 2.8.7)
set(CMAKE_MACOSX_RPATH 1)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)


###
Expand All @@ -51,7 +52,7 @@ IF (WIN32)

IF ("${MSVC_RUNTIME_LIBRARY_CONFIG}" STREQUAL "")
set(MSVC_RUNTIME_LIBRARY_CONFIG "/MT")
ENDIF()
ENDIF()

foreach (flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE)
IF ("${MSVC_RUNTIME_LIBRARY_CONFIG}" STREQUAL "/MT")
Expand All @@ -75,20 +76,17 @@ ENDIF (WIN32)
###
# variables
###
# gtest
set(GTEST_INCLUDES ${PROJECT_SOURCE_DIR}/deps/src/googletest/googletest/include)
# cpp_redis
set(CPP_REDIS_INCLUDES ${PROJECT_SOURCE_DIR}/includes)
# tacopie
set(TACOPIE_FOLDER ${PROJECT_SOURCE_DIR}/tacopie)
set(TACOPIE_INCLUDES ${TACOPIE_FOLDER}/includes)

set(DEPS_INCLUDES ${PROJECT_SOURCE_DIR}/deps/include)
set(DEPS_LIBRARIES ${PROJECT_SOURCE_DIR}/deps/lib)
IF ("${USE_TACOPIE}" STREQUAL "")
set(USE_TACOPIE "true")
ENDIF ()

###
# includes
###
include_directories(${CPP_REDIS_INCLUDES}
${TACOPIE_INCLUDES})
include_directories(${CPP_REDIS_INCLUDES} ${DEPS_INCLUDES})


###
Expand All @@ -104,6 +102,10 @@ foreach(dir ${SRC_DIRS})
# set sources
set(SOURCES ${SOURCES} ${s_${dir}} ${h_${dir}} ${i_${dir}})
endforeach()
# filter tcp_client if no tacopie
IF (NOT USE_TACOPIE)
list(REMOVE_ITEM SRC_DIRS "source/network/tcp_client.cpp" "include/cpp_redis/network/tcp_client.hpp")
ENDIF (NOT USE_TACOPIE)


###
Expand Down Expand Up @@ -140,6 +142,11 @@ IF (LOGGING_ENABLED)
set_target_properties(${PROJECT} PROPERTIES COMPILE_DEFINITIONS "__CPP_REDIS_LOGGING_ENABLED=${LOGGING_ENABLED}")
ENDIF (LOGGING_ENABLED)

# __CPP_REDIS_USE_TACOPIE
IF (USE_TACOPIE)
set_target_properties(${PROJECT} PROPERTIES COMPILE_DEFINITIONS "__CPP_REDIS_USE_TACOPIE=${USE_TACOPIE}")
ENDIF (USE_TACOPIE)


###
# install
Expand All @@ -156,7 +163,12 @@ install (DIRECTORY ${CPP_REDIS_INCLUDES}/ DESTINATION include USE_SOURCE_PERMISS
###
# tacopie
###
add_subdirectory(tacopie)
IF (USE_TACOPIE)
ExternalProject_Add("tacopie"
GIT_SUBMODULES ""
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/deps"
SOURCE_DIR "${PROJECT_SOURCE_DIR}/tacopie")
ENDIF (USE_TACOPIE)


###
Expand All @@ -171,7 +183,7 @@ ENDIF(BUILD_EXAMPLES)
###
IF (BUILD_TESTS)
add_subdirectory(tests)
IF (EXISTS ${PROJECT_SOURCE_DIR}/deps/src/googletest)
add_subdirectory(${PROJECT_SOURCE_DIR}/deps/src/googletest)
ENDIF ()
ExternalProject_Add("googletest"
GIT_REPOSITORY "https://github.com/google/googletest.git"
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/deps")
ENDIF(BUILD_TESTS)
9 changes: 7 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ ENDIF (NOT WIN32)
###
# includes
###
include_directories(${PROJECT_SOURCE_DIR}/includes
${CPP_REDIS_INCLUDES})
include_directories(${CPP_REDIS_INCLUDES})


###
# libraries
###
link_directories(${DEPS_LIBRARIES})


###
Expand Down
4 changes: 2 additions & 2 deletions includes/cpp_redis/network/tcp_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class tcp_client : public tcp_client_iface {
auto callback = std::move(request.async_read_callback);

m_client.async_read({request.size, [=](tacopie::tcp_client::read_result& result) {
if (not callback) {
if (!callback) {
return;
}

Expand All @@ -76,7 +76,7 @@ class tcp_client : public tcp_client_iface {
auto callback = std::move(request.async_write_callback);

m_client.async_write({std::move(request.buffer), [=](tacopie::tcp_client::write_result& result) {
if (not callback) {
if (!callback) {
return;
}

Expand Down
12 changes: 0 additions & 12 deletions install_deps.sh

This file was deleted.

9 changes: 7 additions & 2 deletions sources/network/redis_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,22 @@

#include <cpp_redis/logger.hpp>
#include <cpp_redis/network/redis_connection.hpp>
#include <cpp_redis/network/tcp_client.hpp>
#include <cpp_redis/redis_error.hpp>

#include <tacopie/tacopie>
#ifdef __CPP_REDIS_USE_TACOPIE
#include <cpp_redis/network/tcp_client.hpp>
#endif /* __CPP_REDIS_USE_TACOPIE */

namespace cpp_redis {

namespace network {

std::function<std::shared_ptr<tcp_client_iface>()> get_tcp_client = []() -> std::shared_ptr<tcp_client_iface> {
#ifdef __CPP_REDIS_USE_TACOPIE
return std::make_shared<tcp_client>();
#else
return nullptr;
#endif /* __CPP_REDIS_USE_TACOPIE */
};

redis_connection::redis_connection(void)
Expand Down
2 changes: 1 addition & 1 deletion tacopie
11 changes: 8 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ ENDIF (NOT WIN32)
###
# includes
###
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/includes
${CPP_REDIS_INCLUDES}
${GTEST_INCLUDES})
include_directories(${DEPS_INCLUDES} ${CPP_REDIS_INCLUDES})


###
# libraries
###
link_directories(${DEPS_LIBRARIES})


###
# sources
Expand Down