From 23ab0eaa4869f8e2712a71d703e65b8358ea2d6f Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Sun, 29 Mar 2026 10:45:50 +0000 Subject: [PATCH] V1 Hotfix (#4) Reviewed-on: https://git.romainboullard.com/BigfootDev/Bin2CPP/pulls/4 Co-authored-by: Romain BOULLARD Co-committed-by: Romain BOULLARD --- .gitea/workflows/ci.yml | 2 +- Bin2CPP/Sources/Bin2CPPLib/Generator.cpp | 2 +- Bin2CPP/Sources/Bin2CPPLib/Include/Log.hpp | 14 ++++++++++---- Bin2CPP/Sources/Bin2CPPLib/Log.cpp | 2 ++ Bin2CPP/Tests/Bin2CPPLib/Generator.cpp | 12 +++--------- CMakeLists.txt | 2 +- ConanProfiles/clang | 2 +- ConanProfiles/clang_coverage | 4 ++-- ConanProfiles/clangd | 2 +- ConanProfiles/clangd_asan | 4 ++-- ConanProfiles/msvc | 2 +- ConanProfiles/msvcd | 2 +- ConanProfiles/msvcd_asan | 8 ++++---- 13 files changed, 30 insertions(+), 28 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 282b8d3..37328a1 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: - name: Build run: | - conan install . --remote=bigfootpackages -pr:h=${{ matrix.conan_profile }} -pr:b=${{ matrix.conan_profile }} --build=missing -s build_type=${{ matrix.build_type }} + conan install . --remote=bigfootpackages -pr:h=${{ matrix.conan_profile }} -pr:b=${{ matrix.conan_profile }} --build=missing -s build_type=${{ matrix.build_type }} -o bin2cpp/*:build_tests=True cmake -S . -B ./build/${{ matrix.build_type }} --toolchain ./build/${{ matrix.build_type }}/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_UNITY_BUILD=${{ matrix.unity_build }} -G "Ninja" cmake --build build/${{ matrix.build_type }} --parallel $(nproc) diff --git a/Bin2CPP/Sources/Bin2CPPLib/Generator.cpp b/Bin2CPP/Sources/Bin2CPPLib/Generator.cpp index 1b7e190..77ce323 100644 --- a/Bin2CPP/Sources/Bin2CPPLib/Generator.cpp +++ b/Bin2CPP/Sources/Bin2CPPLib/Generator.cpp @@ -139,7 +139,7 @@ bool Generator::ComputeMappings() bool Generator::ComputeFilename() { std::filesystem::path file {m_inputFile.data()}; - m_mappingTable[magic_enum::enum_index(MappingKey::FILENAME).value()] = file.filename().string().c_str(); + m_mappingTable[magic_enum::enum_index(MappingKey::FILENAME).value()] = file.filename().string(); return true; } diff --git a/Bin2CPP/Sources/Bin2CPPLib/Include/Log.hpp b/Bin2CPP/Sources/Bin2CPPLib/Include/Log.hpp index d9a3ab2..956b409 100644 --- a/Bin2CPP/Sources/Bin2CPPLib/Include/Log.hpp +++ b/Bin2CPP/Sources/Bin2CPPLib/Include/Log.hpp @@ -62,18 +62,24 @@ class Log #define BIN2CPP_LOG_DEBUG(fmt, ...) \ do \ { \ - if (quill::Logger* logger = Bin2CPP::Singleton::Instance().GetLogger()) \ + if (Bin2CPP::Singleton::HasInstance()) \ { \ - QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ + if (quill::Logger* logger = Bin2CPP::Singleton::Instance().GetLogger()) \ + { \ + QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ + } \ } \ } while (0) #define BIN2CPP_LOG_TRACE(fmt, ...) \ do \ { \ - if (quill::Logger* logger = Bin2CPP::Singleton::Instance().GetLogger()) \ + if (Bin2CPP::Singleton::HasInstance()) \ { \ - QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ + if (quill::Logger* logger = Bin2CPP::Singleton::Instance().GetLogger()) \ + { \ + QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \ + } \ } \ } while (0) diff --git a/Bin2CPP/Sources/Bin2CPPLib/Log.cpp b/Bin2CPP/Sources/Bin2CPPLib/Log.cpp index 525a093..fa02a3b 100644 --- a/Bin2CPP/Sources/Bin2CPPLib/Log.cpp +++ b/Bin2CPP/Sources/Bin2CPPLib/Log.cpp @@ -39,6 +39,8 @@ void Log::Flush() Log::~Log() { + Flush(); + for (quill::Logger* logger: quill::Frontend::get_all_loggers()) { quill::Frontend::remove_logger(logger); diff --git a/Bin2CPP/Tests/Bin2CPPLib/Generator.cpp b/Bin2CPP/Tests/Bin2CPPLib/Generator.cpp index 9823fc3..cb89089 100644 --- a/Bin2CPP/Tests/Bin2CPPLib/Generator.cpp +++ b/Bin2CPP/Tests/Bin2CPPLib/Generator.cpp @@ -39,9 +39,7 @@ TEST_F(GeneratorFixture, GenerateDefault) namespace { inline constexpr std::array g_toto_txt = { - std::byte{0x48}, std::byte{0x65}, std::byte{0x6C}, std::byte{0x6C}, std::byte{0x6F}, - std::byte{0x20}, std::byte{0x57}, std::byte{0x6F}, std::byte{0x72}, std::byte{0x6C}, - std::byte{0x64} + std::byte{0x48}, std::byte{0x65}, std::byte{0x6C}, std::byte{0x6C}, std::byte{0x6F}, std::byte{0x20}, std::byte{0x57}, std::byte{0x6F}, std::byte{0x72}, std::byte{0x6C}, std::byte{0x64} }; } // namespace @@ -73,9 +71,7 @@ TEST_F(GeneratorFixture, GenerateNamespace) namespace Test { inline constexpr std::array g_toto_txt = { - std::byte{0x48}, std::byte{0x65}, std::byte{0x6C}, std::byte{0x6C}, std::byte{0x6F}, - std::byte{0x20}, std::byte{0x57}, std::byte{0x6F}, std::byte{0x72}, std::byte{0x6C}, - std::byte{0x64} + std::byte{0x48}, std::byte{0x65}, std::byte{0x6C}, std::byte{0x6C}, std::byte{0x6F}, std::byte{0x20}, std::byte{0x57}, std::byte{0x6F}, std::byte{0x72}, std::byte{0x6C}, std::byte{0x64} }; } // namespace Test @@ -109,9 +105,7 @@ TEST_F(GeneratorFixture, GenerateCustomArray) namespace { inline constexpr eastl::array g_myArray = { - std::byte{0x48}, std::byte{0x65}, std::byte{0x6C}, std::byte{0x6C}, std::byte{0x6F}, - std::byte{0x20}, std::byte{0x57}, std::byte{0x6F}, std::byte{0x72}, std::byte{0x6C}, - std::byte{0x64} + std::byte{0x48}, std::byte{0x65}, std::byte{0x6C}, std::byte{0x6C}, std::byte{0x6F}, std::byte{0x20}, std::byte{0x57}, std::byte{0x6F}, std::byte{0x72}, std::byte{0x6C}, std::byte{0x64} }; } // namespace diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fd5e87..a0d6a8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.26) -project(Bin2CPP VERSION 0.1.0 +project(Bin2CPP VERSION 1.0.0 DESCRIPTION "Bin2CPP" LANGUAGES CXX) diff --git a/ConanProfiles/clang b/ConanProfiles/clang index 86ec4bf..372d0f3 100644 --- a/ConanProfiles/clang +++ b/ConanProfiles/clang @@ -29,4 +29,4 @@ tools.cmake.cmaketoolchain:generator=Ninja !cmake/*: cmake/[>=4.2] [options] -Bin2CPP/*:build_tests=True \ No newline at end of file +bin2cpp/*:build_tests=True diff --git a/ConanProfiles/clang_coverage b/ConanProfiles/clang_coverage index f536fd9..c0f9145 100644 --- a/ConanProfiles/clang_coverage +++ b/ConanProfiles/clang_coverage @@ -26,5 +26,5 @@ tools.build:compiler_executables={"c": "clang", "cpp": "clang++"} !cmake/*: cmake/[>=4.2] [options] -Bin2CPP/*:build_tests=True -Bin2CPP/*:coverage=True +bin2cpp/*:build_tests=True +bin2cpp/*:coverage=True diff --git a/ConanProfiles/clangd b/ConanProfiles/clangd index 0fa3339..9885de5 100644 --- a/ConanProfiles/clangd +++ b/ConanProfiles/clangd @@ -26,4 +26,4 @@ tools.build:compiler_executables={"c": "clang", "cpp": "clang++"} !cmake/*: cmake/[>=4.2] [options] -Bin2CPP/*:build_tests=True \ No newline at end of file +bin2cpp/*:build_tests=True diff --git a/ConanProfiles/clangd_asan b/ConanProfiles/clangd_asan index 9a8fc1e..9cf8200 100644 --- a/ConanProfiles/clangd_asan +++ b/ConanProfiles/clangd_asan @@ -29,5 +29,5 @@ tools.build:compiler_executables={"c": "clang", "cpp": "clang++"} !cmake/*: cmake/[>=4.2] [options] -Bin2CPP/*:asan=True -Bin2CPP/*:build_tests=True \ No newline at end of file +bin2cpp/*:asan=True +bin2cpp/*:build_tests=True diff --git a/ConanProfiles/msvc b/ConanProfiles/msvc index 0aafee5..abbaeed 100644 --- a/ConanProfiles/msvc +++ b/ConanProfiles/msvc @@ -21,4 +21,4 @@ tools.build:cxxflags=["/Zc:preprocessor", "/permissive-", "/Zc:__cplusplus", "/Z !cmake/*: cmake/[>=4.2] [options] -Bin2CPP/*:build_tests=True \ No newline at end of file +bin2cpp/*:build_tests=True diff --git a/ConanProfiles/msvcd b/ConanProfiles/msvcd index 9bdcd07..10afcdc 100644 --- a/ConanProfiles/msvcd +++ b/ConanProfiles/msvcd @@ -17,4 +17,4 @@ tools.build:cxxflags=["/Zc:preprocessor", "/permissive-", "/Zc:__cplusplus", "/Z !cmake/*: cmake/[>=4.2] [options] -Bin2CPP/*:build_tests=True +bin2cpp/*:build_tests=True diff --git a/ConanProfiles/msvcd_asan b/ConanProfiles/msvcd_asan index d9bb8af..2b8cdca 100644 --- a/ConanProfiles/msvcd_asan +++ b/ConanProfiles/msvcd_asan @@ -14,12 +14,12 @@ tools.cmake.cmaketoolchain:user_toolchain+={{profile_dir}}/msvc_ccache.cmake tools.build:exelinkflags=["/INCREMENTAL:NO"] tools.build:sharedlinkflags=["/INCREMENTAL:NO"] -tools.build:cflags=["/Zc:preprocessor", "/Zc:__STDC__", "/D_CRT_DECLARE_NONSTDC_NAMES=1"] -tools.build:cxxflags=["/Zc:preprocessor", "/permissive-", "/Zc:__cplusplus", "/Zc:enumTypes", "/Zc:templateScope", "/Zc:throwingNew"] +tools.build:cflags=["/Zc:preprocessor", "/Zc:__STDC__", "/D_CRT_DECLARE_NONSTDC_NAMES=1", "/fsanitize=address"] +tools.build:cxxflags=["/Zc:preprocessor", "/permissive-", "/Zc:__cplusplus", "/Zc:enumTypes", "/Zc:templateScope", "/Zc:throwingNew", "/fsanitize=address"] [tool_requires] !cmake/*: cmake/[>=4.2] [options] -Bin2CPP/*:asan=True -Bin2CPP/*:build_tests=True +bin2cpp/*:asan=True +bin2cpp/*:build_tests=True