Skip to content

Commit

Permalink
add http moudle
Browse files Browse the repository at this point in the history
  • Loading branch information
Dueplay committed Mar 12, 2024
1 parent 72ab2cb commit 067400f
Show file tree
Hide file tree
Showing 155 changed files with 29,639 additions and 11,038 deletions.
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
/.vscode/
build/
bin/
lib/
cmake-build-debug/
*.DS_Store
*.iml
*.xml
.idea/
*/.ipynb_checkpoints/
.vscode/
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
"string": "cpp",
"bitset": "cpp",
"regex": "cpp",
"variant": "cpp"
"variant": "cpp",
"compare": "cpp",
"concepts": "cpp",
"numbers": "cpp",
"semaphore": "cpp",
"stop_token": "cpp",
"strstream": "cpp"
}
}
86 changes: 72 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# setup
cmake_minimum_required(VERSION 3.11)
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -33,8 +34,45 @@ SET(THREADS_PREFER_PTHREAD_FLAG ON)
FIND_PACKAGE(Threads REQUIRED)

# Formatting utility search path
set(NEXT_SERVER_BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/build_support")
set(NEXT_SERVERTU_CLANG_SEARCH_PATH "/usr/local/bin" "/usr/bin" "/usr/local/opt/llvm/bin" "/usr/local/opt/llvm@8/bin" "/usr/local/Cellar/llvm/8.0.1/bin")

# clang-format
IF (NOT DEFINED CLANG_FORMAT_BIN)
# attempt to find the binary if user did not specify
FIND_PROGRAM(CLANG_FORMAT_BIN
NAMES clang-format clang-format-14
HINTS ${NEXT_SERVERTU_CLANG_SEARCH_PATH})
ENDIF ()
IF ("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND")
MESSAGE(WARNING "Server/main couldn't find clang-format.")
ELSE ()
MESSAGE(STATUS "Server/main found clang-format at ${CLANG_FORMAT_BIN}")
ENDIF ()

# cpplint
FIND_PROGRAM(CPPLINT_BIN
NAMES cpplint cpplint.py
HINTS ${NEXT_SERVER_BUILD_SUPPORT_DIR})
IF ("${CPPLINT_BIN}" STREQUAL "CPPLINT_BIN-NOTFOUND")
MESSAGE(WARNING "Server/main couldn't find cpplint.")
ELSE ()
MESSAGE(STATUS "Server/main found cpplint at ${CPPLINT_BIN}")
ENDIF ()

# clang-tidy
IF (NOT DEFINED CLANG_TIDY_BIN)
FIND_PROGRAM(CLANG_TIDY_BIN
NAMES clang-tidy clang-tidy-14
HINTS ${NEXT_SERVERTU_CLANG_SEARCH_PATH})
ENDIF ()
IF ("${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND")
MESSAGE(WARNING "Server/main couldn't find clang-tidy.")
ELSE ()
SET(CMAKE_EXPORT_COMPILE_COMMANDS 1)
MESSAGE(STATUS "Server/main found clang-tidy at ${CLANG_TIDY_BIN}")
ENDIF ()

# Includes header file path
SET(NEXT_SERVER_SRC_DIR ${PROJECT_SOURCE_DIR}/src)
SET(NEXT_SERVER_SRC_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/include)
Expand All @@ -48,29 +86,40 @@ SET(MYSQL_COMPILER_FLAG -I/usr/include/cppconn -L/usr/local/lib -lmysqlcppconn)

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
# Build the turtle core library
FILE(GLOB TURTLE_CORE_SOURCE RELATIVE ${CMAKE_SOURCE_DIR} "src/core/*.cpp")
ADD_LIBRARY(turtle_core ${TURTLE_CORE_SOURCE})
TARGET_LINK_LIBRARIES(turtle_core turtle_log Threads::Threads)
TARGET_COMPILE_OPTIONS(turtle_core PRIVATE ${CMAKE_COMPILER_FLAG})

# Build the core library
FILE(GLOB NEXT_CORE_SOURCE RELATIVE ${CMAKE_SOURCE_DIR} "src/core/*.cpp")
ADD_LIBRARY(next_core ${NEXT_CORE_SOURCE})
TARGET_LINK_LIBRARIES(next_core next_log Threads::Threads)
TARGET_COMPILE_OPTIONS(next_core PRIVATE ${CMAKE_COMPILER_FLAG})
TARGET_INCLUDE_DIRECTORIES(
next_core
PUBLIC ${NEXT_SERVER_SRC_INCLUDE_DIR}
)

# Build the http library
FILE(GLOB NEXT_HTTP_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "src/http/*.cpp")
ADD_LIBRARY(next_http ${NEXT_HTTP_SOURCES})
TARGET_LINK_LIBRARIES(next_http next_log)
TARGET_COMPILE_OPTIONS(next_http PRIVATE ${CMAKE_COMPILER_FLAG})
TARGET_INCLUDE_DIRECTORIES(
turtle_core
next_http
PUBLIC ${NEXT_SERVER_SRC_INCLUDE_DIR}
)

# Build the turtle logging library
FILE(GLOB TURTLE_LOG_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "src/log/*.cpp")
ADD_LIBRARY(turtle_log ${TURTLE_LOG_SOURCES})
TARGET_LINK_LIBRARIES(turtle_log Threads::Threads)
TARGET_COMPILE_OPTIONS(turtle_log PRIVATE ${CMAKE_COMPILER_FLAG})
# Build the logging library
FILE(GLOB next_log_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "src/log/*.cpp")
ADD_LIBRARY(next_log ${next_log_SOURCES})
TARGET_LINK_LIBRARIES(next_log Threads::Threads)
TARGET_COMPILE_OPTIONS(next_log PRIVATE ${CMAKE_COMPILER_FLAG})
TARGET_INCLUDE_DIRECTORIES(
turtle_log
next_log
PUBLIC ${NEXT_SERVER_SRC_INCLUDE_DIR}
)

# Build the echo server
ADD_EXECUTABLE(echo_server ${NEXT_SERVER_DEMO_DIR}/echo/echo_server.cpp)
TARGET_LINK_LIBRARIES(echo_server turtle_core)
TARGET_LINK_LIBRARIES(echo_server next_core)
TARGET_COMPILE_OPTIONS(echo_server PRIVATE ${CMAKE_COMPILER_FLAG})
TARGET_INCLUDE_DIRECTORIES(
echo_server
Expand All @@ -79,11 +128,20 @@ TARGET_INCLUDE_DIRECTORIES(

# Build the echo client
ADD_EXECUTABLE(echo_client ${NEXT_SERVER_DEMO_DIR}/echo/echo_client.cpp)
TARGET_LINK_LIBRARIES(echo_client turtle_core)
TARGET_LINK_LIBRARIES(echo_client next_core)
TARGET_INCLUDE_DIRECTORIES(
echo_client
PUBLIC ${NEXT_SERVER_SRC_INCLUDE_DIR}
)

# Build the http server
ADD_EXECUTABLE(http_server ${NEXT_SERVER_SRC_DIR}/http/http_server.cpp)
TARGET_LINK_LIBRARIES(http_server next_core next_http)
TARGET_COMPILE_OPTIONS(http_server PRIVATE ${CMAKE_COMPILER_FLAG})
TARGET_INCLUDE_DIRECTORIES(
http_server
PUBLIC ${NEXT_SERVER_SRC_INCLUDE_DIR}
)



Binary file modified bin/echo_client
Binary file not shown.
Binary file modified bin/echo_server
Binary file not shown.
70 changes: 35 additions & 35 deletions build/CMakeCache.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the CMakeCache file.
# For build in directory: /home/book/study/Next/build
# It was generated by CMake: /home/book/Downloads/cmake-3.27.4-linux-x86_64/bin/cmake
# For build in directory: /home/gxj/Next/build
# It was generated by CMake: /usr/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
Expand All @@ -14,6 +14,12 @@
# EXTERNAL cache entries
########################

//Path to a program.
CLANG_FORMAT_BIN:FILEPATH=/usr/bin/clang-format

//Path to a program.
CLANG_TIDY_BIN:FILEPATH=/usr/bin/clang-tidy

//Path to a program.
CMAKE_ADDR2LINE:FILEPATH=/usr/bin/addr2line

Expand All @@ -32,11 +38,11 @@ CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++

//A wrapper around 'ar' adding the appropriate '--plugin' option
// for the GCC compiler
CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-8
CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-11

//A wrapper around 'ranlib' adding the appropriate '--plugin' option
// for the GCC compiler
CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-8
CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-11

//Flags used by the CXX compiler during all build types.
CMAKE_CXX_FLAGS:STRING=
Expand All @@ -58,11 +64,11 @@ CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc

//A wrapper around 'ar' adding the appropriate '--plugin' option
// for the GCC compiler
CMAKE_C_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-8
CMAKE_C_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-11

//A wrapper around 'ranlib' adding the appropriate '--plugin' option
// for the GCC compiler
CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-8
CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-11

//Flags used by the C compiler during all build types.
CMAKE_C_FLAGS:STRING=
Expand Down Expand Up @@ -100,17 +106,14 @@ CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
//Enable/Disable output of compile commands during generation.
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=

//Value Computed by CMake.
CMAKE_FIND_PACKAGE_REDIRECTS_DIR:STATIC=/home/book/study/Next/build/CMakeFiles/pkgRedirects

//Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX:PATH=/usr/local

//Path to a program.
CMAKE_LINKER:FILEPATH=/usr/bin/ld

//Path to a program.
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/gmake

//Flags used by the linker during the creation of modules during
// all build types.
Expand Down Expand Up @@ -221,26 +224,29 @@ CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
//Path to a program.
CMAKE_STRIP:FILEPATH=/usr/bin/strip

//Path to a program.
CMAKE_TAPI:FILEPATH=CMAKE_TAPI-NOTFOUND

//If this value is on, makefiles will be generated without the
// .SILENT directive, and all commands will be echoed to the console
// during the make. This is useful for debugging only. With Visual
// Studio IDE projects all commands are done without /nologo.
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE

//Path to a program.
CPPLINT_BIN:FILEPATH=/home/gxj/Next/build_support/cpplint.py

//Value Computed by CMake
NextServer_BINARY_DIR:STATIC=/home/book/study/Next/build
NextServer_BINARY_DIR:STATIC=/home/gxj/Next/build

//Value Computed by CMake
NextServer_IS_TOP_LEVEL:STATIC=ON

//Value Computed by CMake
NextServer_SOURCE_DIR:STATIC=/home/book/study/Next
NextServer_SOURCE_DIR:STATIC=/home/gxj/Next

//No help, variable specified on the command line.
TIMER:UNINITIALIZED=3000
//Dependencies for the target
next_core_LIB_DEPENDS:STATIC=general;next_log;

//Dependencies for the target
next_http_LIB_DEPENDS:STATIC=general;next_log;

//Dependencies for the target
turtle_core_LIB_DEPENDS:STATIC=general;turtle_log;
Expand All @@ -255,21 +261,21 @@ CMAKE_ADDR2LINE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_AR
CMAKE_AR-ADVANCED:INTERNAL=1
//This is the directory where this CMakeCache.txt was created
CMAKE_CACHEFILE_DIR:INTERNAL=/home/book/study/Next/build
CMAKE_CACHEFILE_DIR:INTERNAL=/home/gxj/Next/build
//Major version of cmake used to create the current loaded cache
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
//Minor version of cmake used to create the current loaded cache
CMAKE_CACHE_MINOR_VERSION:INTERNAL=27
CMAKE_CACHE_MINOR_VERSION:INTERNAL=22
//Patch version of cmake used to create the current loaded cache
CMAKE_CACHE_PATCH_VERSION:INTERNAL=4
CMAKE_CACHE_PATCH_VERSION:INTERNAL=1
//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
//Path to CMake executable.
CMAKE_COMMAND:INTERNAL=/home/book/Downloads/cmake-3.27.4-linux-x86_64/bin/cmake
CMAKE_COMMAND:INTERNAL=/usr/bin/cmake
//Path to cpack program executable.
CMAKE_CPACK_COMMAND:INTERNAL=/home/book/Downloads/cmake-3.27.4-linux-x86_64/bin/cpack
CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack
//Path to ctest program executable.
CMAKE_CTEST_COMMAND:INTERNAL=/home/book/Downloads/cmake-3.27.4-linux-x86_64/bin/ctest
CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest
//ADVANCED property for variable: CMAKE_CXX_COMPILER
CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_COMPILER_AR
Expand Down Expand Up @@ -304,8 +310,6 @@ CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_DLLTOOL
CMAKE_DLLTOOL-ADVANCED:INTERNAL=1
//Path to cache edit program executable.
CMAKE_EDIT_COMMAND:INTERNAL=/home/book/Downloads/cmake-3.27.4-linux-x86_64/bin/ccmake
//Executable file format
CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
Expand All @@ -331,10 +335,12 @@ CMAKE_GENERATOR_PLATFORM:INTERNAL=
//Name of generator toolset.
CMAKE_GENERATOR_TOOLSET:INTERNAL=
//Test CMAKE_HAVE_LIBC_PTHREAD
CMAKE_HAVE_LIBC_PTHREAD:INTERNAL=
CMAKE_HAVE_LIBC_PTHREAD:INTERNAL=1
//Have include pthread.h
CMAKE_HAVE_PTHREAD_H:INTERNAL=1
//Source directory with the top level CMakeLists.txt file for this
// project
CMAKE_HOME_DIRECTORY:INTERNAL=/home/book/study/Next
CMAKE_HOME_DIRECTORY:INTERNAL=/home/gxj/Next
//Install .so files without execute permission.
CMAKE_INSTALL_SO_NO_EXE:INTERNAL=1
//ADVANCED property for variable: CMAKE_LINKER
Expand Down Expand Up @@ -366,7 +372,7 @@ CMAKE_RANLIB-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_READELF
CMAKE_READELF-ADVANCED:INTERNAL=1
//Path to CMake installation.
CMAKE_ROOT:INTERNAL=/home/book/Downloads/cmake-3.27.4-linux-x86_64/share/cmake-3.27
CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.22
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
Expand All @@ -393,16 +399,10 @@ CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STRIP
CMAKE_STRIP-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_TAPI
CMAKE_TAPI-ADVANCED:INTERNAL=1
//uname command
CMAKE_UNAME:INTERNAL=/bin/uname
CMAKE_UNAME:INTERNAL=/usr/bin/uname
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
//Details about finding Threads
FIND_PACKAGE_MESSAGE_DETAILS_Threads:INTERNAL=[TRUE][v()]
//Result of TRY_COMPILE
THREADS_HAVE_PTHREAD_ARG:INTERNAL=TRUE
//linker supports push/pop state
_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED:INTERNAL=TRUE

Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
set(CMAKE_C_COMPILER "/usr/bin/cc")
set(CMAKE_C_COMPILER_ARG1 "")
set(CMAKE_C_COMPILER_ID "GNU")
set(CMAKE_C_COMPILER_VERSION "8.4.0")
set(CMAKE_C_COMPILER_VERSION "11.4.0")
set(CMAKE_C_COMPILER_VERSION_INTERNAL "")
set(CMAKE_C_COMPILER_WRAPPER "")
set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "17")
set(CMAKE_C_EXTENSIONS_COMPUTED_DEFAULT "ON")
set(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert;c_std_17")
set(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert;c_std_17;c_std_23")
set(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes")
set(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros")
set(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert")
set(CMAKE_C17_COMPILE_FEATURES "c_std_17")
set(CMAKE_C23_COMPILE_FEATURES "")
set(CMAKE_C23_COMPILE_FEATURES "c_std_23")

set(CMAKE_C_PLATFORM_ID "Linux")
set(CMAKE_C_SIMULATE_ID "")
set(CMAKE_C_COMPILER_FRONTEND_VARIANT "GNU")
set(CMAKE_C_COMPILER_FRONTEND_VARIANT "")
set(CMAKE_C_SIMULATE_VERSION "")




set(CMAKE_AR "/usr/bin/ar")
set(CMAKE_C_COMPILER_AR "/usr/bin/gcc-ar-8")
set(CMAKE_C_COMPILER_AR "/usr/bin/gcc-ar-11")
set(CMAKE_RANLIB "/usr/bin/ranlib")
set(CMAKE_C_COMPILER_RANLIB "/usr/bin/gcc-ranlib-8")
set(CMAKE_C_COMPILER_RANLIB "/usr/bin/gcc-ranlib-11")
set(CMAKE_LINKER "/usr/bin/ld")
set(CMAKE_MT "")
set(CMAKE_TAPI "CMAKE_TAPI-NOTFOUND")
set(CMAKE_COMPILER_IS_GNUCC 1)
set(CMAKE_C_COMPILER_LOADED 1)
set(CMAKE_C_COMPILER_WORKS TRUE)
Expand All @@ -39,7 +38,6 @@ set(CMAKE_C_COMPILER_ID_RUN 1)
set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
set(CMAKE_C_LINKER_PREFERENCE 10)
set(CMAKE_C_LINKER_DEPFILE_SUPPORTED FALSE)

# Save compiler ABI information.
set(CMAKE_C_SIZEOF_DATA_PTR "8")
Expand Down Expand Up @@ -68,7 +66,7 @@ endif()



set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/8/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/8/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include")
set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/11/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include")
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "gcc;gcc_s;c;gcc;gcc_s")
set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/8;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib")
set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/11;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib")
set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
Loading

0 comments on commit 067400f

Please sign in to comment.