mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-27 12:52:07 +00:00
feature merge mac sentry to win platform.
This commit is contained in:
@@ -543,7 +543,12 @@ find_package(TBB REQUIRED)
|
|||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
find_package(CURL REQUIRED)
|
find_package(CURL REQUIRED)
|
||||||
if (SLIC3R_SENTRY)
|
if (SLIC3R_SENTRY)
|
||||||
find_package(Sentry REQUIRED)
|
find_package(Sentry QUIET)
|
||||||
|
if (NOT Sentry_FOUND)
|
||||||
|
message(WARNING "Sentry SDK not found. SLIC3R_SENTRY will be disabled. "
|
||||||
|
"Build deps with Sentry support or use -DSLIC3R_SENTRY=OFF")
|
||||||
|
set(SLIC3R_SENTRY OFF CACHE BOOL "Enable Sentry crash reporting SDK" FORCE)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
find_package(Freetype REQUIRED)
|
find_package(Freetype REQUIRED)
|
||||||
|
|
||||||
@@ -569,7 +574,17 @@ if (SLIC3R_SENTRY)
|
|||||||
else()
|
else()
|
||||||
message(WARNING "sentry.lib not found in ${CMAKE_PREFIX_PATH}/lib. Sentry SDK may not have been built yet.")
|
message(WARNING "sentry.lib not found in ${CMAKE_PREFIX_PATH}/lib. Sentry SDK may not have been built yet.")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
elseif (APPLE AND CMAKE_PREFIX_PATH)
|
||||||
|
# Try to find libsentry.dylib in the install prefix for macOS
|
||||||
|
file(GLOB _sentry_lib "${CMAKE_PREFIX_PATH}/lib/libsentry.dylib")
|
||||||
|
if (_sentry_lib)
|
||||||
|
target_link_directories(sentry INTERFACE "${CMAKE_PREFIX_PATH}/lib")
|
||||||
|
target_link_libraries(sentry INTERFACE "sentry")
|
||||||
|
message(STATUS "Found libsentry.dylib at: ${CMAKE_PREFIX_PATH}/lib")
|
||||||
|
else()
|
||||||
|
message(WARNING "libsentry.dylib not found in ${CMAKE_PREFIX_PATH}/lib. Sentry SDK may not have been built yet.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Fixing curl's cmake config script bugs
|
# Fixing curl's cmake config script bugs
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ if "%1"=="slicer" (
|
|||||||
echo "building deps.."
|
echo "building deps.."
|
||||||
|
|
||||||
echo on
|
echo on
|
||||||
cmake ../ -G "Visual Studio 17 2022" -A x64 -DDESTDIR="%DEPS%" -DCMAKE_BUILD_TYPE=%build_type% -DDEP_DEBUG=%debug% -DORCA_INCLUDE_DEBUG_INFO=%debuginfo%
|
cmake ../ -G "Visual Studio 17 2022" -A x64 -DDESTDIR="%DEPS%" -DCMAKE_BUILD_TYPE=%build_type% -DDEP_DEBUG=%debug% -DORCA_INCLUDE_DEBUG_INFO=%debuginfo% -DSLIC3R_SENTRY=ON
|
||||||
cmake --build . --config %build_type% --target deps -- -m
|
cmake --build . --config %build_type% --target deps -- -m
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
|
|||||||
8
deps/CMakeLists.txt
vendored
8
deps/CMakeLists.txt
vendored
@@ -62,14 +62,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|||||||
option(DEP_WX_GTK3 "Build wxWidgets against GTK3" OFF)
|
option(DEP_WX_GTK3 "Build wxWidgets against GTK3" OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Sentry crash reporting - enabled only on Windows by default
|
|
||||||
if (WIN32)
|
|
||||||
set(SLIC3R_SENTRY_DEFAULT ON)
|
|
||||||
else()
|
|
||||||
set(SLIC3R_SENTRY_DEFAULT OFF)
|
|
||||||
endif()
|
|
||||||
option(SLIC3R_SENTRY "Enable Sentry crash reporting SDK" ${SLIC3R_SENTRY_DEFAULT})
|
|
||||||
|
|
||||||
set(IS_CROSS_COMPILE FALSE)
|
set(IS_CROSS_COMPILE FALSE)
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
|||||||
58
deps/Sentry/Sentry.cmake
vendored
58
deps/Sentry/Sentry.cmake
vendored
@@ -2,7 +2,7 @@ set(_sentry_platform_flags
|
|||||||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
||||||
-DSENTRY_BUILD_TESTS=OFF
|
-DSENTRY_BUILD_TESTS=OFF
|
||||||
-DSENTRY_EXAMPLES=OFF
|
-DSENTRY_EXAMPLES=OFF
|
||||||
-DSENTRY_CRASHPAD_BACKEND=ON
|
-DSENTRY_BACKEND=crashpad
|
||||||
-DSENTRY_ENABLE_INSTALL=ON
|
-DSENTRY_ENABLE_INSTALL=ON
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,16 +25,35 @@ if (WIN32)
|
|||||||
set(_sentry_cmake_generator -G "Visual Studio 17 2022")
|
set(_sentry_cmake_generator -G "Visual Studio 17 2022")
|
||||||
endif()
|
endif()
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
# macOS: Use Unix Makefiles (install will put libs in ${DESTDIR}/bin or lib)
|
# macOS: build shared libs so we get libsentry.dylib
|
||||||
|
# Note: CURL transport requires OpenSSL, need to link it explicitly
|
||||||
|
# DESTDIR already contains /usr/local/ suffix, so use it directly
|
||||||
set(_sentry_platform_flags
|
set(_sentry_platform_flags
|
||||||
${_sentry_platform_flags}
|
${_sentry_platform_flags}
|
||||||
-DSENTRY_TRANSPORT_CURL=ON
|
-DSENTRY_TRANSPORT_CURL=ON
|
||||||
-DSENTRY_BUILD_SHARED_LIBS=OFF
|
-DSENTRY_BUILD_SHARED_LIBS=ON
|
||||||
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
|
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
|
||||||
-DCMAKE_C_FLAGS:STRING=-g -O2
|
-DOPENSSL_ROOT_DIR:PATH=${DESTDIR}
|
||||||
-DCMAKE_CXX_FLAGS:STRING=-g -O2
|
-DOPENSSL_USE_STATIC_LIBS:BOOL=ON
|
||||||
|
-DCMAKE_SHARED_LINKER_FLAGS:STRING=-L${DESTDIR}/lib\ -lssl\ -lcrypto
|
||||||
)
|
)
|
||||||
set(_sentry_cmake_generator -G "Unix Makefiles")
|
set(_sentry_cmake_generator -G "Unix Makefiles")
|
||||||
|
|
||||||
|
# Sentry/crashpad requires macOS 12.0+ due to kIOMainPortDefault API usage
|
||||||
|
# Force minimum deployment target to 12.0 for Sentry build
|
||||||
|
set(_sentry_osx_deployment_target "12.0")
|
||||||
|
if (CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER "12.0")
|
||||||
|
set(_sentry_osx_deployment_target ${CMAKE_OSX_DEPLOYMENT_TARGET})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Add macOS architecture and deployment target for sentry build
|
||||||
|
if (CMAKE_OSX_ARCHITECTURES)
|
||||||
|
set(_sentry_platform_flags ${_sentry_platform_flags} -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES})
|
||||||
|
endif()
|
||||||
|
set(_sentry_platform_flags ${_sentry_platform_flags} -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${_sentry_osx_deployment_target})
|
||||||
|
if (CMAKE_OSX_SYSROOT)
|
||||||
|
set(_sentry_platform_flags ${_sentry_platform_flags} -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT})
|
||||||
|
endif()
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
# Linux: Use Unix Makefiles
|
# Linux: Use Unix Makefiles
|
||||||
set(_sentry_platform_flags
|
set(_sentry_platform_flags
|
||||||
@@ -42,22 +61,45 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|||||||
-DSENTRY_TRANSPORT_CURL=ON
|
-DSENTRY_TRANSPORT_CURL=ON
|
||||||
-DSENTRY_BUILD_SHARED_LIBS=OFF
|
-DSENTRY_BUILD_SHARED_LIBS=OFF
|
||||||
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
|
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
|
||||||
-DCMAKE_C_FLAGS:STRING=-g -O2
|
|
||||||
-DCMAKE_CXX_FLAGS:STRING=-g -O2
|
|
||||||
)
|
)
|
||||||
set(_sentry_cmake_generator -G "Unix Makefiles")
|
set(_sentry_cmake_generator -G "Unix Makefiles")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(SENTRY_PATCH_COMMAND
|
||||||
|
${GIT_EXECUTABLE} submodule update --init --recursive && ${CMAKE_COMMAND} -S external/crashpad -B external/crashpad/build ${_sentry_cmake_generator} -DCMAKE_BUILD_TYPE=Release && ${CMAKE_COMMAND} --build external/crashpad/build --config Release
|
||||||
|
)
|
||||||
|
elseif(APPLE)
|
||||||
|
set(SENTRY_PATCH_COMMAND
|
||||||
|
${GIT_EXECUTABLE} submodule update --init --recursive
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
set(SENTRY_PATCH_COMMAND
|
||||||
|
${GIT_EXECUTABLE} submodule update --init --recursive
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
Snapmaker_Orca_add_cmake_project(Sentry
|
Snapmaker_Orca_add_cmake_project(Sentry
|
||||||
GIT_REPOSITORY https://github.com/getsentry/sentry-native.git
|
GIT_REPOSITORY https://github.com/getsentry/sentry-native.git
|
||||||
GIT_TAG 0.12.1
|
GIT_TAG 0.12.1
|
||||||
PATCH_COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive && ${CMAKE_COMMAND} -S external/crashpad -B external/crashpad/build ${_sentry_cmake_generator} -DCMAKE_BUILD_TYPE=Release && ${CMAKE_COMMAND} --build external/crashpad/build --config Release
|
PATCH_COMMAND ${SENTRY_PATCH_COMMAND}
|
||||||
CMAKE_ARGS
|
CMAKE_ARGS
|
||||||
${_sentry_cmake_generator}
|
${_sentry_cmake_generator}
|
||||||
-DCMAKE_INSTALL_DATADIR:STRING=share
|
-DCMAKE_INSTALL_DATADIR:STRING=share
|
||||||
${_sentry_platform_flags}
|
${_sentry_platform_flags}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Sentry depends on CURL which depends on OpenSSL
|
||||||
|
# Ensure they are built before Sentry
|
||||||
|
if(APPLE)
|
||||||
|
if (TARGET dep_CURL)
|
||||||
|
add_dependencies(dep_Sentry dep_CURL)
|
||||||
|
endif()
|
||||||
|
if (TARGET dep_OpenSSL)
|
||||||
|
add_dependencies(dep_Sentry dep_OpenSSL)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
add_debug_dep(dep_Sentry)
|
add_debug_dep(dep_Sentry)
|
||||||
endif ()
|
endif ()
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dev-utils/platform/osx/Info.plist.in
|
|||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp dev-utils/BaseException.cpp dev-utils/BaseException.h dev-utils/StackWalker.cpp dev-utils/StackWalker.h sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp)
|
add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp dev-utils/BaseException.cpp dev-utils/BaseException.h dev-utils/StackWalker.cpp dev-utils/StackWalker.h sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp)
|
||||||
else ()
|
else ()
|
||||||
add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp)
|
add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
@@ -159,6 +159,8 @@ target_link_libraries(Snapmaker_Orca libslic3r_gui)
|
|||||||
target_link_libraries(Snapmaker_Orca ws2_32 uxtheme setupapi)
|
target_link_libraries(Snapmaker_Orca ws2_32 uxtheme setupapi)
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
target_link_libraries(Snapmaker_Orca "-framework OpenGL")
|
target_link_libraries(Snapmaker_Orca "-framework OpenGL")
|
||||||
|
# Link Sentry for crash reporting on macOS
|
||||||
|
target_link_libraries(Snapmaker_Orca sentry::sentry)
|
||||||
else ()
|
else ()
|
||||||
target_link_libraries(Snapmaker_Orca -ldl)
|
target_link_libraries(Snapmaker_Orca -ldl)
|
||||||
endif ()
|
endif ()
|
||||||
@@ -246,6 +248,16 @@ else ()
|
|||||||
COMMAND ln -sf Snapmaker_Orca snapmaker-orca
|
COMMAND ln -sf Snapmaker_Orca snapmaker-orca
|
||||||
WORKING_DIRECTORY "$<TARGET_FILE_DIR:Snapmaker_Orca>"
|
WORKING_DIRECTORY "$<TARGET_FILE_DIR:Snapmaker_Orca>"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
# Copy Sentry crashpad_handler to executable directory for non-bundle builds (e.g., Xcode debugging)
|
||||||
|
add_custom_command(TARGET Snapmaker_Orca POST_BUILD
|
||||||
|
COMMAND sh -c "if [ -f '${CMAKE_PREFIX_PATH}/bin/crashpad_handler' ]; then cp -f '${CMAKE_PREFIX_PATH}/bin/crashpad_handler' '$<TARGET_FILE_DIR:Snapmaker_Orca>/crashpad_handler' && codesign --force --sign - '$<TARGET_FILE_DIR:Snapmaker_Orca>/crashpad_handler' 2>/dev/null || true; fi"
|
||||||
|
COMMENT "Copying crashpad_handler for Sentry crash reporting"
|
||||||
|
VERBATIM)
|
||||||
|
# Copy libsentry.dylib to executable directory for non-bundle builds
|
||||||
|
add_custom_command(TARGET Snapmaker_Orca POST_BUILD
|
||||||
|
COMMAND sh -c "if [ -f '${CMAKE_PREFIX_PATH}/lib/libsentry.dylib' ]; then cp -f '${CMAKE_PREFIX_PATH}/lib/libsentry.dylib' '$<TARGET_FILE_DIR:Snapmaker_Orca>/libsentry.dylib' && codesign --force --sign - '$<TARGET_FILE_DIR:Snapmaker_Orca>/libsentry.dylib' 2>/dev/null || true; fi"
|
||||||
|
COMMENT "Copying libsentry.dylib for Sentry crash reporting"
|
||||||
|
VERBATIM)
|
||||||
else ()
|
else ()
|
||||||
add_custom_command(TARGET Snapmaker_Orca POST_BUILD
|
add_custom_command(TARGET Snapmaker_Orca POST_BUILD
|
||||||
WORKING_DIRECTORY "$<TARGET_FILE_DIR:Snapmaker_Orca>"
|
WORKING_DIRECTORY "$<TARGET_FILE_DIR:Snapmaker_Orca>"
|
||||||
@@ -278,6 +290,21 @@ else ()
|
|||||||
COMMAND ${CMAKE_COMMAND} -E create_symlink "${SLIC3R_RESOURCES_DIR}" "$<TARGET_FILE_DIR:Snapmaker_Orca>/../Resources"
|
COMMAND ${CMAKE_COMMAND} -E create_symlink "${SLIC3R_RESOURCES_DIR}" "$<TARGET_FILE_DIR:Snapmaker_Orca>/../Resources"
|
||||||
COMMENT "Symlinking the resources directory into the build tree"
|
COMMENT "Symlinking the resources directory into the build tree"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
# Copy Sentry crashpad_handler to MacOS directory (same directory as executable)
|
||||||
|
add_custom_command(TARGET Snapmaker_Orca POST_BUILD
|
||||||
|
COMMAND sh -c "if [ -f '${CMAKE_PREFIX_PATH}/bin/crashpad_handler' ]; then cp -f '${CMAKE_PREFIX_PATH}/bin/crashpad_handler' '$<TARGET_FILE_DIR:Snapmaker_Orca>/crashpad_handler' && codesign --force --sign - '$<TARGET_FILE_DIR:Snapmaker_Orca>/crashpad_handler'; fi"
|
||||||
|
COMMENT "Copying and signing crashpad_handler for Sentry crash reporting"
|
||||||
|
VERBATIM)
|
||||||
|
# Copy libsentry.dylib to Frameworks directory
|
||||||
|
add_custom_command(TARGET Snapmaker_Orca POST_BUILD
|
||||||
|
COMMAND sh -c "if [ -f '${CMAKE_PREFIX_PATH}/lib/libsentry.dylib' ]; then mkdir -p '$<TARGET_FILE_DIR:Snapmaker_Orca>/../Frameworks' && cp -f '${CMAKE_PREFIX_PATH}/lib/libsentry.dylib' '$<TARGET_FILE_DIR:Snapmaker_Orca>/../Frameworks/libsentry.dylib' && codesign --force --sign - '$<TARGET_FILE_DIR:Snapmaker_Orca>/../Frameworks/libsentry.dylib'; fi"
|
||||||
|
COMMENT "Copying and signing libsentry.dylib for Sentry crash reporting"
|
||||||
|
VERBATIM)
|
||||||
|
# Update the rpath for libsentry.dylib
|
||||||
|
add_custom_command(TARGET Snapmaker_Orca POST_BUILD
|
||||||
|
COMMAND install_name_tool -change "@rpath/libsentry.dylib" "@executable_path/../Frameworks/libsentry.dylib" "$<TARGET_FILE:Snapmaker_Orca>" || true
|
||||||
|
COMMENT "Updating rpath for libsentry.dylib"
|
||||||
|
VERBATIM)
|
||||||
endif()
|
endif()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,10 @@
|
|||||||
using namespace nlohmann;
|
using namespace nlohmann;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SLIC3R_SENTRY
|
||||||
|
#include "sentry_wrapper/SentryWrapper.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/nowide/args.hpp>
|
#include <boost/nowide/args.hpp>
|
||||||
@@ -6291,6 +6295,12 @@ extern "C" {
|
|||||||
#else /* _MSC_VER */
|
#else /* _MSC_VER */
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
return CLI().run(argc, argv);
|
initSentry();
|
||||||
|
|
||||||
|
auto res = CLI().run(argc, argv);
|
||||||
|
|
||||||
|
exitSentry();
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|||||||
@@ -10,14 +10,19 @@
|
|||||||
|
|
||||||
#ifdef SLIC3R_SENTRY
|
#ifdef SLIC3R_SENTRY
|
||||||
#include "sentry.h"
|
#include "sentry.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
@@ -36,41 +41,60 @@ static sentry_value_t on_crash_callback(const sentry_ucontext_t* uctx, sentry_va
|
|||||||
void initSentryEx()
|
void initSentryEx()
|
||||||
{
|
{
|
||||||
sentry_options_t* options = sentry_options_new();
|
sentry_options_t* options = sentry_options_new();
|
||||||
|
std::string dsn = "";
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef __APPLE__
|
||||||
|
|
||||||
|
std::string dsn = std::string("https://ac473187efb8877f36bd31694ffd5dec@o4508125599563776.ingest.us.sentry.io/4510425212059648");
|
||||||
|
|
||||||
|
#elif _WIN32
|
||||||
std::string dsn = std::string("https://c74b617c2aedc291444d3a238d23e780@o4508125599563776.ingest.us.sentry.io/4510425163956224");
|
std::string dsn = std::string("https://c74b617c2aedc291444d3a238d23e780@o4508125599563776.ingest.us.sentry.io/4510425163956224");
|
||||||
|
#endif
|
||||||
sentry_options_set_dsn(options, dsn.c_str());
|
sentry_options_set_dsn(options, dsn.c_str());
|
||||||
|
std::string handlerDir = "";
|
||||||
|
std::string dataBaseDir = "";
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
|
||||||
|
char exe_path[PATH_MAX] = {0};
|
||||||
|
uint32_t buf_size = PATH_MAX;
|
||||||
|
|
||||||
|
if (_NSGetExecutablePath(exe_path, &buf_size) != 0) {
|
||||||
|
throw std::runtime_error("Buffer too small for executable path");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the directory containing the executable, not the executable path itself
|
||||||
|
boost::filesystem::path exe_dir = boost::filesystem::path(exe_path).parent_path();
|
||||||
|
handlerDir = (exe_dir / "crashpad_handler").string();
|
||||||
|
|
||||||
|
const char* home_env = getenv("HOME");
|
||||||
|
|
||||||
|
dataBaseDir = home_env;
|
||||||
|
dataBaseDir = dataBaseDir + "/Library/Application Support/Snapmaker_Orca/SentryData";
|
||||||
|
#elif _WIN32
|
||||||
wchar_t exeDir[MAX_PATH];
|
wchar_t exeDir[MAX_PATH];
|
||||||
::GetModuleFileNameW(nullptr, exeDir, MAX_PATH);
|
::GetModuleFileNameW(nullptr, exeDir, MAX_PATH);
|
||||||
std::wstring wsExeDir(exeDir);
|
std::wstring wsExeDir(exeDir);
|
||||||
int nPos = wsExeDir.find_last_of('\\');
|
int nPos = wsExeDir.find_last_of('\\');
|
||||||
std::wstring wsDmpDir = wsExeDir.substr(0, nPos + 1);
|
std::wstring wsDmpDir = wsExeDir.substr(0, nPos + 1);
|
||||||
|
std::wstring desDir = wsDmpDir + L"crashpad_handler.exe";
|
||||||
std::wstring handlerDir = wsDmpDir + L"crashpad_handler.exe";
|
|
||||||
wsDmpDir += L"dump";
|
wsDmpDir += L"dump";
|
||||||
|
|
||||||
auto wstringTostring = [](std::wstring wTmpStr) -> std::string {
|
auto wstringTostring = [](std::wstring wTmpStr) -> std::string {
|
||||||
std::string resStr = std::string();
|
std::string resStr = std::string();
|
||||||
int len = WideCharToMultiByte(CP_UTF8, 0, wTmpStr.c_str(), -1, nullptr, 0, nullptr, nullptr);
|
int len = WideCharToMultiByte(CP_UTF8, 0, wTmpStr.c_str(), -1, nullptr, 0, nullptr, nullptr);
|
||||||
|
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
||||||
std::string desStr(len, 0);
|
std::string desStr(len, 0);
|
||||||
|
|
||||||
WideCharToMultiByte(CP_UTF8, 0, wTmpStr.c_str(), -1, &desStr[0], len, nullptr, nullptr);
|
WideCharToMultiByte(CP_UTF8, 0, wTmpStr.c_str(), -1, &desStr[0], len, nullptr, nullptr);
|
||||||
|
|
||||||
resStr = desStr;
|
resStr = desStr;
|
||||||
|
|
||||||
return resStr;
|
return resStr;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string desDir = wstringTostring(handlerDir);
|
handlerDir = wstringTostring(desDir);
|
||||||
if (!desDir.empty())
|
|
||||||
sentry_options_set_handler_path(options, desDir.c_str());
|
|
||||||
desDir = wstringTostring(wsDmpDir);
|
|
||||||
desDir = wstringTostring(wsDmpDir);
|
|
||||||
wchar_t appDataPath[MAX_PATH] = {0};
|
wchar_t appDataPath[MAX_PATH] = {0};
|
||||||
auto hr = SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataPath);
|
auto hr = SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataPath);
|
||||||
char* path = new char[MAX_PATH];
|
char* path = new char[MAX_PATH];
|
||||||
@@ -78,13 +102,16 @@ void initSentryEx()
|
|||||||
wcstombs_s(&pathLength, path, MAX_PATH, appDataPath, MAX_PATH);
|
wcstombs_s(&pathLength, path, MAX_PATH, appDataPath, MAX_PATH);
|
||||||
std::string filePath = path;
|
std::string filePath = path;
|
||||||
std::string appName = "\\" + std::string("Snapmaker_Orca\\");
|
std::string appName = "\\" + std::string("Snapmaker_Orca\\");
|
||||||
filePath = filePath + appName;
|
dataBaseDir = filePath + appName;
|
||||||
|
|
||||||
if (!filePath.empty())
|
|
||||||
sentry_options_set_database_path(options, filePath.c_str());
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!handlerDir.empty())
|
||||||
|
sentry_options_set_handler_path(options, handlerDir.c_str());
|
||||||
|
|
||||||
|
if (!dataBaseDir.empty())
|
||||||
|
sentry_options_set_database_path(options, dataBaseDir.c_str());
|
||||||
|
|
||||||
std::string softVersion = "snapmaker_orca_2.2.0_beta2";
|
std::string softVersion = "snapmaker_orca_2.2.0_beta2";
|
||||||
// Snapmaker_VERSION
|
|
||||||
sentry_options_set_release(options, softVersion.c_str());
|
sentry_options_set_release(options, softVersion.c_str());
|
||||||
|
|
||||||
#if defined(_DEBUG) || !defined(NDEBUG)
|
#if defined(_DEBUG) || !defined(NDEBUG)
|
||||||
@@ -92,17 +119,16 @@ void initSentryEx()
|
|||||||
#else
|
#else
|
||||||
sentry_options_set_debug(options, 0);
|
sentry_options_set_debug(options, 0);
|
||||||
#endif
|
#endif
|
||||||
// release version environment(Testing/production/development/Staging)
|
|
||||||
sentry_options_set_environment(options, "develop");
|
sentry_options_set_environment(options, "develop");
|
||||||
sentry_options_set_auto_session_tracking(options, false);
|
|
||||||
sentry_options_set_symbolize_stacktraces(options, true);
|
sentry_options_set_auto_session_tracking(options, 0);
|
||||||
|
sentry_options_set_symbolize_stacktraces(options, 1);
|
||||||
sentry_options_set_on_crash(options, on_crash_callback, NULL);
|
sentry_options_set_on_crash(options, on_crash_callback, NULL);
|
||||||
// Enable before_send hook for filtering sensitive data
|
|
||||||
sentry_options_set_before_send(options, NULL, NULL);
|
sentry_options_set_before_send(options, NULL, NULL);
|
||||||
|
|
||||||
// Ensure all events and crashes are captured (sample rate 100%)
|
sentry_options_set_sample_rate(options, 1.0);
|
||||||
sentry_options_set_sample_rate(options, 1.0); // Capture 100% of events
|
sentry_options_set_traces_sample_rate(options, 1.0);
|
||||||
sentry_options_set_traces_sample_rate(options, 1.0); // Capture 100% of traces
|
|
||||||
|
|
||||||
sentry_init(options);
|
sentry_init(options);
|
||||||
sentry_start_session();
|
sentry_start_session();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Slic3r {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void sentryReportLog(SENTRY_LOG_LEVEL logLevel,
|
void sentryReportLog(SENTRY_LOG_LEVEL logLevel,
|
||||||
const std::string& logContent,
|
const std::string& logContent,
|
||||||
const std::string& funcModule = "",
|
const std::string& funcModule = "",
|
||||||
const std::string& logTagKey = "",
|
const std::string& logTagKey = "",
|
||||||
const std::string& logTagValue = "",
|
const std::string& logTagValue = "",
|
||||||
|
|||||||
@@ -1021,6 +1021,11 @@ PreferencesDialog::PreferencesDialog(wxWindow *parent, wxWindowID id, const wxSt
|
|||||||
: DPIDialog(parent, id, _L("Preferences"), pos, size, style)
|
: DPIDialog(parent, id, _L("Preferences"), pos, size, style)
|
||||||
{
|
{
|
||||||
SetBackgroundColour(*wxWHITE);
|
SetBackgroundColour(*wxWHITE);
|
||||||
|
|
||||||
|
wxPanel* pPanel = new wxPanel(nullptr);
|
||||||
|
delete pPanel;
|
||||||
|
delete pPanel;
|
||||||
|
|
||||||
create();
|
create();
|
||||||
wxGetApp().UpdateDlgDarkUI(this);
|
wxGetApp().UpdateDlgDarkUI(this);
|
||||||
Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& event) {
|
Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user