commit c81197054d7b3dc73dc3b3c6892d420a376a9525 Author: HappyTanuki Date: Mon Apr 21 19:58:25 2025 +0900 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07ed706 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/* \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2cd616c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,55 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb)Client Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/Client/Client", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ], + "preLaunchTask": "${defaultBuildTask}" + }, + { + "name": "(gdb)Server Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/Server/Server", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ], + "preLaunchTask": "${defaultBuildTask}" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..16ddb66 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "assert": "cpp", + "zstring": "cpp" + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..642fe16 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,36 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "cppbuild", + "label": "ninja-build", + "command": "ninja", + "args": [], + "options": { + "cwd": "${workspaceFolder}/build/" + }, + "group": { + "kind": "build", + "isDefault": true + }, + "dependsOn": ["cmake"] + }, + { + "type": "shell", + "label": "cmake", + "command": "cmake", + "args": [ + "..", + "-G", + "Ninja" + ], + "options": { + "cwd": "${workspaceFolder}/build/" + }, + "group": { + "kind": "build", + "isDefault": false + } + }, + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2c06bcb --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.5) + +set(PROJECT_NAME "Chattring") +set(CMAKE_BUILD_TYPE Debug) + +project(${PROJECT_NAME}) + +add_subdirectory(Client) +add_subdirectory(Server) \ No newline at end of file diff --git a/Client/CMakeLists.txt b/Client/CMakeLists.txt new file mode 100644 index 0000000..b9a24fa --- /dev/null +++ b/Client/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.5) + +set(PROJECT_NAME "Client") +set(CMAKE_BUILD_TYPE Debug) + +project(${PROJECT_NAME}) + +add_executable(${PROJECT_NAME} src/client.cpp) + +target_include_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/../include + ${CMAKE_CURRENT_SOURCE_DIR}/include +) \ No newline at end of file diff --git a/Client/src/client.cpp b/Client/src/client.cpp new file mode 100644 index 0000000..10daf1f --- /dev/null +++ b/Client/src/client.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + std::cout << "Hello, world!" << std::endl; +} \ No newline at end of file diff --git a/Server/CMakeLists.txt b/Server/CMakeLists.txt new file mode 100644 index 0000000..69d62cb --- /dev/null +++ b/Server/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.5) + +set(PROJECT_NAME "Server") +set(CMAKE_BUILD_TYPE Debug) + +project(${PROJECT_NAME} CXX) + +include(FetchContent) + +FetchContent_Declare( + spdlog + GIT_REPOSITORY "https://github.com/gabime/spdlog.git" + GIT_TAG "v1.15.2" + GIT_SHALLOW ON +) +FetchContent_MakeAvailable(spdlog) + +FetchContent_Declare( + GSL + GIT_REPOSITORY "https://github.com/microsoft/GSL.git" + GIT_TAG "v4.2.0" + GIT_SHALLOW ON +) +FetchContent_MakeAvailable(GSL) + +file(GLOB_RECURSE additional_sources CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/../impl/*.cpp" +) + +add_executable(${PROJECT_NAME} + src/server.cpp + ${additional_sources} +) +target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft.GSL::GSL) +target_link_libraries(${PROJECT_NAME} PRIVATE spdlog) + +target_include_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/../include + ${CMAKE_CURRENT_SOURCE_DIR}/include +) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) \ No newline at end of file diff --git a/Server/src/server.cpp b/Server/src/server.cpp new file mode 100644 index 0000000..c7fd739 --- /dev/null +++ b/Server/src/server.cpp @@ -0,0 +1,6 @@ +#include +#include "Socket/Error.hpp" + +int main() { + std::cout << "Hello, world!" << std::endl; +} \ No newline at end of file diff --git a/impl/Socket/Error.cpp b/impl/Socket/Error.cpp new file mode 100644 index 0000000..d3a2089 --- /dev/null +++ b/impl/Socket/Error.cpp @@ -0,0 +1,29 @@ +#include "Socket/Error.hpp" +#include "spdlog/spdlog.h" + +namespace Chattr::error { + +void critical(gsl::czstring msg) { +#ifdef _WIN32 + //TODO 윈도우에서 구현할 것 +#elif __linux__ + gsl::czstring msgbuf = strerror(errno); +#else +#error "이 플랫폼은 지원되지 않습니다." +#endif + spdlog::critical(msgbuf); + std::exit(EXIT_FAILURE); +} + +void error(gsl::czstring msg) { +#ifdef _WIN32 + //TODO 윈도우에서 구현할 것 +#elif __linux__ + gsl::czstring msgbuf = strerror(errno); +#else +#error "이 플랫폼은 지원되지 않습니다." +#endif + spdlog::error(msgbuf); +} + +} \ No newline at end of file diff --git a/impl/Socket/Socket_Init.cpp b/impl/Socket/Socket_Init.cpp new file mode 100644 index 0000000..f12a42e --- /dev/null +++ b/impl/Socket/Socket_Init.cpp @@ -0,0 +1,11 @@ +#include "Socket/Socket_Init.hpp" + +namespace Chattr { + +Socket_Init::Socket_Init() { +} + +Socket_Init::~Socket_Init() { +} + +} \ No newline at end of file diff --git a/include/Common.hpp b/include/Common.hpp new file mode 100644 index 0000000..e69de29 diff --git a/include/Socket/Error.hpp b/include/Socket/Error.hpp new file mode 100644 index 0000000..3d9c372 --- /dev/null +++ b/include/Socket/Error.hpp @@ -0,0 +1,16 @@ +#pragma once + +#ifdef _WIN32 +#include +#elif __linux__ +#include +#else +#error "이 플랫폼은 지원되지 않습니다." +#endif + +#include + +namespace Chattr::error { +void critical(gsl::czstring msg); +void error(gsl::czstring msg); +} \ No newline at end of file diff --git a/include/Socket/Socket_Init.hpp b/include/Socket/Socket_Init.hpp new file mode 100644 index 0000000..91c9380 --- /dev/null +++ b/include/Socket/Socket_Init.hpp @@ -0,0 +1,18 @@ +#pragma once + +#ifdef _WIN32 + +#elif __linux__ + +#else +#error "이 플랫폼은 지원되지 않습니다." +#endif + +namespace Chattr { + +struct Socket_Init { + Socket_Init(); + ~Socket_Init(); +}; + +} \ No newline at end of file