Skip to content

Commit

Permalink
feat: add an option to configure native backend on windows & linux
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Dec 19, 2024
1 parent dd25e43 commit d660887
Show file tree
Hide file tree
Showing 4 changed files with 346 additions and 273 deletions.
2 changes: 2 additions & 0 deletions flutter/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# the plugin to fail to compile for some customers of the plugin.
cmake_minimum_required(VERSION 3.10)

set(SENTRY_BACKEND "crashpad" CACHE STRING "The sentry backend responsible for reporting crashes" FORCE)

include("${CMAKE_CURRENT_SOURCE_DIR}/../sentry-native/sentry-native.cmake")

# Even though sentry_flutter doesn't actually provide a useful plugin, we need to accommodate the Flutter tooling.
Expand Down
29 changes: 20 additions & 9 deletions flutter/sentry-native/sentry-native.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ load_cache("${CMAKE_CURRENT_LIST_DIR}" READ_WITH_PREFIX SENTRY_NATIVE_ repo vers
message(STATUS "Fetching Sentry native version: ${SENTRY_NATIVE_version} from ${SENTRY_NATIVE_repo}")

set(SENTRY_SDK_NAME "sentry.native.flutter" CACHE STRING "The SDK name to report when sending events." FORCE)
set(SENTRY_BACKEND "crashpad" CACHE STRING "The sentry backend responsible for reporting crashes" FORCE)
set(SENTRY_BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" FORCE)

# Note: the backend is also set in linux/CMakeLists.txt and windows/CMakeLists.txt. This overwrites those if user sets an env var.
if("$ENV{SENTRY_NATIVE_BACKEND}" STREQUAL "")
# Until sentry-dart v9, we disable native backend by default.
set(SENTRY_BACKEND "none" CACHE STRING "The sentry backend responsible for reporting crashes" FORCE)
else()
set(SENTRY_BACKEND $ENV{SENTRY_NATIVE_BACKEND} CACHE STRING "The sentry backend responsible for reporting crashes" FORCE)
endif()

include(FetchContent)
FetchContent_Declare(
sentry-native
Expand All @@ -17,15 +24,19 @@ FetchContent_MakeAvailable(sentry-native)

# List of absolute paths to libraries that should be bundled with the plugin.
# This list could contain prebuilt libraries, or libraries created by an external build triggered from this build file.
if(WIN32)
set(sentry_flutter_bundled_libraries
$<TARGET_FILE:crashpad_handler>
$<TARGET_FILE:crashpad_wer>
PARENT_SCOPE)
if(SENTRY_BACKEND STREQUAL "crashpad")
if(WIN32)
set(sentry_flutter_bundled_libraries
$<TARGET_FILE:crashpad_handler>
$<TARGET_FILE:crashpad_wer>
PARENT_SCOPE)
else()
set(sentry_flutter_bundled_libraries
$<TARGET_FILE:crashpad_handler>
PARENT_SCOPE)
endif()
else()
set(sentry_flutter_bundled_libraries
$<TARGET_FILE:crashpad_handler>
PARENT_SCOPE)
set(sentry_flutter_bundled_libraries "" PARENT_SCOPE)
endif()

# `*_plugin` is the name of the plugin library as expected by flutter.
Expand Down
Loading

0 comments on commit d660887

Please sign in to comment.