restructure project
This commit is contained in:
parent
65c5c5f894
commit
2453f5b717
@ -12,8 +12,7 @@ set (CMAKE_CXX_STANDARD 14)
|
||||
set (CXX_STANDARD_REQUIRED ON)
|
||||
set (CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# -Wshorten-64-to-32 does not work with clang
|
||||
if (NOT WIN32)
|
||||
if (UNIX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
|
||||
endif()
|
||||
|
||||
@ -211,6 +210,15 @@ install(TARGETS ixwebsocket
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ixwebsocket/
|
||||
)
|
||||
|
||||
if (USE_WS)
|
||||
add_subdirectory(ws)
|
||||
if (USE_WS OR USE_TEST)
|
||||
add_subdirectory(ixcore)
|
||||
add_subdirectory(ixcrypto)
|
||||
add_subdirectory(ixcobra)
|
||||
|
||||
if (USE_WS)
|
||||
add_subdirectory(ws)
|
||||
endif()
|
||||
if (USE_TEST)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
endif()
|
||||
|
30
ixcobra/CMakeLists.txt
Normal file
30
ixcobra/CMakeLists.txt
Normal file
@ -0,0 +1,30 @@
|
||||
#
|
||||
# Author: Benjamin Sergeant
|
||||
# Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
|
||||
#
|
||||
|
||||
set (IXCOBRA_SOURCES
|
||||
ixcobra/IXCobraConnection.cpp
|
||||
ixcobra/IXCobraMetricsThreadedPublisher.cpp
|
||||
ixcobra/IXCobraMetricsPublisher.cpp
|
||||
)
|
||||
|
||||
set (IXCOBRA_HEADERS
|
||||
ixcobra/IXCobraConnection.h
|
||||
ixcobra/IXCobraMetricsThreadedPublisher.h
|
||||
ixcobra/IXCobraMetricsPublisher.h
|
||||
)
|
||||
|
||||
add_library(ixcobra STATIC
|
||||
${IXCOBRA_SOURCES}
|
||||
${IXCOBRA_HEADERS}
|
||||
)
|
||||
|
||||
set(IXCOBRA_INCLUDE_DIRS
|
||||
.
|
||||
../ixcore
|
||||
../ixcrypto
|
||||
../ixwebsocket
|
||||
../third_party)
|
||||
|
||||
target_include_directories( ixcobra PUBLIC ${IXCOBRA_INCLUDE_DIRS} )
|
19
ixcore/CMakeLists.txt
Normal file
19
ixcore/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Author: Benjamin Sergeant
|
||||
# Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
|
||||
#
|
||||
|
||||
set (IXCORE_SOURCES
|
||||
ixcore/utils/IXCoreLogger.cpp
|
||||
)
|
||||
|
||||
set (IXCORE_HEADERS
|
||||
ixcore/utils/IXCoreLogger.h
|
||||
)
|
||||
|
||||
add_library(ixcore STATIC
|
||||
${IXCORE_SOURCES}
|
||||
${IXCORE_HEADERS}
|
||||
)
|
||||
|
||||
target_include_directories( ixcore PUBLIC . )
|
29
ixcrypto/CMakeLists.txt
Normal file
29
ixcrypto/CMakeLists.txt
Normal file
@ -0,0 +1,29 @@
|
||||
#
|
||||
# Author: Benjamin Sergeant
|
||||
# Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
|
||||
#
|
||||
|
||||
set (IXCRYPTO_SOURCES
|
||||
ixcrypto/IXHMac.cpp
|
||||
ixcrypto/IXBase64.cpp
|
||||
ixcrypto/IXUUid.cpp
|
||||
ixcrypto/IXHash.cpp
|
||||
)
|
||||
|
||||
set (IXCRYPTO_HEADERS
|
||||
ixcrypto/IXHMac.h
|
||||
ixcrypto/IXBase64.h
|
||||
ixcrypto/IXUUid.h
|
||||
ixcrypto/IXHash.h
|
||||
)
|
||||
|
||||
add_library(ixcrypto STATIC
|
||||
${IXCRYPTO_SOURCES}
|
||||
${IXCRYPTO_HEADERS}
|
||||
)
|
||||
|
||||
set(IXCRYPTO_INCLUDE_DIRS
|
||||
.
|
||||
../ixcore)
|
||||
|
||||
target_include_directories( ixcrypto PUBLIC ${IXCRYPTO_INCLUDE_DIRS} )
|
7
makefile
7
makefile
@ -9,7 +9,7 @@ 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 .. ; make -j install)
|
||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j install)
|
||||
|
||||
ws:
|
||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j)
|
||||
@ -57,8 +57,9 @@ test_server:
|
||||
# env TEST=Websocket_server make test
|
||||
# env TEST=Websocket_chat make test
|
||||
# env TEST=heartbeat make test
|
||||
test:
|
||||
python2.7 test/run.py
|
||||
test: brew
|
||||
# (cd test ; ../build/test/ixwebsocket_unittest)
|
||||
(cd test ; python2.7 run.py -r)
|
||||
|
||||
ws_test: ws
|
||||
(cd ws ; env DEBUG=1 PATH=../ws/build:$$PATH bash test_ws.sh)
|
||||
|
@ -15,8 +15,6 @@ if (MAC)
|
||||
option(USE_TLS "Add TLS support" ON)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/.. ixwebsocket)
|
||||
|
||||
set (WS ../ws)
|
||||
|
||||
include_directories(
|
||||
@ -36,17 +34,6 @@ set (SOURCES
|
||||
../third_party/msgpack11/msgpack11.cpp
|
||||
../third_party/jsoncpp/jsoncpp.cpp
|
||||
|
||||
${WS}/ixcore/utils/IXCoreLogger.cpp
|
||||
|
||||
${WS}/ixcrypto/IXBase64.cpp
|
||||
${WS}/ixcrypto/IXHash.cpp
|
||||
${WS}/ixcrypto/IXUuid.cpp
|
||||
${WS}/ixcrypto/IXHMac.cpp
|
||||
|
||||
${WS}/ixcobra/IXCobraConnection.cpp
|
||||
${WS}/ixcobra/IXCobraMetricsPublisher.cpp
|
||||
${WS}/ixcobra/IXCobraMetricsThreadedPublisher.cpp
|
||||
|
||||
${WS}/snake/IXSnakeServer.cpp
|
||||
${WS}/snake/IXSnakeProtocol.cpp
|
||||
${WS}/snake/IXAppConfig.cpp
|
||||
@ -99,5 +86,9 @@ if (APPLE AND USE_TLS)
|
||||
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)
|
||||
|
||||
install(TARGETS ixwebsocket_unittest DESTINATION bin)
|
||||
|
@ -309,6 +309,7 @@ TEST_CASE("Cobra_chat", "[cobra_chat]")
|
||||
timeout -= 10;
|
||||
if (timeout <= 0)
|
||||
{
|
||||
snakeServer.stop();
|
||||
REQUIRE(false); // timeout
|
||||
}
|
||||
}
|
||||
@ -332,6 +333,7 @@ TEST_CASE("Cobra_chat", "[cobra_chat]")
|
||||
timeout -= 10;
|
||||
if (timeout <= 0)
|
||||
{
|
||||
snakeServer.stop();
|
||||
REQUIRE(false); // timeout
|
||||
}
|
||||
}
|
||||
|
29
test/run.py
29
test/run.py
@ -350,21 +350,22 @@ def generateXmlOutput(results, xmlOutput, testRunName, runTime):
|
||||
|
||||
|
||||
def run(testName, buildDir, sanitizer, xmlOutput,
|
||||
testRunName, buildOnly, useLLDB, cpuCount):
|
||||
testRunName, buildOnly, useLLDB, cpuCount, runOnly):
|
||||
'''Main driver. Run cmake, compiles, execute and validate the testsuite.'''
|
||||
|
||||
# gen build files with CMake
|
||||
runCMake(sanitizer, buildDir)
|
||||
if not runOnly:
|
||||
runCMake(sanitizer, buildDir)
|
||||
|
||||
if platform.system() == 'Linux':
|
||||
# build with make -j
|
||||
runCommand('make -C {} -j 2'.format(buildDir))
|
||||
elif platform.system() == 'Darwin':
|
||||
# build with make
|
||||
runCommand('make -C {} -j 8'.format(buildDir))
|
||||
else:
|
||||
# build with cmake on recent
|
||||
runCommand('cmake --build --parallel {}'.format(buildDir))
|
||||
if platform.system() == 'Linux':
|
||||
# build with make -j
|
||||
runCommand('make -C {} -j 2'.format(buildDir))
|
||||
elif platform.system() == 'Darwin':
|
||||
# build with make
|
||||
runCommand('make -C {} -j 8'.format(buildDir))
|
||||
else:
|
||||
# build with cmake on recent
|
||||
runCommand('cmake --build --parallel {}'.format(buildDir))
|
||||
|
||||
if buildOnly:
|
||||
return
|
||||
@ -454,6 +455,8 @@ def main():
|
||||
help='Validate XML output.')
|
||||
parser.add_argument('--build_only', '-b', action='store_true',
|
||||
help='Stop after building. Do not run the unittest.')
|
||||
parser.add_argument('--run_only', '-r', action='store_true',
|
||||
help='Only run the test, do not build anything.')
|
||||
parser.add_argument('--output', '-o', help='Output XML file.')
|
||||
parser.add_argument('--lldb', action='store_true',
|
||||
help='Run the test through lldb.')
|
||||
@ -492,7 +495,7 @@ def main():
|
||||
if platform.system() == 'Windows':
|
||||
TEST_EXE_PATH = os.path.join(buildDir, BUILD_TYPE, 'ixwebsocket_unittest.exe')
|
||||
else:
|
||||
TEST_EXE_PATH = os.path.join(buildDir, 'ixwebsocket_unittest')
|
||||
TEST_EXE_PATH = '../build/test/ixwebsocket_unittest'
|
||||
|
||||
if args.list:
|
||||
# catch2 exit with a different error code when requesting the list of files
|
||||
@ -511,7 +514,7 @@ def main():
|
||||
args.lldb = False
|
||||
|
||||
return run(args.test, buildDir, sanitizer, xmlOutput,
|
||||
testRunName, args.build_only, args.lldb, args.cpu_count)
|
||||
testRunName, args.build_only, args.lldb, args.cpu_count, args.run_only)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -35,17 +35,6 @@ add_executable(ws
|
||||
../third_party/jsoncpp/jsoncpp.cpp
|
||||
${STATSD_CLIENT_SOURCES}
|
||||
|
||||
ixcore/utils/IXCoreLogger.cpp
|
||||
|
||||
ixcrypto/IXBase64.cpp
|
||||
ixcrypto/IXHash.cpp
|
||||
ixcrypto/IXUuid.cpp
|
||||
ixcrypto/IXHMac.cpp
|
||||
|
||||
ixcobra/IXCobraConnection.cpp
|
||||
ixcobra/IXCobraMetricsPublisher.cpp
|
||||
ixcobra/IXCobraMetricsThreadedPublisher.cpp
|
||||
|
||||
snake/IXSnakeServer.cpp
|
||||
snake/IXSnakeProtocol.cpp
|
||||
snake/IXAppConfig.cpp
|
||||
@ -73,6 +62,9 @@ add_executable(ws
|
||||
ws_autobahn.cpp
|
||||
ws.cpp)
|
||||
|
||||
target_link_libraries(ws ixcore)
|
||||
target_link_libraries(ws ixcrypto)
|
||||
target_link_libraries(ws ixcobra)
|
||||
target_link_libraries(ws ixwebsocket)
|
||||
|
||||
if(NOT APPLE AND NOT USE_MBED_TLS)
|
||||
|
Loading…
Reference in New Issue
Block a user