From 3bf42c6ff3805a0d42bbc661794a95ff31bedc26 Mon Sep 17 00:00:00 2001 From: untodesu Date: Sat, 15 Mar 2025 16:22:09 +0500 Subject: Add whatever I was working on for the last month --- deps/src/spdlog/CMakeLists.txt | 22 +++++++++++++ deps/src/spdlog/async.cpp | 11 +++++++ deps/src/spdlog/bundled_fmtlib_format.cpp | 48 +++++++++++++++++++++++++++ deps/src/spdlog/cfg.cpp | 8 +++++ deps/src/spdlog/color_sinks.cpp | 55 +++++++++++++++++++++++++++++++ deps/src/spdlog/file_sinks.cpp | 20 +++++++++++ deps/src/spdlog/spdlog.cpp | 28 ++++++++++++++++ deps/src/spdlog/stdout_sinks.cpp | 37 +++++++++++++++++++++ 8 files changed, 229 insertions(+) create mode 100644 deps/src/spdlog/CMakeLists.txt create mode 100644 deps/src/spdlog/async.cpp create mode 100644 deps/src/spdlog/bundled_fmtlib_format.cpp create mode 100644 deps/src/spdlog/cfg.cpp create mode 100644 deps/src/spdlog/color_sinks.cpp create mode 100644 deps/src/spdlog/file_sinks.cpp create mode 100644 deps/src/spdlog/spdlog.cpp create mode 100644 deps/src/spdlog/stdout_sinks.cpp (limited to 'deps/src/spdlog') diff --git a/deps/src/spdlog/CMakeLists.txt b/deps/src/spdlog/CMakeLists.txt new file mode 100644 index 0000000..8a10e27 --- /dev/null +++ b/deps/src/spdlog/CMakeLists.txt @@ -0,0 +1,22 @@ +add_library(spdlog STATIC + "${CMAKE_CURRENT_LIST_DIR}/async.cpp" + "${CMAKE_CURRENT_LIST_DIR}/bundled_fmtlib_format.cpp" + "${CMAKE_CURRENT_LIST_DIR}/cfg.cpp" + "${CMAKE_CURRENT_LIST_DIR}/color_sinks.cpp" + "${CMAKE_CURRENT_LIST_DIR}/file_sinks.cpp" + "${CMAKE_CURRENT_LIST_DIR}/spdlog.cpp" + "${CMAKE_CURRENT_LIST_DIR}/stdout_sinks.cpp") +target_compile_definitions(spdlog PUBLIC SPDLOG_COMPILED_LIB) +target_include_directories(spdlog PUBLIC "${DEPS_INCLUDE_DIR}") +set_target_properties(spdlog PROPERTIES FOLDER DEPS) + +find_package(Threads REQUIRED) +target_link_libraries(spdlog PUBLIC Threads::Threads) + +if(MSVC) + # There seems to be a compile-time check merged into the + # master fmtlib branch that has been pulled into spdlog as well + # that seems to fix an MSVC bug (https://github.com/fmtlib/fmt/pull/2297) + # FIXME: should I bundle fmtlib as a separate dependency? + target_compile_options(spdlog PUBLIC /utf-8) +endif() diff --git a/deps/src/spdlog/async.cpp b/deps/src/spdlog/async.cpp new file mode 100644 index 0000000..f99d977 --- /dev/null +++ b/deps/src/spdlog/async.cpp @@ -0,0 +1,11 @@ +// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. +// Distributed under the MIT License (http://opensource.org/licenses/MIT) + +#ifndef SPDLOG_COMPILED_LIB + #error Please define SPDLOG_COMPILED_LIB to compile this file. +#endif + +#include +#include +#include +#include diff --git a/deps/src/spdlog/bundled_fmtlib_format.cpp b/deps/src/spdlog/bundled_fmtlib_format.cpp new file mode 100644 index 0000000..4a5b35d --- /dev/null +++ b/deps/src/spdlog/bundled_fmtlib_format.cpp @@ -0,0 +1,48 @@ +// Slightly modified version of fmt lib's format.cc source file. +// Copyright (c) 2012 - 2016, Victor Zverovich +// All rights reserved. + +#ifndef SPDLOG_COMPILED_LIB + #error Please define SPDLOG_COMPILED_LIB to compile this file. +#endif + +#if !defined(SPDLOG_FMT_EXTERNAL) && !defined(SPDLOG_USE_STD_FORMAT) + + #include + +FMT_BEGIN_NAMESPACE +namespace detail { + +template FMT_API auto dragonbox::to_decimal(float x) noexcept + -> dragonbox::decimal_fp; +template FMT_API auto dragonbox::to_decimal(double x) noexcept + -> dragonbox::decimal_fp; + +#ifndef FMT_STATIC_THOUSANDS_SEPARATOR +template FMT_API locale_ref::locale_ref(const std::locale& loc); +template FMT_API auto locale_ref::get() const -> std::locale; +#endif + +// Explicit instantiations for char. + +template FMT_API auto thousands_sep_impl(locale_ref) + -> thousands_sep_result; +template FMT_API auto decimal_point_impl(locale_ref) -> char; + +template FMT_API void buffer::append(const char*, const char*); + +template FMT_API void vformat_to(buffer&, string_view, + typename vformat_args<>::type, locale_ref); + +// Explicit instantiations for wchar_t. + +template FMT_API auto thousands_sep_impl(locale_ref) + -> thousands_sep_result; +template FMT_API auto decimal_point_impl(locale_ref) -> wchar_t; + +template FMT_API void buffer::append(const wchar_t*, const wchar_t*); + +} // namespace detail +FMT_END_NAMESPACE + +#endif // !SPDLOG_FMT_EXTERNAL diff --git a/deps/src/spdlog/cfg.cpp b/deps/src/spdlog/cfg.cpp new file mode 100644 index 0000000..c98fd36 --- /dev/null +++ b/deps/src/spdlog/cfg.cpp @@ -0,0 +1,8 @@ +// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. +// Distributed under the MIT License (http://opensource.org/licenses/MIT) + +#ifndef SPDLOG_COMPILED_LIB + #error Please define SPDLOG_COMPILED_LIB to compile this file. +#endif + +#include diff --git a/deps/src/spdlog/color_sinks.cpp b/deps/src/spdlog/color_sinks.cpp new file mode 100644 index 0000000..2406004 --- /dev/null +++ b/deps/src/spdlog/color_sinks.cpp @@ -0,0 +1,55 @@ +// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. +// Distributed under the MIT License (http://opensource.org/licenses/MIT) + +#ifndef SPDLOG_COMPILED_LIB + #error Please define SPDLOG_COMPILED_LIB to compile this file. +#endif + +#include + +#include +#include +// +// color sinks +// +#ifdef _WIN32 + #include +template class SPDLOG_API spdlog::sinks::wincolor_sink; +template class SPDLOG_API spdlog::sinks::wincolor_sink; +template class SPDLOG_API spdlog::sinks::wincolor_stdout_sink; +template class SPDLOG_API spdlog::sinks::wincolor_stdout_sink; +template class SPDLOG_API spdlog::sinks::wincolor_stderr_sink; +template class SPDLOG_API spdlog::sinks::wincolor_stderr_sink; +#else + #include "spdlog/sinks/ansicolor_sink-inl.h" +template class SPDLOG_API spdlog::sinks::ansicolor_sink; +template class SPDLOG_API spdlog::sinks::ansicolor_sink; +template class SPDLOG_API spdlog::sinks::ansicolor_stdout_sink; +template class SPDLOG_API spdlog::sinks::ansicolor_stdout_sink; +template class SPDLOG_API spdlog::sinks::ansicolor_stderr_sink; +template class SPDLOG_API spdlog::sinks::ansicolor_stderr_sink; +#endif + +// factory methods for color loggers +#include "spdlog/sinks/stdout_color_sinks-inl.h" +template SPDLOG_API std::shared_ptr +spdlog::stdout_color_mt(const std::string &logger_name, + color_mode mode); +template SPDLOG_API std::shared_ptr +spdlog::stdout_color_st(const std::string &logger_name, + color_mode mode); +template SPDLOG_API std::shared_ptr +spdlog::stderr_color_mt(const std::string &logger_name, + color_mode mode); +template SPDLOG_API std::shared_ptr +spdlog::stderr_color_st(const std::string &logger_name, + color_mode mode); + +template SPDLOG_API std::shared_ptr spdlog::stdout_color_mt( + const std::string &logger_name, color_mode mode); +template SPDLOG_API std::shared_ptr spdlog::stdout_color_st( + const std::string &logger_name, color_mode mode); +template SPDLOG_API std::shared_ptr spdlog::stderr_color_mt( + const std::string &logger_name, color_mode mode); +template SPDLOG_API std::shared_ptr spdlog::stderr_color_st( + const std::string &logger_name, color_mode mode); diff --git a/deps/src/spdlog/file_sinks.cpp b/deps/src/spdlog/file_sinks.cpp new file mode 100644 index 0000000..7d70127 --- /dev/null +++ b/deps/src/spdlog/file_sinks.cpp @@ -0,0 +1,20 @@ +// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. +// Distributed under the MIT License (http://opensource.org/licenses/MIT) + +#ifndef SPDLOG_COMPILED_LIB + #error Please define SPDLOG_COMPILED_LIB to compile this file. +#endif + +#include +#include +#include +#include + +#include + +template class SPDLOG_API spdlog::sinks::basic_file_sink; +template class SPDLOG_API spdlog::sinks::basic_file_sink; + +#include +template class SPDLOG_API spdlog::sinks::rotating_file_sink; +template class SPDLOG_API spdlog::sinks::rotating_file_sink; diff --git a/deps/src/spdlog/spdlog.cpp b/deps/src/spdlog/spdlog.cpp new file mode 100644 index 0000000..1a2638a --- /dev/null +++ b/deps/src/spdlog/spdlog.cpp @@ -0,0 +1,28 @@ +// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. +// Distributed under the MIT License (http://opensource.org/licenses/MIT) + +#ifndef SPDLOG_COMPILED_LIB + #error Please define SPDLOG_COMPILED_LIB to compile this file. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +// template instantiate logger constructor with sinks init list +template SPDLOG_API spdlog::logger::logger(std::string name, + sinks_init_list::iterator begin, + sinks_init_list::iterator end); +template class SPDLOG_API spdlog::sinks::base_sink; +template class SPDLOG_API spdlog::sinks::base_sink; diff --git a/deps/src/spdlog/stdout_sinks.cpp b/deps/src/spdlog/stdout_sinks.cpp new file mode 100644 index 0000000..afd1837 --- /dev/null +++ b/deps/src/spdlog/stdout_sinks.cpp @@ -0,0 +1,37 @@ +// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. +// Distributed under the MIT License (http://opensource.org/licenses/MIT) + +#ifndef SPDLOG_COMPILED_LIB + #error Please define SPDLOG_COMPILED_LIB to compile this file. +#endif + +#include + +#include +#include +#include + +template class SPDLOG_API spdlog::sinks::stdout_sink_base; +template class SPDLOG_API spdlog::sinks::stdout_sink_base; +template class SPDLOG_API spdlog::sinks::stdout_sink; +template class SPDLOG_API spdlog::sinks::stdout_sink; +template class SPDLOG_API spdlog::sinks::stderr_sink; +template class SPDLOG_API spdlog::sinks::stderr_sink; + +template SPDLOG_API std::shared_ptr +spdlog::stdout_logger_mt(const std::string &logger_name); +template SPDLOG_API std::shared_ptr +spdlog::stdout_logger_st(const std::string &logger_name); +template SPDLOG_API std::shared_ptr +spdlog::stderr_logger_mt(const std::string &logger_name); +template SPDLOG_API std::shared_ptr +spdlog::stderr_logger_st(const std::string &logger_name); + +template SPDLOG_API std::shared_ptr spdlog::stdout_logger_mt( + const std::string &logger_name); +template SPDLOG_API std::shared_ptr spdlog::stdout_logger_st( + const std::string &logger_name); +template SPDLOG_API std::shared_ptr spdlog::stderr_logger_mt( + const std::string &logger_name); +template SPDLOG_API std::shared_ptr spdlog::stderr_logger_st( + const std::string &logger_name); -- cgit