Initial commit

This commit is contained in:
2025-04-21 19:58:25 +09:00
commit c81197054d
14 changed files with 246 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
build/*

55
.vscode/launch.json vendored Normal file
View File

@@ -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}"
}
]
}

6
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"files.associations": {
"assert": "cpp",
"zstring": "cpp"
}
}

36
.vscode/tasks.json vendored Normal file
View File

@@ -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
}
},
]
}

9
CMakeLists.txt Normal file
View File

@@ -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)

13
Client/CMakeLists.txt Normal file
View File

@@ -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
)

5
Client/src/client.cpp Normal file
View File

@@ -0,0 +1,5 @@
#include <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
}

41
Server/CMakeLists.txt Normal file
View File

@@ -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)

6
Server/src/server.cpp Normal file
View File

@@ -0,0 +1,6 @@
#include <iostream>
#include "Socket/Error.hpp"
int main() {
std::cout << "Hello, world!" << std::endl;
}

29
impl/Socket/Error.cpp Normal file
View File

@@ -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);
}
}

View File

@@ -0,0 +1,11 @@
#include "Socket/Socket_Init.hpp"
namespace Chattr {
Socket_Init::Socket_Init() {
}
Socket_Init::~Socket_Init() {
}
}

0
include/Common.hpp Normal file
View File

16
include/Socket/Error.hpp Normal file
View File

@@ -0,0 +1,16 @@
#pragma once
#ifdef _WIN32
#include <winsock2.h>
#elif __linux__
#include <errno.h>
#else
#error "이 플랫폼은 지원되지 않습니다."
#endif
#include <gsl/gsl>
namespace Chattr::error {
void critical(gsl::czstring msg);
void error(gsl::czstring msg);
}

View File

@@ -0,0 +1,18 @@
#pragma once
#ifdef _WIN32
#elif __linux__
#else
#error "이 플랫폼은 지원되지 않습니다."
#endif
namespace Chattr {
struct Socket_Init {
Socket_Init();
~Socket_Init();
};
}