Compare commits
5 Commits
b05c6aa5c9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 00f512d7b1 | |||
| 8a3df93a3f | |||
| 23ab0eaa48 | |||
| 554bdcad92 | |||
| f727e2f1ed |
@@ -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)
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Bin2CPPCompileAndLinkFlags
|
||||
PUBLIC
|
||||
$<IF:$<BOOL:${ASAN}>,mimalloc-asan,mimalloc-static>
|
||||
quill::quill
|
||||
$<$<CONFIG:Debug,RelWithDebInfo>:cpptrace::cpptrace>
|
||||
magic_enum::magic_enum)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -62,18 +62,24 @@ class Log
|
||||
#define BIN2CPP_LOG_DEBUG(fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
|
||||
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
|
||||
{ \
|
||||
QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::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<Bin2CPP::Log>::Instance().GetLogger()) \
|
||||
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
|
||||
{ \
|
||||
QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
|
||||
{ \
|
||||
QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ void Log::Flush()
|
||||
|
||||
Log::~Log()
|
||||
{
|
||||
Flush();
|
||||
|
||||
for (quill::Logger* logger: quill::Frontend::get_all_loggers())
|
||||
{
|
||||
quill::Frontend::remove_logger(logger);
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
/*********************************************************************
|
||||
* \file MimallocImpl.cpp
|
||||
*
|
||||
* \author Romain BOULLARD
|
||||
* \date February 2026
|
||||
*********************************************************************/
|
||||
#if defined BIN2CPP_WINDOWS
|
||||
#pragma comment(linker, "/include:mi_version")
|
||||
#pragma warning(disable: 4100 4559)
|
||||
#elif defined BIN2CPP_LINUX
|
||||
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#else
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Taken from mimalloc-new-delete.h
|
||||
|
||||
// clang-format off
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// This header provides convenient overrides for the new and
|
||||
// delete operations in C++.
|
||||
//
|
||||
// This header should be included in only one source file!
|
||||
//
|
||||
// On Windows, or when linking dynamically with mimalloc, these
|
||||
// can be more performant than the standard new-delete operations.
|
||||
// See <https://en.cppreference.com/w/cpp/memory/new/operator_new>
|
||||
// ---------------------------------------------------------------------------
|
||||
#if defined(__cplusplus)
|
||||
#include <new>
|
||||
#include <mimalloc.h>
|
||||
|
||||
#if defined(_MSC_VER) && defined(_Ret_notnull_) && defined(_Post_writable_byte_size_)
|
||||
// stay consistent with VCRT definitions
|
||||
#define mi_decl_new(n) mi_decl_nodiscard mi_decl_restrict _Ret_notnull_ _Post_writable_byte_size_(n)
|
||||
#define mi_decl_new_nothrow(n) mi_decl_nodiscard mi_decl_restrict _Ret_maybenull_ _Success_(return != NULL) _Post_writable_byte_size_(n)
|
||||
#else
|
||||
#define mi_decl_new(n) mi_decl_nodiscard mi_decl_restrict
|
||||
#define mi_decl_new_nothrow(n) mi_decl_nodiscard mi_decl_restrict
|
||||
#endif
|
||||
|
||||
void operator delete(void* p) noexcept { mi_free(p); };
|
||||
void operator delete[](void* p) noexcept { mi_free(p); };
|
||||
|
||||
void operator delete (void* p, const std::nothrow_t&) noexcept { mi_free(p); }
|
||||
void operator delete[](void* p, const std::nothrow_t&) noexcept { mi_free(p); }
|
||||
|
||||
mi_decl_new(n) void* operator new(std::size_t n) noexcept(false) { return mi_new(n); }
|
||||
mi_decl_new(n) void* operator new[](std::size_t n) noexcept(false) { return mi_new(n); }
|
||||
|
||||
mi_decl_new_nothrow(n) void* operator new (std::size_t n, const std::nothrow_t& tag) noexcept { (void)(tag); return mi_new_nothrow(n); }
|
||||
mi_decl_new_nothrow(n) void* operator new[](std::size_t n, const std::nothrow_t& tag) noexcept { (void)(tag); return mi_new_nothrow(n); }
|
||||
|
||||
// Not from mimalloc-new-delete.h, but necessary for EASTL
|
||||
void* operator new[](size_t size, const char* name, int flags, unsigned debugFlags, const char* file, int line) noexcept(false) { return mi_new(size); }
|
||||
|
||||
#if (__cplusplus >= 201402L || _MSC_VER >= 1916)
|
||||
void operator delete (void* p, std::size_t n) noexcept { mi_free_size(p,n); };
|
||||
void operator delete[](void* p, std::size_t n) noexcept { mi_free_size(p,n); };
|
||||
#endif
|
||||
|
||||
#if (__cplusplus > 201402L || defined(__cpp_aligned_new))
|
||||
void operator delete (void* p, std::align_val_t al) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); }
|
||||
void operator delete[](void* p, std::align_val_t al) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); }
|
||||
void operator delete (void* p, std::size_t n, std::align_val_t al) noexcept { mi_free_size_aligned(p, n, static_cast<size_t>(al)); };
|
||||
void operator delete[](void* p, std::size_t n, std::align_val_t al) noexcept { mi_free_size_aligned(p, n, static_cast<size_t>(al)); };
|
||||
void operator delete (void* p, std::align_val_t al, const std::nothrow_t&) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); }
|
||||
void operator delete[](void* p, std::align_val_t al, const std::nothrow_t&) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); }
|
||||
|
||||
void* operator new (std::size_t n, std::align_val_t al) noexcept(false) { return mi_new_aligned(n, static_cast<size_t>(al)); }
|
||||
void* operator new[](std::size_t n, std::align_val_t al) noexcept(false) { return mi_new_aligned(n, static_cast<size_t>(al)); }
|
||||
void* operator new (std::size_t n, std::align_val_t al, const std::nothrow_t&) noexcept { return mi_new_aligned_nothrow(n, static_cast<size_t>(al)); }
|
||||
void* operator new[](std::size_t n, std::align_val_t al, const std::nothrow_t&) noexcept { return mi_new_aligned_nothrow(n, static_cast<size_t>(al)); }
|
||||
|
||||
// Not from mimalloc-new-delete.h, but necessary for EASTL
|
||||
void* operator new[](size_t size, size_t alignment, size_t alignmentOffset, const char* pName, int flags, unsigned debugFlags, const char* file, int line) noexcept(false) { return mi_new_aligned(size, alignment); }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
|
||||
#if defined BIN2CPP_WINDOWS
|
||||
#pragma warning(default: 4100 4559)
|
||||
#elif defined BIN2CPP_LINUX
|
||||
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER)
|
||||
#pragma GCC diagnostic pop
|
||||
#else
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
@@ -39,9 +39,7 @@ TEST_F(GeneratorFixture, GenerateDefault)
|
||||
namespace
|
||||
{
|
||||
inline constexpr std::array<std::byte, 11> 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<std::byte, 11> 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<std::byte, 11> 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
|
||||
|
||||
@@ -9,12 +9,6 @@ find_package(magic_enum REQUIRED)
|
||||
find_package(CLI11 REQUIRED)
|
||||
find_package(quill REQUIRED)
|
||||
|
||||
if(${ASAN})
|
||||
find_package(mimalloc-asan REQUIRED)
|
||||
else()
|
||||
find_package(mimalloc REQUIRED)
|
||||
endif()
|
||||
|
||||
find_package(cpptrace REQUIRED)
|
||||
|
||||
if(BUILD_TESTS)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -29,4 +29,4 @@ tools.cmake.cmaketoolchain:generator=Ninja
|
||||
!cmake/*: cmake/[>=4.2]
|
||||
|
||||
[options]
|
||||
Bin2CPP/*:build_tests=True
|
||||
bin2cpp/*:build_tests=True
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -26,4 +26,4 @@ tools.build:compiler_executables={"c": "clang", "cpp": "clang++"}
|
||||
!cmake/*: cmake/[>=4.2]
|
||||
|
||||
[options]
|
||||
Bin2CPP/*:build_tests=True
|
||||
bin2cpp/*:build_tests=True
|
||||
|
||||
@@ -29,5 +29,5 @@ tools.build:compiler_executables={"c": "clang", "cpp": "clang++"}
|
||||
!cmake/*: cmake/[>=4.2]
|
||||
|
||||
[options]
|
||||
Bin2CPP/*:asan=True
|
||||
Bin2CPP/*:build_tests=True
|
||||
bin2cpp/*:asan=True
|
||||
bin2cpp/*:build_tests=True
|
||||
|
||||
@@ -21,4 +21,4 @@ tools.build:cxxflags=["/Zc:preprocessor", "/permissive-", "/Zc:__cplusplus", "/Z
|
||||
!cmake/*: cmake/[>=4.2]
|
||||
|
||||
[options]
|
||||
Bin2CPP/*:build_tests=True
|
||||
bin2cpp/*:build_tests=True
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -45,13 +45,9 @@ class Bin2CPP(ConanFile):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
|
||||
if(self.options.asan):
|
||||
self.options["mimalloc"].asan = True
|
||||
|
||||
def requirements(self):
|
||||
self.requires("quill/11.0.2", transitive_headers=True)
|
||||
self.requires("magic_enum/0.9.7", transitive_headers=True)
|
||||
self.requires("mimalloc/3.2.8@bigfootdev/main", transitive_headers=True)
|
||||
self.requires("cli11/2.6.1@bigfootdev/main")
|
||||
|
||||
self.requires("cpptrace/1.0.4", transitive_headers=True)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
sonar.projectKey=Bin2CPP
|
||||
|
||||
sonar.projectVersion=0.1.0
|
||||
sonar.projectVersion=1.0.0
|
||||
|
||||
sonar.sourceEncoding=UTF-8
|
||||
|
||||
|
||||
Reference in New Issue
Block a user