Skip to content

Commit 83ddeef

Browse files
committed
initial sentry plugin implementation
1 parent 263d4d1 commit 83ddeef

File tree

7 files changed

+796
-2
lines changed

7 files changed

+796
-2
lines changed

CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if(NOT CMAKE_BUILD_TYPE)
3030
message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to Release.")
3131
endif()
3232

33-
project(flutter-pi LANGUAGES C VERSION "1.0.0")
33+
project(flutter-pi LANGUAGES C CXX ASM VERSION "1.0.0")
3434

3535
message(STATUS "Generator .............. ${CMAKE_GENERATOR}")
3636
message(STATUS "Build Type ............. ${CMAKE_BUILD_TYPE}")
@@ -39,10 +39,16 @@ message(STATUS "Build Type ............. ${CMAKE_BUILD_TYPE}")
3939
option(BUILD_TEXT_INPUT_PLUGIN "Include the text input plugin in the finished binary. Enables text input (to flutter text fields, for example) via attached keyboards." ON)
4040
option(BUILD_RAW_KEYBOARD_PLUGIN "Include the raw keyboard plugin in the finished binary. Enables raw keycode listening in flutter via the flutter RawKeyboard interface." ON)
4141
option(BUILD_TEST_PLUGIN "Include the test plugin in the finished binary. Allows testing platform channel communication." OFF)
42+
4243
option(BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN "Include the gstreamer based video plugins in the finished binary. Allows for more stable, hardware accelerated video playback in flutter using gstreamer." ON)
43-
option(BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN "Include the gstreamer based audio plugins in the finished binary." ON)
4444
option(TRY_BUILD_GSTREAMER_VIDEO_PLAYER_PLUGIN "Don't throw an error if the gstreamer libs aren't found, instead just don't build the gstreamer video player plugin in that case." ON)
45+
46+
option(BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN "Include the gstreamer based audio plugins in the finished binary." ON)
4547
option(TRY_BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN "Don't throw an error if the gstreamer libs aren't found, instead just don't build gstreamer audio plugin." ON)
48+
49+
option(BUILD_SENTRY_PLUGIN "Include the sentry plugin in the finished binary. Allows for crash reporting to sentry.io." OFF)
50+
option(TRY_BUILD_SENTRY_PLUGIN "Don't throw an error if the sentry libs aren't found, instead just don't build the sentry plugin in that case." ON)
51+
4652
option(BUILD_CHARSET_CONVERTER_PLUGIN "Include the charset converter plugin in the finished binary." OFF)
4753
option(ENABLE_OPENGL "Build with EGL/OpenGL rendering support." ON)
4854
option(TRY_ENABLE_OPENGL "Don't throw an error if EGL/OpenGL aren't found, instead just build without EGL/OpenGL support in that case." ON)
@@ -343,6 +349,15 @@ if (BUILD_CHARSET_CONVERTER_PLUGIN)
343349
target_sources(flutterpi_module PRIVATE src/plugins/charset_converter.c)
344350
endif()
345351

352+
# Sentry Plugin
353+
if (BUILD_SENTRY_PLUGIN)
354+
add_subdirectory(third_party/sentry-native)
355+
356+
target_sources(flutterpi_module PRIVATE src/plugins/sentry/sentry.c)
357+
target_link_libraries(flutterpi_module PUBLIC sentry)
358+
endif()
359+
message(STATUS "Sentry plugin: ${BUILD_SENTRY_PLUGIN}")
360+
346361
# Needed so dart VM can actually resolve symbols in the same
347362
# executable. (For dart:ffi DynamicLibrary.executable / DynamicLibrary.process)
348363
target_link_options(flutterpi_module PUBLIC -rdynamic)

CMakePresets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
1313
"ENABLE_OPENGL": true,
1414
"BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN": true,
15+
"BUILD_SENTRY_PLUGIN": true,
1516
"ENABLE_TESTS": true
1617
}
1718
},

src/platformchannel.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <flutter_embedder.h>
1313

1414
#include "flutter-pi.h"
15+
#define JSMN_STATIC
1516
#include "jsmn.h"
1617
#include "util/asserts.h"
1718

@@ -1823,6 +1824,11 @@ ATTR_PURE double raw_std_value_as_float64(const struct raw_std_value *value) {
18231824
return *(double *) get_value_ptr(value, 8);
18241825
}
18251826

1827+
ATTR_PURE size_t raw_std_string_get_length(const struct raw_std_value *value) {
1828+
assert(raw_std_value_is_string(value));
1829+
return raw_std_value_get_size(value);
1830+
}
1831+
18261832
ATTR_PURE bool raw_std_value_is_string(const struct raw_std_value *value) {
18271833
return raw_std_value_get_type(value) == kStdString;
18281834
}
@@ -1843,6 +1849,11 @@ MALLOCLIKE MUST_CHECK char *raw_std_string_dup(const struct raw_std_value *value
18431849
return str;
18441850
}
18451851

1852+
ATTR_PURE const char *raw_std_string_get_nonzero_terminated(const struct raw_std_value *value) {
1853+
assert(raw_std_value_is_string(value));
1854+
return get_array_value_ptr(value, 0, raw_std_value_get_size(value));
1855+
}
1856+
18461857
ATTR_PURE bool raw_std_string_equals(const struct raw_std_value *value, const char *str) {
18471858
size_t length = raw_std_value_get_size(value);
18481859
const char *as_unterminated_string = get_array_value_ptr(value, 0, length);

src/platformchannel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ struct std_value {
136136
#define STDVALUE_IS_MAP(value) ((value).type == kStdMap)
137137
#define STDVALUE_IS_SIZED_MAP(value, _size) ((value).size == (_size))
138138

139+
#define STDMAP0() ((struct std_value){ .type = kStdMap, .size = 0, .keys = (struct std_value[0]){}, .values = (struct std_value[0]){} })
140+
139141
#define STDMAP1(key1, val1) \
140142
((struct std_value){ .type = kStdMap, .size = 1, .keys = (struct std_value[1]){ (key1) }, .values = (struct std_value[1]){ (val1) } })
141143

@@ -1564,6 +1566,7 @@ struct std_value *stdmap_get_str(struct std_value *map, char *key);
15641566

15651567
struct raw_std_value;
15661568

1569+
ATTR_PURE enum std_value_type raw_std_value_get_type(const struct raw_std_value *value);
15671570
ATTR_PURE bool raw_std_value_is_null(const struct raw_std_value *value);
15681571
ATTR_PURE bool raw_std_value_is_true(const struct raw_std_value *value);
15691572
ATTR_PURE bool raw_std_value_is_false(const struct raw_std_value *value);
@@ -1574,6 +1577,8 @@ ATTR_PURE int64_t raw_std_value_as_int64(const struct raw_std_value *value);
15741577
ATTR_PURE bool raw_std_value_is_float64(const struct raw_std_value *value);
15751578
ATTR_PURE double raw_std_value_as_float64(const struct raw_std_value *value);
15761579
ATTR_PURE bool raw_std_value_is_string(const struct raw_std_value *value);
1580+
ATTR_PURE size_t raw_std_string_get_length(const struct raw_std_value *value);
1581+
ATTR_PURE const char *raw_std_string_get_nonzero_terminated(const struct raw_std_value *value);
15771582
MALLOCLIKE MUST_CHECK char *raw_std_string_dup(const struct raw_std_value *value);
15781583
ATTR_PURE bool raw_std_string_equals(const struct raw_std_value *value, const char *str);
15791584
ATTR_PURE bool raw_std_value_is_uint8array(const struct raw_std_value *value);

0 commit comments

Comments
 (0)