Skip to content

Commit

Permalink
chore: remove fmt usage (#54)
Browse files Browse the repository at this point in the history
ongoing work to remove fmt usage in the project
needs to be tested in cmake and vcpkg
  • Loading branch information
qudix authored Sep 15, 2023
1 parent faf5067 commit a381cb6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CommonLibSF/include/RE/F/FormTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ namespace std
}
}

#ifdef FMT_VERSION
namespace fmt
{
template <>
Expand All @@ -253,6 +254,7 @@ namespace fmt
}
};
}
#endif

#ifdef __cpp_lib_format
namespace std
Expand Down
8 changes: 5 additions & 3 deletions CommonLibSF/include/SFSE/Impl/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
static_assert(std::is_integral_v<std::time_t> && sizeof(std::time_t) == sizeof(std::size_t), "wrap std::time_t instead");

#pragma warning(push)
#include <fmt/format.h>
#ifndef SPDLOG_USE_STD_FORMAT
#define SPDLOG_USE_STD_FORMAT
#endif
#include <spdlog/spdlog.h>
#pragma warning(pop)

Expand All @@ -69,7 +71,7 @@ static_assert(std::is_integral_v<std::time_t> && sizeof(std::time_t) == sizeof(s
#define stl_assert(cond, ...) \
{ \
if (!((cond))) { \
SFSE::stl::report_and_fail(fmt::format(__VA_ARGS__)); \
SFSE::stl::report_and_fail(std::format(__VA_ARGS__)); \
} \
}

Expand Down Expand Up @@ -574,7 +576,7 @@ namespace SFSE
filename = matches[1].str();
}

return utf8_to_utf16(fmt::format("{}({}): {}"sv, filename, a_loc.line(), a_msg)).value_or(L"<character encoding error>"s);
return utf8_to_utf16(std::format("{}({}): {}"sv, filename, a_loc.line(), a_msg)).value_or(L"<character encoding error>"s);
}();

const auto caption = []() {
Expand Down
4 changes: 2 additions & 2 deletions CommonLibSF/include/SFSE/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
{ \
a_func() = delete; \
\
explicit a_func(fmt::format_string<Args...> a_fmt, Args&&... a_args, std::source_location a_loc = std::source_location::current()) { spdlog::log(spdlog::source_loc{ a_loc.file_name(), static_cast<int>(a_loc.line()), a_loc.function_name() }, spdlog::level::a_type, a_fmt, std::forward<Args>(a_args)...); } \
explicit a_func(std::format_string<Args...> a_fmt, Args&&... a_args, std::source_location a_loc = std::source_location::current()) { spdlog::log(spdlog::source_loc{ a_loc.file_name(), static_cast<int>(a_loc.line()), a_loc.function_name() }, spdlog::level::a_type, a_fmt, std::forward<Args>(a_args)...); } \
}; \
\
template <class... Args> \
a_func(fmt::format_string<Args...>, Args&&...) -> a_func<Args...>;
a_func(std::format_string<Args...>, Args&&...) -> a_func<Args...>;

namespace SFSE::log
{
Expand Down
1 change: 0 additions & 1 deletion CommonLibSF/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"name": "vcpkg-cmake-config",
"host": true
},
"fmt",
"spdlog",
"xbyak"
]
Expand Down
2 changes: 1 addition & 1 deletion CommonLibSF/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ target("commonlibsf")
set_kind("static")

-- add packages
add_packages("fmt", "spdlog", { public = true })
add_packages("spdlog", { public = true })

if has_config("sfse_xbyak") then
add_packages("xbyak")
Expand Down
4 changes: 2 additions & 2 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ set_encodings("utf-8")
add_rules("mode.debug", "mode.release")

-- require packages
add_requires("fmt", "xbyak")
add_requires("spdlog", { configs = { header_only = false, fmt_external = true } })
add_requires("xbyak")
add_requires("spdlog", { configs = { header_only = false, std_format = true } })

-- include subprojects
includes("CommonLibSF")

0 comments on commit a381cb6

Please sign in to comment.