feature add sentry config for mac cmake

This commit is contained in:
alves
2025-12-08 12:13:09 +08:00
parent fdc2dca0f4
commit 06a403e295
2 changed files with 34 additions and 25 deletions

View File

@@ -247,15 +247,19 @@ else ()
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) # Copy Sentry crashpad_handler to executable directory for non-bundle builds (e.g., Xcode debugging)
if (SLIC3R_SENTRY)
add_custom_command(TARGET Snapmaker_Orca POST_BUILD 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" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_PREFIX_PATH}/bin/crashpad_handler" "$<TARGET_FILE_DIR:Snapmaker_Orca>/crashpad_handler"
COMMAND sh -c "codesign --force --sign - '$<TARGET_FILE_DIR:Snapmaker_Orca>/crashpad_handler' 2>/dev/null || true"
COMMENT "Copying crashpad_handler for Sentry crash reporting" COMMENT "Copying crashpad_handler for Sentry crash reporting"
VERBATIM) VERBATIM)
# Copy libsentry.dylib to executable directory for non-bundle builds # Copy libsentry.dylib to executable directory for non-bundle builds
add_custom_command(TARGET Snapmaker_Orca POST_BUILD 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" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_PREFIX_PATH}/lib/libsentry.dylib" "$<TARGET_FILE_DIR:Snapmaker_Orca>/libsentry.dylib"
COMMAND sh -c "codesign --force --sign - '$<TARGET_FILE_DIR:Snapmaker_Orca>/libsentry.dylib' 2>/dev/null || true"
COMMENT "Copying libsentry.dylib for Sentry crash reporting" COMMENT "Copying libsentry.dylib for Sentry crash reporting"
VERBATIM) VERBATIM)
endif()
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>"
@@ -289,13 +293,17 @@ else ()
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) # Copy Sentry crashpad_handler to MacOS directory (same directory as executable)
if (SLIC3R_SENTRY)
add_custom_command(TARGET Snapmaker_Orca POST_BUILD 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" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_PREFIX_PATH}/bin/crashpad_handler" "$<TARGET_FILE_DIR:Snapmaker_Orca>/crashpad_handler"
COMMAND sh -c "codesign --force --sign - '$<TARGET_FILE_DIR:Snapmaker_Orca>/crashpad_handler' 2>/dev/null || true"
COMMENT "Copying and signing crashpad_handler for Sentry crash reporting" COMMENT "Copying and signing crashpad_handler for Sentry crash reporting"
VERBATIM) VERBATIM)
# Copy libsentry.dylib to Frameworks directory # Copy libsentry.dylib to Frameworks directory
add_custom_command(TARGET Snapmaker_Orca POST_BUILD 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" COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:Snapmaker_Orca>/../Frameworks"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_PREFIX_PATH}/lib/libsentry.dylib" "$<TARGET_FILE_DIR:Snapmaker_Orca>/../Frameworks/libsentry.dylib"
COMMAND sh -c "codesign --force --sign - '$<TARGET_FILE_DIR:Snapmaker_Orca>/../Frameworks/libsentry.dylib' 2>/dev/null || true"
COMMENT "Copying and signing libsentry.dylib for Sentry crash reporting" COMMENT "Copying and signing libsentry.dylib for Sentry crash reporting"
VERBATIM) VERBATIM)
# Update the rpath for libsentry.dylib # Update the rpath for libsentry.dylib
@@ -304,6 +312,7 @@ else ()
COMMENT "Updating rpath for libsentry.dylib" COMMENT "Updating rpath for libsentry.dylib"
VERBATIM) VERBATIM)
endif() endif()
endif()
endif () endif ()
# Slic3r binary install target. Default build type is release in case no CMAKE_BUILD_TYPE is provided. # Slic3r binary install target. Default build type is release in case no CMAKE_BUILD_TYPE is provided.

View File

@@ -33,9 +33,9 @@
using namespace nlohmann; using namespace nlohmann;
#endif #endif
#ifdef SLIC3R_SENTRY
#include "sentry_wrapper/SentryWrapper.hpp" #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>