From de2cc2563924ea27e732b770de5bfe3e381f0796 Mon Sep 17 00:00:00 2001 From: nxtum <94901881+nxtum@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:21:40 +0200 Subject: [PATCH] Added buildinfo method (build flags) for QA report (#1712) * Added buildinfo method for QA report * Added public compilesettings * Updated Controller.cpp from seb comments * Updated CMakeLists.txt in core * added priv compilesettings * Added threadcount to buildinfo * Added unused variable macro * systemtype and universal build flags * enum extensions * spelling * empty commit to test action * shortened namespaces and whitespace * extra line --------- Co-authored-by: Pierre Wielders --- Source/Thunder/CMakeLists.txt | 1 + Source/Thunder/Controller.cpp | 83 ++++++++++++++++++++++++++++++ Source/Thunder/Controller.h | 1 + Source/Thunder/PluginServer.h | 4 +- Source/Thunder/Probe.cpp | 2 +- Source/plugins/IController.h | 39 ++++++++++++++ cmake/common/CompileSettings.cmake | 2 + 7 files changed, 129 insertions(+), 3 deletions(-) diff --git a/Source/Thunder/CMakeLists.txt b/Source/Thunder/CMakeLists.txt index fb3c0cdf8..4b52c9026 100644 --- a/Source/Thunder/CMakeLists.txt +++ b/Source/Thunder/CMakeLists.txt @@ -60,6 +60,7 @@ endif() target_link_libraries(${TARGET} PRIVATE + CompileSettings::CompileSettings CompileSettingsDebug::CompileSettingsDebug ${NAMESPACE}Core::${NAMESPACE}Core ${NAMESPACE}Cryptalgo::${NAMESPACE}Cryptalgo diff --git a/Source/Thunder/Controller.cpp b/Source/Thunder/Controller.cpp index 3103fd239..d66ea2baa 100644 --- a/Source/Thunder/Controller.cpp +++ b/Source/Thunder/Controller.cpp @@ -1363,5 +1363,88 @@ namespace Plugin { // also notify the JSON RPC listeners (if any) Exchange::Controller::JLifeTime::Event::StateChange(*this, callsign, state, reason); } + + Core::hresult Controller::BuildInfo(IMetadata::Data::BuildInfo& buildInfo) const + { + #if defined(__WINDOWS__) + buildInfo.SystemType = IMetadata::Data::BuildInfo::SYSTEM_WINDOWS; + #elif defined(__LINUX__) + buildInfo.SystemType = IMetadata::Data::BuildInfo::SYSTEM_LINUX; + #elif defined(__APPLE__) + buildInfo.SystemType = IMetadata::Data::BuildInfo::SYSTEM_MACOS; + #else + #error No system type detected + #endif + + #if defined(__DEBUG__) + #if defined(_THUNDER_DEBUG_OPTIMIZED_) + buildInfo.BuildType = IMetadata::Data::BuildInfo::DEBUG_OPTIMIZED; + #else + buildInfo.BuildType = IMetadata::Data::BuildInfo::DEBUG; + #endif + #else // !__DEBUG__ + #if defined(_THUNDER_NDEBUG_DEB_INFO) + buildInfo.BuildType = IMetadata::Data::BuildInfo::RELEASE_WITH_DEBUG_INFO; + #elif defined(_THUNDER_PRODUCTION) + buildInfo.BuildType = IMetadata::Data::BuildInfo::PRODUCTION; + #else + buildInfo.BuildType = IMetadata::Data::BuildInfo::RELEASE; + #endif + #endif + + #ifdef _TRACE_LEVEL + buildInfo.TraceLevel = _TRACE_LEVEL; + #endif + + uint8_t extensions = 0; + #ifdef __CORE_WARNING_REPORTING__ + extensions |= IMetadata::Data::BuildInfo::WARNING_REPORTING; + #endif + #ifdef __CORE_BLUETOOTH_SUPPORT__ + extensions |= IMetadata::Data::BuildInfo::BLUETOOTH; + #endif + #ifdef HIBERNATE_SUPPORT_ENABLED + extensions |= IMetadata::Data::BuildInfo::HIBERNATE; + #endif + #ifdef PROCESSCONTAINERS_ENABLED + extensions |= IMetadata::Data::BuildInfo::PROCESS_CONTAINERS; + #endif + + if (extensions != 0) { + buildInfo.Extensions = static_cast(extensions); + } + + #ifdef __CORE_MESSAGING__ + buildInfo.Messaging = true; + #else + buildInfo.Messaging= false; + #endif + + #ifdef __CORE_EXCEPTION_CATCHING__ + buildInfo.ExceptionCatching = true; + #else + buildInfo.ExceptionCatching = false; + #endif + + buildInfo.InstanceIDBits = (sizeof(Core::instance_id) * 8); + + #ifdef __CORE_CRITICAL_SECTION_LOG__ + buildInfo.DeadlockDetection = true; + #else + buildInfo.DeadlockDetection = false; + #endif + + #ifdef __CORE_NO_WCHAR_SUPPORT__ + buildInfo.WCharSupport = false; + #else + buildInfo.WCharSupport = true; + #endif + + #ifdef THREADPOOL_COUNT + buildInfo.ThreadPoolCount = THREADPOOL_COUNT; + #endif + + return (Core::ERROR_NONE); + } } } diff --git a/Source/Thunder/Controller.h b/Source/Thunder/Controller.h index bf026583a..bd7ed365a 100644 --- a/Source/Thunder/Controller.h +++ b/Source/Thunder/Controller.h @@ -330,6 +330,7 @@ namespace Plugin { Core::hresult Threads(IMetadata::Data::IThreadsIterator*& threads) const override; Core::hresult PendingRequests(IMetadata::Data::IPendingRequestsIterator*& requests) const override; Core::hresult Version(IMetadata::Data::Version& version) const override; + Core::hresult BuildInfo(IMetadata::Data::BuildInfo& buildInfo) const override; // IShells overrides Core::hresult Register(Exchange::Controller::IShells::INotification* sink) override; diff --git a/Source/Thunder/PluginServer.h b/Source/Thunder/PluginServer.h index eb9bab386..905639a9c 100644 --- a/Source/Thunder/PluginServer.h +++ b/Source/Thunder/PluginServer.h @@ -4184,7 +4184,7 @@ namespace PluginHost { } } } - void Send(const Core::ProxyType& response) override + void Send(const Core::ProxyType& response VARIABLE_IS_NOT_USED) override { if (_requestClose == true) { PluginHost::Channel::Close(0); @@ -4209,7 +4209,7 @@ namespace PluginHost { return (result); } - void Send(const Core::ProxyType& element) override + void Send(const Core::ProxyType& element VARIABLE_IS_NOT_USED) override { TRACE(SocketFlow, (element)); } diff --git a/Source/Thunder/Probe.cpp b/Source/Thunder/Probe.cpp index 18bfa149d..5c4d61037 100644 --- a/Source/Thunder/Probe.cpp +++ b/Source/Thunder/Probe.cpp @@ -174,7 +174,7 @@ namespace Plugin { } // Notification of a Response send. - /* virtual */ void Probe::Listener::Send(const Core::ProxyType& response) + /* virtual */ void Probe::Listener::Send(const Core::ProxyType& response VARIABLE_IS_NOT_USED) { TRACE(Discovery, (response, _destinations.front()._destination)); diff --git a/Source/plugins/IController.h b/Source/plugins/IController.h index 6ce91cbdc..47c1d705e 100644 --- a/Source/plugins/IController.h +++ b/Source/plugins/IController.h @@ -227,6 +227,41 @@ namespace Controller { uint8_t Patch /* @brief Patch number */; }; + struct BuildInfo { + + enum systemtype : uint8_t { + SYSTEM_WINDOWS /* @text:Windows */, + SYSTEM_LINUX /* @text:Linux */, + SYSTEM_MACOS /* @text:MacOS */ + }; + + enum buildtype : uint8_t { + DEBUG, + DEBUG_OPTIMIZED, + RELEASE_WITH_DEBUG_INFO, + RELEASE, + PRODUCTION + }; + + enum extensiontype : uint8_t { + WARNING_REPORTING = 1, + BLUETOOTH = 2, + HIBERBATE = 4, + PROCESS_CONTAINERS = 8 + }; + + systemtype SystemType /* @brief System type */; + buildtype BuildType /* @brief Build type */; + Core::OptionalType Extensions /* @bitmask */; + bool Messaging /* @brief Denotes whether Messaging is enabled*/; + bool ExceptionCatching /* @brief Denotes whether there is an exception */; + bool DeadlockDetection /* @brief Denotes whether deadlock detection is enabled */; + bool WCharSupport /* Denotes whether there is wchar support */; + uint8_t InstanceIDBits /* @brief Core instance bits */; + Core::OptionalType TraceLevel /* @brief Trace level */; + uint8_t ThreadPoolCount /* Number of configured threads on the threadpool */; + }; + struct CallStack { Core::instance_id Address /* @brief Memory address */; string Module /* @brief Module name */; @@ -341,6 +376,10 @@ namespace Controller { // @property // @brief Thread callstack virtual Core::hresult CallStack(const uint8_t thread /* @index */, Data::ICallStackIterator*& callstack /* @out */) const = 0; + + // @property + // @brief Build information + virtual Core::hresult BuildInfo(Data::BuildInfo& buildInfo /* @out */) const = 0; }; } // namespace Controller diff --git a/cmake/common/CompileSettings.cmake b/cmake/common/CompileSettings.cmake index c3943bacc..c7861393e 100644 --- a/cmake/common/CompileSettings.cmake +++ b/cmake/common/CompileSettings.cmake @@ -79,12 +79,14 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") elseif("${CMAKE_BUILD_TYPE}" STREQUAL "DebugOptimized") target_compile_definitions(CompileSettings INTERFACE _THUNDER_DEBUG) + target_compile_definitions(CompileSettings INTERFACE _THUNDER_DEBUG_OPTIMIZED) target_compile_definitions(CompileSettings INTERFACE _THUNDER_CALLSTACK_INFO) target_compile_options(CompileSettings INTERFACE -funwind-tables) set(CONFIG_DIR "DebugOptimized" CACHE STRING "Build config directory" FORCE) elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") target_compile_definitions(CompileSettings INTERFACE _THUNDER_NDEBUG) + target_compile_definitions(CompileSettings INTERFACE _THUNDER_NDEBUG_DEB_INFO) target_compile_definitions(CompileSettings INTERFACE _THUNDER_CALLSTACK_INFO) target_compile_options(CompileSettings INTERFACE -funwind-tables) set(CONFIG_DIR "RelWithDebInfo" CACHE STRING "Build config directory" FORCE)