테스트 구조 완성, 코딩 스타일 교정 기능 추가 쓸데없는 설정파일들 정리

This commit is contained in:
2025-09-01 02:29:37 +09:00
parent e26d20a869
commit b123b2ecdb
16 changed files with 208 additions and 204 deletions

8
.clang-format Normal file
View File

@@ -0,0 +1,8 @@
# Google C/C++ Code Style Settings
Language: Cpp
BasedOnStyle: Google
Standard: c++20
IndentWidth: 2
UseTab: Never
ColumnLimit: 80

10
.idea/.gitignore generated vendored
View File

@@ -1,10 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Environment-dependent path to Maven home directory
/mavenHomeManager.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

9
.idea/BumbleCee.iml generated
View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/misc.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="openjdk-23" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated
View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/BumbleCee.iml" filepath="$PROJECT_DIR$/.idea/BumbleCee.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@@ -1,19 +0,0 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/include"
],
"defines": [
"DDPP_CORO=on"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}

13
.vscode/launch.json vendored
View File

@@ -1,13 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/BumbleCee",
"program": "${workspaceFolder}/build/Debug Clang 18.1.3 x86_64-pc-linux-gnu/tests/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
@@ -22,8 +26,7 @@
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "${defaultBuildTask}"
]
}
]
}

48
.vscode/settings.json vendored
View File

@@ -1,9 +1,16 @@
{
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
"editor.rulers": [
{
"column": 80
}
],
"cmake.generator": "Ninja",
"files.associations": {
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csetjmp": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
@@ -12,37 +19,53 @@
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"barrier": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"coroutine": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"expected": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"rope": "cpp",
"slist": "cpp",
"format": "cpp",
"fstream": "cpp",
"future": "cpp",
@@ -51,20 +74,39 @@
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"latch": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"scoped_allocator": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"spanstream": "cpp",
"sstream": "cpp",
"stacktrace": "cpp",
"stdexcept": "cpp",
"stdfloat": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"syncstream": "cpp",
"thread": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp",
"__config": "cpp",
"rope": "cpp"
"__locale": "cpp",
"ios": "cpp",
"locale": "cpp",
"print": "cpp"
},
"files.exclude": {
"**/*.rpyc": true,
"**/*.rpa": true,
"**/*.rpymc": true,
"**/cache/": true
}
}

37
.vscode/tasks.json vendored
View File

@@ -1,37 +0,0 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "ninja",
"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
}
},
]
}

View File

