refactor(framework): create debug output ostream that redirects to a null stream if TB_EXT_FRAMEWORK_DEBUG isn't defined or is set to 0
This commit is contained in:
parent
d7ee745205
commit
b6df1547e2
@ -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.")
|
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()
|
endif()
|
||||||
|
|
||||||
|
option(TOON_BOOM_EXTENSION_FRAMEWORK_DEBUG "Enable debug output" ON)
|
||||||
|
|
||||||
include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
|
include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
|
||||||
list(APPEND CMAKE_PREFIX_PATH ${QT6_ROOT_DIR})
|
list(APPEND CMAKE_PREFIX_PATH ${QT6_ROOT_DIR})
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
||||||
|
|||||||
@ -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)
|
file(COPY "${QT5_ROOT_DIR}/include/QtScript" DESTINATION ${CMAKE_BINARY_DIR}/include)
|
||||||
find_package(minhook CONFIG REQUIRED)
|
find_package(minhook CONFIG REQUIRED)
|
||||||
function(link_libs_and_set_properties target_name)
|
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_compile_features(${target_name} PUBLIC cxx_std_20)
|
||||||
target_include_directories(${target_name} PUBLIC "${CMAKE_BINARY_DIR}/include")
|
target_include_directories(${target_name} PUBLIC "${CMAKE_BINARY_DIR}/include")
|
||||||
target_link_libraries(${target_name} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/QtScript.lib")
|
target_link_libraries(${target_name} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/QtScript.lib")
|
||||||
|
|||||||
5
framework/debug.cpp
Normal file
5
framework/debug.cpp
Normal file
@ -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;
|
||||||
@ -1,7 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <format>
|
#include <format>
|
||||||
|
#include <iostream>
|
||||||
|
#include <streambuf>
|
||||||
|
|
||||||
|
#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 addrToHex(void *addr);
|
std::string addrToHex(void *addr);
|
||||||
|
|
||||||
std::string constAddrToHex(const void *addr);
|
std::string constAddrToHex(const void *addr);
|
||||||
|
|
||||||
|
extern std::ostream &out;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user