diff --git a/CMakeLists.txt b/CMakeLists.txt index 412113e..f036069 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,8 @@ if(NOT DEFINED QT6_ROOT_DIR) message(FATAL_ERROR "QT6_ROOT_DIR is not defined. Please set the QT6_ROOT_DIR variable to the root directory of the Qt 6 installation.") endif() +option(TOON_BOOM_EXTENSION_FRAMEWORK_DEBUG "Enable debug output" ON) + include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) list(APPEND CMAKE_PREFIX_PATH ${QT6_ROOT_DIR}) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index dc05a7d..a7d0ffe 100644 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt @@ -19,6 +19,9 @@ list(FILTER FRAMEWORK_SOURCES EXCLUDE REGEX "/(out|build|cmake-build-|CMakeFiles file(COPY "${QT5_ROOT_DIR}/include/QtScript" DESTINATION ${CMAKE_BINARY_DIR}/include) find_package(minhook CONFIG REQUIRED) function(link_libs_and_set_properties target_name) + if(TOON_BOOM_EXTENSION_FRAMEWORK_DEBUG) + target_compile_definitions(${target_name} PUBLIC TB_EXT_FRAMEWORK_DEBUG=1) + endif() target_compile_features(${target_name} PUBLIC cxx_std_20) target_include_directories(${target_name} PUBLIC "${CMAKE_BINARY_DIR}/include") target_link_libraries(${target_name} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/QtScript.lib") diff --git a/framework/debug.cpp b/framework/debug.cpp new file mode 100644 index 0000000..5f551e9 --- /dev/null +++ b/framework/debug.cpp @@ -0,0 +1,5 @@ +#include "include/public/toon_boom/ext/util.hpp" + + std::ostream devnull(new NullBuffer()); + + std::ostream& out = TB_EXT_FRAMEWORK_DEBUG ? std::cout : devnull; diff --git a/framework/include/public/toon_boom/ext/util.hpp b/framework/include/public/toon_boom/ext/util.hpp index 3159b4a..3f9d826 100644 --- a/framework/include/public/toon_boom/ext/util.hpp +++ b/framework/include/public/toon_boom/ext/util.hpp @@ -1,7 +1,18 @@ #pragma once #include +#include +#include -std::string addrToHex(void* addr); +#if !defined(TB_EXT_FRAMEWORK_DEBUG) +#define TB_EXT_FRAMEWORK_DEBUG 0 +#endif +struct NullBuffer : std::streambuf { + int overflow(int c) { return c; } +}; -std::string constAddrToHex(const void* addr); \ No newline at end of file +std::string addrToHex(void *addr); + +std::string constAddrToHex(const void *addr); + +extern std::ostream &out;