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

turbo network framework #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
38 changes: 36 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,41 @@
####################################################################################
cmake_minimum_required(VERSION 3.15)

project(turbo CXX)
# 设置 C++ 编译器目录
set(CMAKE_CXX_COMPILER "/opt/compiler/gcc-12/bin/g++")
# 设置 C 编译器目录
set(CMAKE_C_COMPILER "/opt/compiler/gcc-12/bin/gcc")

project(turbo)

include(CheckStructHasMember)
include(CheckSymbolExists)

list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
check_struct_has_member("struct mmsghdr" msg_hdr sys/socket.h HAVE_MMSG_HDR)
check_symbol_exists(sendmmsg sys/socket.h HAVE_SENDMMSG_API)
check_symbol_exists(recvmmsg sys/socket.h HAVE_RECVMMSG_API)

if (HAVE_MMSG_HDR)
add_definitions(-DHAVE_MMSG_HDR)
endif ()
if (HAVE_SENDMMSG_API)
add_definitions(-DHAVE_SENDMMSG_API)
endif ()
if (HAVE_RECVMMSG_API)
add_definitions(-DHAVE_RECVMMSG_API)
endif ()

# check the socket buffer size set by the upper cmake project, if it is set, use the setting of the upper cmake project, otherwise set it to 256K
# if the socket buffer size is set to 0, it means that the socket buffer size is not set, and the kernel default value is used(just for linux)
if(DEFINED SOCKET_DEFAULT_BUF_SIZE)
if (SOCKET_DEFAULT_BUF_SIZE EQUAL 0)
message(STATUS "Socket default buffer size is not set, use the kernel default value")
else()
message(STATUS "Socket default buffer size is set to ${SOCKET_DEFAULT_BUF_SIZE}")
endif ()
add_definitions(-DSOCKET_DEFAULT_BUF_SIZE=${SOCKET_DEFAULT_BUF_SIZE})
endif()

set(PROJECT_DESCRIPTION "Hercules is an ahead of time compiler for a subset of the Python language framework.")
set(PROJECT_VERSION_MAJOR 0)
Expand All @@ -29,7 +63,7 @@ set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT
set(CARBIN_VERSION 0.2.0)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/carbin_cmake)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
#################################################################
#################################################################=
#
# modify the CARBIN_DEPS_PREFIX to you prefix if needed.
# for example when you install you deps to "/opt/handsome/guy
Expand Down
35 changes: 29 additions & 6 deletions cmake/user_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,38 @@ find_package(Threads REQUIRED)
# so you can and system pthread and rt, dl already add to
# CARBIN_SYSTEM_DYLINK, using it for fun.
##########################################################
if (WIN32)
list(APPEND SUB_DIR_LIST "win32")
#防止Windows.h包含Winsock.h
#Prevent Windows.h from including Winsock.h
add_definitions(-DWIN32_LEAN_AND_MEAN)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif ()

set(ENABLE_OPENSSL ON CACHE BOOL "enable openssl")
set(ASAN_USE_DELETE OFF CACHE BOOL "use delele[] or free when asan enabled")

#查找openssl是否安装
#Find out if openssl is installed
find_package(OpenSSL QUIET)
if (OPENSSL_FOUND AND ENABLE_OPENSSL)
message(STATUS "找到openssl库:\"${OPENSSL_INCLUDE_DIR}\",ENABLE_OPENSSL宏已打开")
include_directories(${OPENSSL_INCLUDE_DIR})
add_definitions(-DENABLE_OPENSSL)
endif ()

#是否使用delete[]替代free,用于解决开启asan后在MacOS上的卡死问题
#use delele[] or free when asan enabled
if(ASAN_USE_DELETE)
add_definitions(-DASAN_USE_DELETE)
endif()

set(CARBIN_DEPS_LINK
#${TURBO_LIB}
${CARBIN_SYSTEM_DYLINK}
${OPENSSL_LIBRARIES}
dl
pthread
)
list(REMOVE_DUPLICATES CARBIN_DEPS_LINK)
carbin_print_list_label("Denpendcies:" CARBIN_DEPS_LINK)





carbin_print_list_label("Denpendcies:" CARBIN_DEPS_LINK)
3 changes: 2 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ add_subdirectory(log)
add_subdirectory(taskflow)
add_subdirectory(system)
add_subdirectory(status)
add_subdirectory(var)
add_subdirectory(var)
add_subdirectory(network)
179 changes: 179 additions & 0 deletions tests/network/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
#
# Copyright 2023 The titan-search Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
carbin_cc_test(
NAME
lib_test
SOURCES
"test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
thread_pool_test
SOURCES
"thread_pool_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
udp_server_test
SOURCES
"udp_server_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
event_poller_test
SOURCES
"event_poller_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
tcp_client_test
SOURCES
"tcp_client_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
tcp_server_test
SOURCES
"tcp_server_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
timer_test
SOURCES
"timer_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
thread_pool_benchmark_test
SOURCES
"thread_pool_benchmark.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
network_resource_pool_test
SOURCES
"resource_pool_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
pipe_test
SOURCES
"pipe_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
dolaytask_test
SOURCES
"dolaytask_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
notice_center_test
SOURCES
"notice_center_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
ini_test
SOURCES
"ini_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
logger_test
SOURCES
"logger_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)

carbin_cc_test(
NAME
create_test
SOURCES
"create_test.cc"
COPTS
${CARBIN_CXX_OPTIONS}
DEPS
turbo::turbo
)
Loading