diff --git a/cmake/macros/AddBugSplat.cmake b/cmake/macros/AddBugSplat.cmake new file mode 100644 index 0000000000..979dcfe817 --- /dev/null +++ b/cmake/macros/AddBugSplat.cmake @@ -0,0 +1,34 @@ +# +# AddBugSplat.cmake +# cmake/macros +# +# Created by Ryan Huffman on 02/09/16. +# Copyright 2016 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html +# + +macro(add_bugsplat) + get_property(BUGSPLAT_CHECKED GLOBAL PROPERTY CHECKED_FOR_BUGSPLAT_ONCE) + + if (NOT BUGSPLAT_CHECKED) + find_package(BugSplat) + set_property(GLOBAL PROPERTY CHECKED_FOR_BUGSPLAT_ONCE TRUE) + endif () + + if (BUGSPLAT_FOUND) + add_definitions(-DHAS_BUGSPLAT) + + target_include_directories(${TARGET_NAME} PRIVATE ${BUGSPLAT_INCLUDE_DIRS}) + target_link_libraries(${TARGET_NAME} ${BUGSPLAT_LIBRARIES}) + add_paths_to_fixup_libs(${BUGSPLAT_DLL_PATH}) + + add_custom_command(TARGET ${TARGET_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${BUGSPLAT_RC_DLL_PATH} "$/") + add_custom_command(TARGET ${TARGET_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${BUGSPLAT_EXE_PATH} "$/") + endif () +endmacro() diff --git a/cmake/modules/FindBugSplat.cmake b/cmake/modules/FindBugSplat.cmake new file mode 100644 index 0000000000..8bea1cb1e1 --- /dev/null +++ b/cmake/modules/FindBugSplat.cmake @@ -0,0 +1,30 @@ +# +# FindBugSplat.cmake +# cmake/modules +# +# Created by Ryan Huffman on 02/09/16. +# Copyright 2016 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html +# + +if (WIN32) + include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") + hifi_library_search_hints("BugSplat") + + find_path(BUGSPLAT_INCLUDE_DIRS NAMES BugSplat.h PATH_SUFFIXES inc HINTS ${BUGSPLAT_SEARCH_DIRS}) + + find_library(BUGSPLAT_LIBRARY_RELEASE "BugSplat64.lib" PATH_SUFFIXES "lib64" HINTS ${BUGSPLAT_SEARCH_DIRS}) + find_path(BUGSPLAT_DLL_PATH NAMES "BugSplat64.dll" PATH_SUFFIXES "bin64" HINTS ${BUGSPLAT_SEARCH_DIRS}) + find_file(BUGSPLAT_RC_DLL_PATH NAMES "BugSplatRc64.dll" PATH_SUFFIXES "bin64" HINTS ${BUGSPLAT_SEARCH_DIRS}) + find_file(BUGSPLAT_EXE_PATH NAMES "BsSndRpt64.exe" PATH_SUFFIXES "bin64" HINTS ${BUGSPLAT_SEARCH_DIRS}) + + include(SelectLibraryConfigurations) + select_library_configurations(BUGSPLAT) + + set(BUGSPLAT_LIBRARIES ${BUGSPLAT_LIBRARY_RELEASE}) +endif () + +set(BUGSPLAT_REQUIREMENTS BUGSPLAT_INCLUDE_DIRS BUGSPLAT_LIBRARIES BUGSPLAT_DLL_PATH BUGSPLAT_RC_DLL_PATH BUGSPLAT_EXE_PATH) +find_package_handle_standard_args(BugSplat DEFAULT_MSG ${BUGSPLAT_REQUIREMENTS}) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index b4ce53b92a..b398778db7 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -261,6 +261,8 @@ if (SCRIPTS_INSTALL_DIR) ) endif() +add_bugsplat() + if (WIN32) set(EXTRA_DEPLOY_OPTIONS "--qmldir ${PROJECT_SOURCE_DIR}/resources/qml") diff --git a/interface/src/main.cpp b/interface/src/main.cpp index a57e53b384..f45a6c08b9 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -25,8 +25,23 @@ #include "InterfaceLogging.h" #include "MainWindow.h" +#ifdef HAS_BUGSPLAT +#include +#include +#endif + int main(int argc, const char* argv[]) { disableQtBearerPoll(); // Fixes wifi ping spikes + +#if HAS_BUGSPLAT + // Prevent other threads from hijacking the Exception filter, and allocate 4MB up-front that may be useful in + // low-memory scenarios. + static const DWORD BUG_SPLAT_FLAGS = MDSF_PREVENTHIJACKING | MDSF_USEGUARDMEMORY; + static const char* BUG_SPLAT_DATABASE = "interface_alpha"; + static const char* BUG_SPLAT_APPLICATION_NAME = "Interface"; + MiniDmpSender mpSender { BUG_SPLAT_DATABASE, BUG_SPLAT_APPLICATION_NAME, BuildInfo::VERSION.toLatin1().constData(), + nullptr, BUG_SPLAT_FLAGS }; +#endif QString applicationName = "High Fidelity Interface - " + qgetenv("USERNAME");