diff --git a/protocol/CMakeLists.txt b/protocol/CMakeLists.txt index 624422c9db1..3c2e2b6301b 100644 --- a/protocol/CMakeLists.txt +++ b/protocol/CMakeLists.txt @@ -113,10 +113,7 @@ if (CPPCHECK AND ${CI} MATCHES "TRUE" AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux") "--error-exitcode=1" # Propagate cppcheck errors to cmake "--suppress=shiftTooManyBitsSigned" "--suppress=*:${CMAKE_SOURCE_DIR}/fractal/clipboard/clipboard_osx.m" # suppress all warnings for clipboard_osx.m since cppcheck isn't supported on Objective-C - "--suppress=*:*/sentry-native/*.c" # Ignore errors that occur in sentry-native c files. We shouldn't ignore errors in sentry-native h files - "--suppress=*:*/sentry-native/vendor/*" # However, we should ignore errors in the c and h files of sentry-native's build dependencies "--suppress=*:${CMAKE_SOURCE_DIR}/fractal/utils/lodepng.*" # suppress all lodepng warnings, since this is an external library that we should not touch - "-D__linux" # Needed for sentry.h to pass "--inline-suppr" # Allow cppcheck-suppress comments in code ) else() @@ -227,7 +224,16 @@ else() find_package(OpenSSL REQUIRED) endif() - +find_library(LIB_SENTRY NAMES sentry PATHS "${CMAKE_BINARY_DIR}/lib/${arch}/sentry/${CMAKE_SYSTEM_NAME}" + NO_DEFAULT_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_CMAKE_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH + NO_CMAKE_FIND_ROOT_PATH) +if (NOT LIB_SENTRY) + message(FATAL_ERROR "Library sentry was not found! ${CMAKE_BINARY_DIR}/lib/${arch}/sentry/${CMAKE_SYSTEM_NAME}") +endif() find_library(STATIC_SDL2 NAMES SDL2 SDL2-static PATHS "${CMAKE_BINARY_DIR}/lib/${arch}/SDL2/${CMAKE_SYSTEM_NAME}" NO_DEFAULT_PATH @@ -252,40 +258,6 @@ if ((NOT LIBMFX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) message(FATAL_ERROR "Library LIBMFX was not found! ${CMAKE_SOURCE_DIR}/lib/${arch}/mfx/${CMAKE_SYSTEM_NAME}") endif() -#download and install Sentry CMake project -# This is fixed to sdk version 0.4.8 -set(sentry_url https://github.com/getsentry/sentry-native/releases/download/0.4.10/sentry-native.zip) -set(sentry_dir sentry-native) -MESSAGE(VERBOSE ${CMAKE_SOURCE_DIR}/${sentry_dir}) -if(NOT EXISTS ${CMAKE_SOURCE_DIR}/${sentry_dir}) - MESSAGE(STATUS "Downloading Sentry") - file(DOWNLOAD ${sentry_url} "${CMAKE_SOURCE_DIR}/${sentry_dir}.zip" - STATUS sentry_dl_status) - MESSAGE(VERBOSE ${sentry_dl_status}) - file(MAKE_DIRECTORY ${sentry_dir}) - - execute_process( - COMMAND ${CMAKE_COMMAND} -E tar -xzf ${CMAKE_SOURCE_DIR}/${sentry_dir}.zip - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${sentry_dir} - ) - execute_process( - COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_SOURCE_DIR}/${sentry_dir}.zip - ) -endif() - -# Do this before setting the OSX compiler so we do not mess with the sentry-native build -message("Setting Sentry options") -set(SENTRY_BUILD_SHARED_LIBS ON CACHE BOOL "sentry create shared lib" FORCE) -set(SENTRY_BUILD_RUNTIMESTATIC ON CACHE BOOL "sentry runtimestatic" FORCE) -set(SENTRY_BACKEND crashpad CACHE STRING "sentry backend" FORCE) -add_subdirectory(sentry-native) - -# set a standard location for the sentry shared lib so we can copy it into client/server build folders as a post build step -set_target_properties(sentry PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/sentry-native - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/sentry-native - ) - #Set OSX compiler and SDK globally if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_C_COMPILER clang) @@ -297,28 +269,10 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15) # deployment target must be <= than compiler SDK above endif() -# Store compiler options of native libraries, for now, we simply pass in "-w" to disable warnings -if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") - set(NONFRACTAL_COMPILE_OPTIONS -w) - target_compile_options(mini_chromium PRIVATE ${NONFRACTAL_COMPILE_OPTIONS}) - if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - target_compile_options(crashpad_compat PRIVATE ${NONFRACTAL_COMPILE_OPTIONS}) - endif() - target_compile_options(crashpad_util PRIVATE ${NONFRACTAL_COMPILE_OPTIONS}) - target_compile_options(crashpad_client PRIVATE ${NONFRACTAL_COMPILE_OPTIONS}) - target_compile_options(crashpad_snapshot PRIVATE ${NONFRACTAL_COMPILE_OPTIONS}) - target_compile_options(crashpad_minidump PRIVATE ${NONFRACTAL_COMPILE_OPTIONS}) - target_compile_options(crashpad_handler_lib PRIVATE ${NONFRACTAL_COMPILE_OPTIONS}) - target_compile_options(crashpad_tools PRIVATE ${NONFRACTAL_COMPILE_OPTIONS}) - target_compile_options(crashpad_handler PRIVATE ${NONFRACTAL_COMPILE_OPTIONS}) - target_compile_options(sentry PRIVATE ${NONFRACTAL_COMPILE_OPTIONS}) -endif() - # Tell CMake where to look for includes # Use SYSTEM flag to not get warnings from their files include_directories(${CMAKE_SOURCE_DIR}) # For #include semantics include_directories(SYSTEM include) -include_directories(SYSTEM sentry-native/include) include_directories(SYSTEM ${CMAKE_BINARY_DIR}/include) include_directories(SYSTEM ${CMAKE_BINARY_DIR}/include/ffmpeg) diff --git a/protocol/client/CMakeLists.txt b/protocol/client/CMakeLists.txt index 51b8be6cec0..c3c82255a5c 100644 --- a/protocol/client/CMakeLists.txt +++ b/protocol/client/CMakeLists.txt @@ -28,21 +28,14 @@ set_target_properties(FractalClient PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/client/build${arch} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/client/build${arch}) -# copy the sentry shared library to the build folder after the build +# copy the sentry shared library and crashpad handler to the build folder after the build add_custom_command( TARGET FractalClient POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_BINARY_DIR}/sentry-native/${CMAKE_SHARED_LIBRARY_PREFIX}sentry${CMAKE_SHARED_LIBRARY_SUFFIX} + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_BINARY_DIR}/lib/64/sentry/${CMAKE_SYSTEM_NAME}/ $) -# MacOS and Windows default to crashpad for Sentry, and crashpad_handler needs to be in -# the same folder as the executable if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux") - add_custom_command( - TARGET FractalClient POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_BINARY_DIR}/sentry-native/crashpad_build/handler/crashpad_handler - $) add_custom_command( TARGET FractalClient POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy @@ -50,11 +43,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux ${CMAKE_BINARY_DIR}) endif() if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_custom_command( - TARGET FractalClient POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_BINARY_DIR}/sentry-native/crashpad_build/handler/crashpad_handler.exe - $) add_custom_command( TARGET FractalClient POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy @@ -120,7 +108,7 @@ target_link_libraries(FractalClient fractalLogging fractalUtils ${STATIC_SDL2} - sentry + ${LIB_SENTRY} ) #[[ diff --git a/protocol/download-binaries.sh b/protocol/download-binaries.sh index 5fbbc4b28d4..48562ef75b0 100755 --- a/protocol/download-binaries.sh +++ b/protocol/download-binaries.sh @@ -83,6 +83,45 @@ if has_updated "$SDL_LIB"; then aws s3 cp --only-show-errors "s3://fractal-protocol-shared-libs/$SDL_LIB" - | tar -xz -C "$SDL_LIB_DIR" fi +############################### +# Download Sentry headers +############################### + +# If the include/sentry directory doesn't exist, make it and fill it +# Or, if the lib has updated, refill the directory +LIB="fractal-sentry-headers.tar.gz" +SENTRY_DIR="$DEST_DIR/include/sentry" +if has_updated "$LIB" || [[ ! -d "$SENTRY_DIR" ]]; then + rm -rf "$SENTRY_DIR" + mkdir -p "$SENTRY_DIR" + aws s3 cp --only-show-errors "s3://fractal-protocol-shared-libs/$LIB" - | tar -xz -C "$SENTRY_DIR" + + # Pull all SDL2 include files up a level and delete encapsulating folder + mv "$SENTRY_DIR/include"/* "$SENTRY_DIR" + rmdir "$SENTRY_DIR/include" +fi + +############################### +# Download Sentry libraries +############################### + +# Select sentry lib dir and sentry lib targz name based on OS +SENTRY_LIB_DIR="$DEST_DIR/lib/64/sentry/$OS" +if [[ "$OS" =~ "Windows" ]]; then + SENTRY_LIB="fractal-windows-sentry-shared-lib.tar.gz" +elif [[ "$OS" == "Darwin" ]]; then + SENTRY_LIB="fractal-macos-sentry-shared-lib.tar.gz" +elif [[ "$OS" == "Linux" ]]; then + SENTRY_LIB="fractal-linux-sentry-shared-lib.tar.gz" +fi + +# Check if SENTRY_LIB has updated, and if so, create the dir and copy the libs into the source dir +if has_updated "$SENTRY_LIB"; then + rm -rf "$SENTRY_LIB_DIR" + mkdir -p "$SENTRY_LIB_DIR" + aws s3 cp --only-show-errors "s3://fractal-protocol-shared-libs/$SENTRY_LIB" - | tar -xz -C "$SENTRY_LIB_DIR" +fi + ############################### # Download OpenSSL headers ############################### diff --git a/protocol/fractal/logging/error_monitor.c b/protocol/fractal/logging/error_monitor.c index cf80c5eff80..05ce4ca5eae 100644 --- a/protocol/fractal/logging/error_monitor.c +++ b/protocol/fractal/logging/error_monitor.c @@ -41,7 +41,7 @@ Includes ============================ */ -#include +#include #include #include "error_monitor.h" diff --git a/protocol/server/CMakeLists.txt b/protocol/server/CMakeLists.txt index 1d9a1f419b4..65e0eda441a 100644 --- a/protocol/server/CMakeLists.txt +++ b/protocol/server/CMakeLists.txt @@ -16,21 +16,14 @@ set_target_properties(FractalServer PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/server/build${arch} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/server/build${arch}) -# copy the sentry shared library to the build folder after the build +# copy the sentry shared library and crashpad handler to the build folder after the build add_custom_command( TARGET FractalServer POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_BINARY_DIR}/sentry-native/${CMAKE_SHARED_LIBRARY_PREFIX}sentry${CMAKE_SHARED_LIBRARY_SUFFIX} + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_BINARY_DIR}/lib/64/sentry/${CMAKE_SYSTEM_NAME}/ $) -# MacOS and Windows default to crashpad for Sentry, and crashpad_handler needs to be in -# the same folder as the executable if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux") - add_custom_command( - TARGET FractalServer POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_BINARY_DIR}/sentry-native/crashpad_build/handler/crashpad_handler - $) add_custom_command( TARGET FractalServer POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy @@ -38,11 +31,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux ${CMAKE_BINARY_DIR}) endif() if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - add_custom_command( - TARGET FractalServer POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_BINARY_DIR}/sentry-native/crashpad_build/handler/crashpad_handler.exe - $) add_custom_command( TARGET FractalServer POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy @@ -103,8 +91,8 @@ target_link_libraries(FractalServer fractalLogging fractalUtils ${STATIC_SDL2} + ${LIB_SENTRY} ${LIBMFX} - sentry ) #[[