diff --git a/CMakeLists.txt b/CMakeLists.txt index f3ac839c..d93df970 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,6 +216,7 @@ if (USE_WS OR USE_TEST) add_subdirectory(ixcore) add_subdirectory(ixcrypto) add_subdirectory(ixcobra) + add_subdirectory(ixsnake) if (USE_WS) add_subdirectory(ws) diff --git a/ixsnake/CMakeLists.txt b/ixsnake/CMakeLists.txt new file mode 100644 index 00000000..c5adb15e --- /dev/null +++ b/ixsnake/CMakeLists.txt @@ -0,0 +1,33 @@ +# +# Author: Benjamin Sergeant +# Copyright (c) 2019 Machine Zone, Inc. All rights reserved. +# + +set (IXSNAKE_SOURCES + ixsnake/IXSnakeServer.cpp + ixsnake/IXSnakeProtocol.cpp + ixsnake/IXAppConfig.cpp + ixsnake/IXRedisClient.cpp +) + +set (IXSNAKE_HEADERS + ixsnake/IXSnakeServer.h + ixsnake/IXSnakeProtocol.h + ixsnake/IXAppConfig.h + ixsnake/IXRedisClient.h +) + +add_library(ixsnake STATIC + ${IXSNAKE_SOURCES} + ${IXSNAKE_HEADERS} +) + +set(IXSNAKE_INCLUDE_DIRS + . + .. + ../ixcore + ../ixcrypto + ../ixwebsocket + ../third_party) + +target_include_directories( ixsnake PUBLIC ${IXSNAKE_INCLUDE_DIRS} ) diff --git a/ws/snake/IXAppConfig.cpp b/ixsnake/ixsnake/IXAppConfig.cpp similarity index 100% rename from ws/snake/IXAppConfig.cpp rename to ixsnake/ixsnake/IXAppConfig.cpp diff --git a/ws/snake/IXAppConfig.h b/ixsnake/ixsnake/IXAppConfig.h similarity index 100% rename from ws/snake/IXAppConfig.h rename to ixsnake/ixsnake/IXAppConfig.h diff --git a/ws/IXRedisClient.cpp b/ixsnake/ixsnake/IXRedisClient.cpp similarity index 100% rename from ws/IXRedisClient.cpp rename to ixsnake/ixsnake/IXRedisClient.cpp diff --git a/ws/IXRedisClient.h b/ixsnake/ixsnake/IXRedisClient.h similarity index 100% rename from ws/IXRedisClient.h rename to ixsnake/ixsnake/IXRedisClient.h diff --git a/ws/snake/IXSnakeConnectionState.h b/ixsnake/ixsnake/IXSnakeConnectionState.h similarity index 100% rename from ws/snake/IXSnakeConnectionState.h rename to ixsnake/ixsnake/IXSnakeConnectionState.h diff --git a/ws/snake/IXSnakeProtocol.cpp b/ixsnake/ixsnake/IXSnakeProtocol.cpp similarity index 100% rename from ws/snake/IXSnakeProtocol.cpp rename to ixsnake/ixsnake/IXSnakeProtocol.cpp diff --git a/ws/snake/IXSnakeProtocol.h b/ixsnake/ixsnake/IXSnakeProtocol.h similarity index 100% rename from ws/snake/IXSnakeProtocol.h rename to ixsnake/ixsnake/IXSnakeProtocol.h diff --git a/ws/snake/IXSnakeServer.cpp b/ixsnake/ixsnake/IXSnakeServer.cpp similarity index 100% rename from ws/snake/IXSnakeServer.cpp rename to ixsnake/ixsnake/IXSnakeServer.cpp diff --git a/ws/snake/IXSnakeServer.h b/ixsnake/ixsnake/IXSnakeServer.h similarity index 100% rename from ws/snake/IXSnakeServer.h rename to ixsnake/ixsnake/IXSnakeServer.h diff --git a/ws/snake/appsConfig.json b/ixsnake/ixsnake/appsConfig.json similarity index 100% rename from ws/snake/appsConfig.json rename to ixsnake/ixsnake/appsConfig.json diff --git a/makefile b/makefile index f91b7114..fbdeb3f9 100644 --- a/makefile +++ b/makefile @@ -9,10 +9,10 @@ install: brew # on osx it is good practice to make /usr/local user writable # sudo chown -R `whoami`/staff /usr/local brew: - mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j install) + mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j 4 install) ws: - mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j) + mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j 4) uninstall: xargs rm -fv < build/install_manifest.txt @@ -58,7 +58,7 @@ test_server: # env TEST=Websocket_chat make test # env TEST=heartbeat make test test: - mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j) + mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j 4) (cd test ; python2.7 run.py -r) ws_test: ws diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fe223776..55903b44 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -15,15 +15,12 @@ if (MAC) option(USE_TLS "Add TLS support" ON) endif() -set (WS ../ws) - include_directories( ${PROJECT_SOURCE_DIR}/Catch2/single_include ../third_party ../third_party/msgpack11 ../third_party/spdlog/include ../ws - ../ws/snake ) # Shared sources @@ -34,12 +31,6 @@ set (SOURCES ../third_party/msgpack11/msgpack11.cpp ../third_party/jsoncpp/jsoncpp.cpp - ${WS}/snake/IXSnakeServer.cpp - ${WS}/snake/IXSnakeProtocol.cpp - ${WS}/snake/IXAppConfig.cpp - - ${WS}/IXRedisClient.cpp - IXSocketTest.cpp IXSocketConnectTest.cpp IXWebSocketServerTest.cpp @@ -83,12 +74,13 @@ if (MAC) endif() if (APPLE AND USE_TLS) - target_link_libraries(ixwebsocket_unittest "-framework foundation" "-framework security") + target_link_libraries(ixwebsocket_unittest "-framework foundation" "-framework security") endif() target_link_libraries(ixwebsocket_unittest ixcore) target_link_libraries(ixwebsocket_unittest ixcrypto) target_link_libraries(ixwebsocket_unittest ixcobra) target_link_libraries(ixwebsocket_unittest ixwebsocket) +target_link_libraries(ixwebsocket_unittest ixsnake) install(TARGETS ixwebsocket_unittest DESTINATION bin) diff --git a/test/IXCobraChatTest.cpp b/test/IXCobraChatTest.cpp index 5a60904b..e540de62 100644 --- a/test/IXCobraChatTest.cpp +++ b/test/IXCobraChatTest.cpp @@ -4,7 +4,7 @@ * Copyright (c) 2017 Machine Zone. All rights reserved. */ -#include "IXSnakeServer.h" +#include #include "IXTest.h" #include "catch.hpp" #include diff --git a/test/IXCobraMetricsPublisherTest.cpp b/test/IXCobraMetricsPublisherTest.cpp index 799ee9be..73e6e240 100644 --- a/test/IXCobraMetricsPublisherTest.cpp +++ b/test/IXCobraMetricsPublisherTest.cpp @@ -3,12 +3,12 @@ * Copyright (c) 2018 Machine Zone. All rights reserved. */ -#include "IXSnakeServer.h" #include "IXTest.h" #include "catch.hpp" #include #include #include +#include #include using namespace ix; diff --git a/test/IXTest.h b/test/IXTest.h index a111074b..baf76b2a 100644 --- a/test/IXTest.h +++ b/test/IXTest.h @@ -6,7 +6,7 @@ #pragma once -#include "IXAppConfig.h" +#include #include "IXGetFreePort.h" #include #include diff --git a/ws/CMakeLists.txt b/ws/CMakeLists.txt index d3c69d92..b44a2fd0 100644 --- a/ws/CMakeLists.txt +++ b/ws/CMakeLists.txt @@ -24,7 +24,6 @@ include_directories(ws ../third_party) include_directories(ws ../third_party/statsd-client-cpp/src) include_directories(ws ../third_party/spdlog/include) include_directories(ws ../third_party/cpp-linenoise) -include_directories(ws snake) if (UNIX) set( STATSD_CLIENT_SOURCES ../third_party/statsd-client-cpp/src/statsd_client.cpp) @@ -35,11 +34,6 @@ add_executable(ws ../third_party/jsoncpp/jsoncpp.cpp ${STATSD_CLIENT_SOURCES} - snake/IXSnakeServer.cpp - snake/IXSnakeProtocol.cpp - snake/IXAppConfig.cpp - - IXRedisClient.cpp IXSentryClient.cpp ws_http_client.cpp @@ -53,12 +47,12 @@ add_executable(ws ws_receive.cpp ws_redis_publish.cpp ws_redis_subscribe.cpp + ws_snake.cpp ws_cobra_subscribe.cpp ws_cobra_metrics_publish.cpp ws_cobra_publish.cpp ws_cobra_to_statsd.cpp ws_cobra_to_sentry.cpp - ws_snake.cpp ws_httpd.cpp ws_autobahn.cpp ws.cpp) @@ -67,6 +61,7 @@ target_link_libraries(ws ixcore) target_link_libraries(ws ixcrypto) target_link_libraries(ws ixcobra) target_link_libraries(ws ixwebsocket) +target_link_libraries(ws ixsnake) if(NOT APPLE AND NOT USE_MBED_TLS) find_package(OpenSSL REQUIRED) diff --git a/ws/ws_redis_publish.cpp b/ws/ws_redis_publish.cpp index 6dcf751a..25619997 100644 --- a/ws/ws_redis_publish.cpp +++ b/ws/ws_redis_publish.cpp @@ -4,7 +4,7 @@ * Copyright (c) 2019 Machine Zone, Inc. All rights reserved. */ -#include "IXRedisClient.h" +#include #include #include diff --git a/ws/ws_redis_subscribe.cpp b/ws/ws_redis_subscribe.cpp index 15f3041e..34065f83 100644 --- a/ws/ws_redis_subscribe.cpp +++ b/ws/ws_redis_subscribe.cpp @@ -4,7 +4,7 @@ * Copyright (c) 2019 Machine Zone, Inc. All rights reserved. */ -#include "IXRedisClient.h" +#include #include #include #include diff --git a/ws/ws_snake.cpp b/ws/ws_snake.cpp index b030870d..823bdd3b 100644 --- a/ws/ws_snake.cpp +++ b/ws/ws_snake.cpp @@ -4,7 +4,7 @@ * Copyright (c) 2018 Machine Zone, Inc. All rights reserved. */ -#include "IXSnakeServer.h" +#include #include #include #include