@@ -2,12 +2,17 @@ cmake_minimum_required (VERSION 3.16)
set(BOT_NAME "BumbleCee")
project(${BOT_NAME} LANGUAGES CXX)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(BOOST_EXCLUDE_LIBRARIES nowide)
set(BUILD_TESTING ON)
set(DPP_BUILD_TEST OFF)
enable_testing()
if(WIN32)
set(OPENSSL_ROOT_DIR "C:/Program Files/OpenSSL-Win64")
@@ -26,14 +31,15 @@ find_package(OpenSSL REQUIRED)
include(FetchContent)
set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS})
FetchContent_Declare(
Boost
URL "https://github.com/boostorg/boost/releases/download/boost-1.89.0/boost-1.89.0-cmake.7z"
DOWNLOAD_EXTRACT_TIMESTAMP ON
CMAKE_ARGS
-DBOOST_USE_STATIC_LIBS=ON
-DBOOST_USE_STATIC_RUNTIME=ON
EXCLUDE_FROM_ALL
)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Do not build SHARED libraries" FORCE)
message(STATUS "Fetching and making available Boost...")
FetchContent_MakeAvailable(Boost)
@@ -42,11 +48,13 @@ FetchContent_Declare(
GIT_REPOSITORY "https://github.com/brainboxdotcc/DPP.git"
GIT_TAG "v10.1.3"
GIT_SHALLOW ON
CMAKE_ARGS -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} -DCMAKE_CXX_STANDARD_REQUIRED=ON
)
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build SHARED libraries" FORCE)
message(STATUS "Fetching and making available dpp...")
FetchContent_MakeAvailable(dpp)
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD} CACHE BOOL "Type of libraries to build" FORCE)
# -------------------------------------------------------------
# 플랫폼별 FFmpeg 바이너리 다운로드 및 링크
# -------------------------------------------------------------
@@ -84,41 +92,42 @@ find_library(AVUTIL_LIBRARY NAMES avutil PATHS ${FFMPEG_LIBRARY_PATH} NO_DEFAULT
message(STATUS "AVUTIL_LIBRARY = ${AVUTIL_LIBRARY}")
find_library(SWSCALE_LIBRARY NAMES swscale PATHS ${FFMPEG_LIBRARY_PATH} NO_DEFAULT_PATH)
message(STATUS "SWSCALE_LIBRARY = ${SWSCALE_LIBRARY}")
find_library(SWRESAMPLE_LIBRARY NAMES swresample PATHS ${FFMPEG_LIBRARY_PATH} NO_DEFAULT_PATH)
message(STATUS "SWRESAMPLE_LIBRARY = ${SWRESAMPLE_LIBRARY}")
if(NOT AVCODEC_LIBRARY OR NOT AVFORMAT_LIBRARY OR NOT AVUTIL_LIBRARY)
if(NOT AVCODEC_LIBRARY OR NOT AVFORMAT_LIBRARY OR NOT AVUTIL_LIBRARY OR NOT SWRESAMPLE_LIBRARY)
message(FATAL_ERROR "FFmpeg 라이브러리를 찾을 수 없습니다. 다운로드 경로를 확인해주세요.")
endif()
file(GLOB_RECURSE CORES "src/*.cpp" "src/*.cxx" "src/*.cc")
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.cxx" "src/*.cc")
set(ALL_SOURCE_FILES
${CORES}
${AUDIO_SOURCES}
${COMMANDS_SOURCES}
${QUEUE_SOURCES}
${SETTINGS_SOURCES}
${UTILS_SOURCES}
)
add_library(${BOT_NAME}_lib ${SOURCES})
add_executable(${BOT_NAME} ${ALL_SOURCE_FILES})
target_include_directories(${BOT_NAME}_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(${BOT_NAME} PRIVATE dpp)
target_link_libraries(${BOT_NAME} PRIVATE Boost::filesystem)
target_link_libraries(${BOT_NAME} PRIVATE Boost::process)
target_link_libraries(${BOT_NAME} PRIVATE Boost::log)
target_link_libraries(${BOT_NAME} PRIVATE Boost::beast)
target_link_libraries(${BOT_NAME} PRIVATE OpenSSL::Crypto)
target_link_libraries(${BOT_NAME} PRIVATE OpenSSL::SSL)
target_link_libraries(${BOT_NAME} PRIVATE ${AVUTIL_LIBRARY})
target_link_libraries(${BOT_NAME} PRIVATE ${AVCODEC_LIBRARY})
target_link_libraries(${BOT_NAME} PRIVATE ${AVFORMAT_LIBRARY})
target_link_libraries(${BOT_NAME} PRIVATE ${SWSCALE_LIBRARY})
target_include_directories(${BOT_NAME}_lib PUBLIC ${OpenSSL_INCLUDE_DIRS})
target_include_directories(${BOT_NAME}_lib PUBLIC ${FFMPEG_INCLUDE_PATH})
target_precompile_headers(${BOT_NAME}_lib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include/precomp.h")
target_link_libraries(${BOT_NAME}_lib PUBLIC dpp)
target_link_libraries(${BOT_NAME}_lib PUBLIC Boost::filesystem)
target_link_libraries(${BOT_NAME}_lib PUBLIC Boost::process)
target_link_libraries(${BOT_NAME}_lib PUBLIC Boost::log)
target_link_libraries(${BOT_NAME}_lib PUBLIC Boost::beast)
target_link_libraries(${BOT_NAME}_lib PUBLIC OpenSSL::Crypto)
target_link_libraries(${BOT_NAME}_lib PUBLIC OpenSSL::SSL)
target_link_libraries(${BOT_NAME}_lib PUBLIC ${AVUTIL_LIBRARY})
target_link_libraries(${BOT_NAME}_lib PUBLIC ${AVCODEC_LIBRARY})
target_link_libraries(${BOT_NAME}_lib PUBLIC ${AVFORMAT_LIBRARY})
target_link_libraries(${BOT_NAME}_lib PUBLIC ${SWSCALE_LIBRARY})
target_link_libraries(${BOT_NAME}_lib PUBLIC ${SWRESAMPLE_LIBRARY})
if(WIN32)
target_link_libraries(${BOT_NAME} PRIVATE ws2_32)
target_link_libraries(${BOT_NAME}_lib PUBLIC ws2_32)
endif()
if(UNIX AND NOT APPLE AND CMAKE_BUILD_TYPE STREQUAL "Release")
set_target_properties(${PROJECT_NAME} PROPERTIES
if(UNIX AND NOT APPLE)
set_target_properties(${BOT_NAME}_lib PROPERTIES
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH "$ORIGIN"
SKIP_BUILD_RPATH FALSE
@@ -126,16 +135,29 @@ if(UNIX AND NOT APPLE AND CMAKE_BUILD_TYPE STREQUAL "Release")
)
endif()
target_include_directories(${BOT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_executable(${BOT_NAME} ${SOURCES})
target_include_directories(${BOT_NAME} PRIVATE ${OpenSSL_INCLUDE_DIRS})
target_include_directories(${BOT_NAME} PRIVATE ${FFMPEG_INCLUDE_PATH})
target_link_libraries(${BOT_NAME} PUBLIC ${BOT_NAME}_lib)
target_precompile_headers(${BOT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include/precomp.h")
file(GLOB FFMPEG_SHARED
"${CMAKE_BINARY_DIR}/${FFMPEG_ARCHIVE_NAME}/bin/*.dll" # Windows
"${CMAKE_BINARY_DIR}/${FFMPEG_ARCHIVE_NAME}/lib/*.so*" # Linux
)
foreach(ffmpeg_shared ${FFMPEG_SHARED})
add_custom_command(TARGET ${BOT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${ffmpeg_shared}"
"$<TARGET_FILE_DIR:${BOT_NAME}>"
COMMENT "Copying ${ffmpeg_shared} to output directory"
)
endforeach()
add_custom_command(TARGET ${BOT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_BINARY_DIR}/${FFMPEG_ARCHIVE_NAME}/bin"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE:dpp>"
"$<TARGET_FILE_DIR:${BOT_NAME}>"
COMMENT "Copying FFMpeg_AVCODEC DLL/so files to output directory"
COMMENT "Copying dpp DLL/so files to output directory"
)
add_subdirectory(tests)

View File

@@ -4,51 +4,7 @@
int main(int argc, char* argv[]) {
boost::asio::io_context ctx;
boost::system::error_code ec;
char buf[8192];
std::string output;
utils::CheckUpdate(ctx);
#ifdef WIN32
/*try {
auto ytdlp_pipe = utils::OpenPipe(ctx,
"yt-dlp.exe", { "-o", "-", "--quiet", "--ignore-errors", "-f",
"bestaudio", "https://youtu.be/9_bTl2vvYQg?si=IVhvpDhnpPvziwQR" });
while (true) {
boost::system::error_code read_ec;
size_t bytes_read =
boost::asio::read(ytdlp_pipe, boost::asio::buffer(buf,
8192), read_ec); if (bytes_read > 0) { std::cout.write(buf, bytes_read);
}
if (read_ec == boost::asio::error::eof || read_ec) {
break;
}
}
}
catch (const boost::process::system_error& e) {
std::string error = e.what();
return -1;
}*/
#else
auto ytdlp_pipe = utils::OpenPipe(
ctx, "yt-dlp",
{"-o", "-", "--quiet", "--ignore-errors", "-f", "bestaudio",
"https://youtu.be/9_bTl2vvYQg?si=IVhvpDhnpPvziwQR"});
while (true) {
boost::system::error_code read_ec;
size_t bytes_read =
boost::asio::read(ytdlp_pipe, boost::asio::buffer(buf, 8192), read_ec);
if (bytes_read > 0) {
std::cout.write(buf, bytes_read);
}
if (read_ec == boost::asio::error::eof || read_ec) {
break;
}
}
#endif
return 0;
}

