From 1fa0913f3cbfea2812844e1a2ba3c682ea188491 Mon Sep 17 00:00:00 2001 From: Mars Ultor Date: Tue, 23 Dec 2025 22:10:12 -0600 Subject: [PATCH] test --- .gitignore | 38 ++++++++++++++++++++ .gitmodules | 10 ++++++ CMakeLists.txt | 78 +++++++++++++++++++++++++++++++++++++++++ external/clickhouse-cpp | 1 + external/spdlog | 1 + external/tomlplusplus | 1 + src/main.cpp | 14 ++++++++ 7 files changed, 143 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 160000 external/clickhouse-cpp create mode 160000 external/spdlog create mode 160000 external/tomlplusplus create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..edb7364 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +# OS junk +.DS_Store +Thumbs.db + +# Editor settings +.vscode/** +.idea/** +*.swp +*.swo + +# Build system metadata (keep actual build dirs tracked) +CMakeFiles/** +CMakeCache.txt +cmake_install.cmake +Makefile +compile_commands.json + +# Logs and temp files +*.log +*.tmp +*.bak +*.old + +build/** +*.toml +.cache/** + + +**/*.aux +**/*.fdb_latexmk +**/*.fls +**/*.log +**/*.synctex.gz +**/*.blg +**/*.bcf +**/*.run.xml +**/*.bbl + diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..02f0964 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,10 @@ + +[submodule "external/clickhouse-cpp"] + path = external/clickhouse-cpp + url = https://github.com/ClickHouse/clickhouse-cpp +[submodule "external/tomlplusplus"] + path = external/tomlplusplus + url = https://github.com/marzer/tomlplusplus +[submodule "external/spdlog"] + path = external/spdlog + url = https://github.com/gabime/spdlog diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..baa10f4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,78 @@ +cmake_minimum_required(VERSION 3.20) + +# ----------------------------- +# Force Clang before project() is called +# ----------------------------- +if(NOT DEFINED CMAKE_C_COMPILER) + set(CMAKE_C_COMPILER clang CACHE STRING "" FORCE) +endif() +if(NOT DEFINED CMAKE_CXX_COMPILER) + set(CMAKE_CXX_COMPILER clang++ CACHE STRING "" FORCE) +endif() + +# ----------------------------- +# Project setup +# ----------------------------- +project(mc-watchdog LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_BUILD_TYPE Release) + +# ----------------------------- +# Dependencies (local submodules / cloned repos) +# ----------------------------- +add_subdirectory(external/spdlog) + +add_subdirectory(external/clickhouse-cpp) +add_subdirectory(external/tomlplusplus) +# ----------------------------- +# Executable +# ----------------------------- +add_executable(${PROJECT_NAME} src/main.cpp) + +# ----------------------------- +# Auto-discover include dirs under src/ +# ----------------------------- +file(GLOB_RECURSE SRC_SUBDIRS LIST_DIRECTORIES true "${CMAKE_CURRENT_SOURCE_DIR}/src/*") +set(SRC_INCLUDES "") +foreach(dir ${SRC_SUBDIRS}) + if(IS_DIRECTORY ${dir}) + list(APPEND SRC_INCLUDES ${dir}) + endif() +endforeach() + +# ----------------------------- +# Auto-discover all .cpp files except main.cpp +# ----------------------------- +file(GLOB_RECURSE ALL_CPP "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") +list(REMOVE_ITEM ALL_CPP "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp") + +# ----------------------------- +# Apply sources and includes +# ----------------------------- +target_sources(${PROJECT_NAME} PRIVATE ${ALL_CPP}) +target_include_directories(${PROJECT_NAME} PRIVATE ${SRC_INCLUDES}) + +# ----------------------------- +# Link libraries +# ----------------------------- +target_link_libraries(${PROJECT_NAME} PRIVATE + spdlog::spdlog + clickhouse-cpp-lib + tomlplusplus::tomlplusplus +) + +# ----------------------------- +# Compiler warnings (Clang/GCC) +# ----------------------------- +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") + add_compile_options( + -Wall -Wextra -Wpedantic + -Wconversion -Wshadow + -Wnull-dereference + -Wdouble-promotion + ) +endif() + diff --git a/external/clickhouse-cpp b/external/clickhouse-cpp new file mode 160000 index 0000000..3c94b44 --- /dev/null +++ b/external/clickhouse-cpp @@ -0,0 +1 @@ +Subproject commit 3c94b44894197860cabbba97c015b967055a55c2 diff --git a/external/spdlog b/external/spdlog new file mode 160000 index 0000000..32dd298 --- /dev/null +++ b/external/spdlog @@ -0,0 +1 @@ +Subproject commit 32dd298dc2d60fe0454e70b818d64941392c5b41 diff --git a/external/tomlplusplus b/external/tomlplusplus new file mode 160000 index 0000000..e7aaccc --- /dev/null +++ b/external/tomlplusplus @@ -0,0 +1 @@ +Subproject commit e7aaccca3fa3dbde9818ab8313250f3da4976e37 diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..fdd5017 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main (int argc, char *argv[]) { + auto config = toml::parse_file("config.toml"); + bool ingest_all_logs = config["all"].value_or(false); + std::string log_path = config["minecraft"]["logs_path"].value_or(""); + if(log_path.empty()) throw std::runtime_error("your dumbass can't put in a path"); + std::string clickhouse_username = config["clickhouse"]["username"].value_or(""); + std::string clickouse_password = config["clickhouse"]["password"].value_or(""); + if(clickhouse_username.empty() || clickouse_password.empty()) throw std::runtime_error("put the creds in the right place idiot"); + + return 0; +}