diff --git a/services/tunnelbroker/CMakeLists.txt b/services/tunnelbroker/CMakeLists.txt --- a/services/tunnelbroker/CMakeLists.txt +++ b/services/tunnelbroker/CMakeLists.txt @@ -1,4 +1,4 @@ -PROJECT(tunnelbroker C CXX) +PROJECT(tunnelbroker-service C CXX) cmake_minimum_required(VERSION 3.16) @@ -25,6 +25,16 @@ # Find Libuv installation pkg_check_modules(LIBUV REQUIRED libuv>=1.43) +# Shared Comm libraries under native/cpp +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../native/cpp/ + ${CMAKE_CURRENT_BINARY_DIR}/cpp + EXCLUDE_FROM_ALL +) + +# Ideally, we should be able to re-use this project, but transitive +# linking with aws-sdk seems to be problematic +# add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../lib/src ${CMAKE_CURRENT_BINARY_DIR}/services-common) + set(BUILD_TESTING OFF CACHE BOOL "Turn off tests" FORCE) set(WITH_GFLAGS OFF CACHE BOOL "Turn off gflags" FORCE) @@ -34,40 +44,23 @@ find_package(glog) -# Generated sources -get_filename_component(proto "protos/tunnelbroker.proto" ABSOLUTE) -get_filename_component(proto_path "${proto}" PATH) - -set(GENERATED_BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/gen") -set(GENERATED_CODE_DIR "${GENERATED_BASE_DIR}/_generated") -file(MAKE_DIRECTORY ${GENERATED_CODE_DIR}) - -set(proto_srcs "${GENERATED_CODE_DIR}/tunnelbroker.pb.cc") -set(proto_hdrs "${GENERATED_CODE_DIR}/tunnelbroker.pb.h") -set(grpc_srcs "${GENERATED_CODE_DIR}/tunnelbroker.grpc.pb.cc") -set(grpc_hdrs "${GENERATED_CODE_DIR}/tunnelbroker.grpc.pb.h") -add_custom_command( - OUTPUT "${proto_srcs}" "${proto_hdrs}" "${grpc_srcs}" "${grpc_hdrs}" - COMMAND ${_PROTOBUF_PROTOC} - ARGS --grpc_out "${GENERATED_CODE_DIR}" - --cpp_out "${GENERATED_CODE_DIR}" - -I "${proto_path}" - --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" - "${proto}" - DEPENDS "${proto}" -) +file(GLOB_RECURSE SOURCE_CODE "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") +file(GLOB COMMON_CODE "${CMAKE_CURRENT_SOURCE_DIR}/../lib/src/*.cpp") + +set(INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/src/Database + ${CMAKE_CURRENT_SOURCE_DIR}/src/DeliveryBroker + ${CMAKE_CURRENT_SOURCE_DIR}/src/Service + ${CMAKE_CURRENT_SOURCE_DIR}/src/Tools + ${CMAKE_CURRENT_SOURCE_DIR}/src/Amqp + + + # Ideally, we would add comm-services-common as a + # target link library, however, aws-sdk seems to not be able + # to be linked transitively + ${CMAKE_CURRENT_SOURCE_DIR}/../lib/src -file(GLOB_RECURSE SOURCE_CODE "./src/*.cpp") -set(GENERATED_CODE ${proto_srcs} ${proto_hdrs} ${grpc_srcs} ${grpc_hdrs}) - -include_directories( - ./src - ./src/Database - ./src/DeliveryBroker - ./src/Service - ./src/Tools - ./src/Amqp - ${GENERATED_BASE_DIR} ${Boost_INCLUDE_DIR} ${CRYPTOPP_INCLUDE_DIRS} ${LIBUV_INCLUDE_DIRS} @@ -79,6 +72,7 @@ ${DOUBLE_CONVERSION_SOURCES} ${GENERATED_CODE} ${SOURCE_CODE} + ${COMMON_CODE} ) set( @@ -95,11 +89,14 @@ glog::glog double-conversion::double-conversion Folly::folly + + tunnelbroker + #comm-services-common ) #SERVER add_executable( - tunnelbroker + tunnelbroker-service ${FOLLY_SOURCES} ${GENERATED_CODE} @@ -107,13 +104,19 @@ ) target_link_libraries( - tunnelbroker + tunnelbroker-service ${LIBS} ) +target_include_directories( + tunnelbroker-service + PUBLIC + ${INCLUDE_DIRS} +) + install( - TARGETS tunnelbroker + TARGETS tunnelbroker-service RUNTIME DESTINATION bin/ ) @@ -141,6 +144,12 @@ gtest_main ) + target_include_directories( + runTests + PUBLIC + ${INCLUDE_DIRS} + ) + add_test( NAME runTests COMMAND runTests diff --git a/services/tunnelbroker/src/Database/DatabaseEntitiesTools.h b/services/tunnelbroker/src/Database/DatabaseEntitiesTools.h deleted file mode 100644 --- a/services/tunnelbroker/src/Database/DatabaseEntitiesTools.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "DeviceSessionItem.h" -#include "Item.h" -#include "MessageItem.h" -#include "PublicKeyItem.h" -#include "SessionSignItem.h" - -#include - -namespace comm { -namespace network { -namespace database { - -template std::shared_ptr createItemByType() { - static_assert(std::is_base_of::value, "T must inherit from Item"); - return std::make_shared(); -} - -} // namespace database -} // namespace network -} // namespace comm diff --git a/services/tunnelbroker/src/Database/DatabaseManager.h b/services/tunnelbroker/src/Database/DatabaseManager.h --- a/services/tunnelbroker/src/Database/DatabaseManager.h +++ b/services/tunnelbroker/src/Database/DatabaseManager.h @@ -4,6 +4,10 @@ #include "Constants.h" #include "DatabaseEntitiesTools.h" #include "DatabaseManagerBase.h" +#include "DeviceSessionItem.h" +#include "MessageItem.h" +#include "PublicKeyItem.h" +#include "SessionSignItem.h" #include "Tools.h" #include diff --git a/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.h b/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.h --- a/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.h +++ b/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.h @@ -1,7 +1,7 @@ #pragma once -#include <_generated/tunnelbroker.grpc.pb.h> -#include <_generated/tunnelbroker.pb.h> +#include +#include #include