8
tests/CMakeLists.txt Normal file
View File

@@ -0,0 +1,8 @@
file(GLOB_RECURSE TEST_SOURCES "*.cpp" "*.cxx" "*.cc")
foreach(test_src ${TEST_SOURCES})
get_filename_component(test_name ${test_src} NAME_WE)
add_executable(${test_name} ${test_src})
target_link_libraries(${test_name} PRIVATE ${BOT_NAME}_lib)
add_test(NAME ${test_name} COMMAND ${test_name})
endforeach()

View File

@@ -0,0 +1,52 @@
#include "precomp.h"
#include "utils/console.h"
#include "utils/update_checker.h"
int main() {
boost::asio::io_context ctx;
boost::system::error_code ec;
utils::CheckUpdate(ctx);
char buf[8192];
#ifdef WIN32
/*try {
auto ytdlp_pipe = utils::OpenPipe(ctx,
"yt-dlp.exe", { "-o", "-", "--quiet", "--ignore-errors", "-f",
"bestaudio", "https://youtu.be/9_bTl2vvYQg?si=IVhvpDhnpPvziwQR" });
while (true) {
boost::system::error_code read_ec;
size_t bytes_read =
boost::asio::read(ytdlp_pipe, boost::asio::buffer(buf,
8192), read_ec); if (bytes_read > 0) { std::cout.write(buf, bytes_read);
}
if (read_ec == boost::asio::error::eof || read_ec) {
break;
}
}
}
catch (const boost::process::system_error& e) {
std::string error = e.what();
return -1;
}*/
#else
auto ytdlp_pipe = utils::OpenPipe(
ctx, "yt-dlp",
{"-o", "-", "--quiet", "--ignore-errors", "-f", "bestaudio",
"https://youtu.be/9_bTl2vvYQg?si=IVhvpDhnpPvziwQR"});
while (true) {
boost::system::error_code read_ec;
size_t bytes_read =
boost::asio::read(ytdlp_pipe, boost::asio::buffer(buf, 8192), read_ec);
if (bytes_read > 0) {
std::cout.write(buf, bytes_read);
}
if (read_ec == boost::asio::error::eof || read_ec) {
break;
}
}
#endif
return 0;
}

8
tests/update.cc Normal file
View File

@@ -0,0 +1,8 @@
#include "precomp.h"
#include "utils/update_checker.h"
int main() {
boost::asio::io_context ctx;
utils::CheckUpdate(ctx);
return 0;
}

BIN
yt-dlp

Binary file not shown.