Skip to content

feat: Nintendo Switch support #2198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions package-dev/Runtime/SentryInitialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#define SENTRY_NATIVE_ANDROID
#elif UNITY_64 && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX)
#define SENTRY_NATIVE
#elif UNITY_SWITCH
#define SENTRY_NATIVE
#elif UNITY_WEBGL
#define SENTRY_WEBGL
#endif
Expand Down Expand Up @@ -325,6 +327,8 @@ public bool IsNativeSupportEnabled(SentryUnityOptions options, RuntimePlatform p
return options.MacosNativeSupportEnabled;
case RuntimePlatform.LinuxPlayer:
return options.LinuxNativeSupportEnabled;
case RuntimePlatform.Switch:
return true;
#if UNITY_2021_3_OR_NEWER
case RuntimePlatform.WindowsServer:
return options.WindowsNativeSupportEnabled;
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.Unity.Android/SentryNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static class SentryNative
public static void ReinstallBackend() => ReinstallSentryNativeBackendStrategy();

// libsentry.io
[DllImport("sentry")]
[DllImport("__Internal")]
private static extern void sentry_reinstall_backend();

// Testing
Expand Down
10 changes: 5 additions & 5 deletions src/Sentry.Unity.Editor/Native/BuildPostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public static class BuildPostProcess
public static void OnPostProcessBuild(BuildTarget target, string executablePath)
{
var targetGroup = BuildPipeline.GetBuildTargetGroup(target);
if (targetGroup is not BuildTargetGroup.Standalone)
{
return;
}
// if (targetGroup is not BuildTargetGroup.Standalone)
// {
// return;
// }

var (options, cliOptions) = SentryScriptableObject.ConfiguredBuildTimeOptions();
var logger = options?.DiagnosticLogger ?? new UnityLogger(options ?? new SentryUnityOptions());
Expand Down Expand Up @@ -220,7 +220,7 @@ private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget tar
}
break;
default:
logger.LogError($"Symbol upload for '{target}' is currently not supported.");
// logger.LogError($"Symbol upload for '{target}' is currently not supported.");
break;
}

Expand Down
10 changes: 5 additions & 5 deletions src/Sentry.Unity.Native/SentryNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public static void Configure(SentryUnityOptions options, ISentryUnityInfo sentry

Logger?.LogInfo("Attempting to configure native support via the Native SDK");

if (!sentryUnityInfo.IsNativeSupportEnabled(options, ApplicationAdapter.Instance.Platform))
{
Logger?.LogDebug("Native support is disabled for '{0}'.", ApplicationAdapter.Instance.Platform);
return;
}
// if (!sentryUnityInfo.IsNativeSupportEnabled(options, ApplicationAdapter.Instance.Platform))
// {
// Logger?.LogDebug("Native support is disabled for '{0}'.", ApplicationAdapter.Instance.Platform);
// return;
// }

try
{
Expand Down
32 changes: 16 additions & 16 deletions src/Sentry.Unity.Native/SentryNativeBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static bool Init(SentryUnityOptions options, ISentryUnityInfo sentryUnity
if (ApplicationAdapter.Instance.Platform is RuntimePlatform.WindowsPlayer)
{
options.DiagnosticLogger?.LogDebug("Setting CacheDirectoryPath on Windows: {0}", dir);
sentry_options_set_database_pathw(cOptions, dir);
// sentry_options_set_database_pathw(cOptions, dir);
}
else
{
Expand Down Expand Up @@ -106,37 +106,37 @@ internal static string GetCacheDirectory(SentryUnityOptions options)
internal static void ReinstallBackend() => sentry_reinstall_backend();

// libsentry.so
[DllImport("sentry")]
[DllImport("__Internal")]
private static extern IntPtr sentry_options_new();

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern void sentry_options_set_dsn(IntPtr options, string dsn);

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern void sentry_options_set_release(IntPtr options, string release);

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern void sentry_options_set_debug(IntPtr options, int debug);

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern void sentry_options_set_environment(IntPtr options, string environment);

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern void sentry_options_set_sample_rate(IntPtr options, double rate);

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern void sentry_options_set_database_path(IntPtr options, string path);

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern void sentry_options_set_database_pathw(IntPtr options, [MarshalAs(UnmanagedType.LPWStr)] string path);

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern void sentry_options_set_auto_session_tracking(IntPtr options, int debug);

[UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)]
private delegate void sentry_logger_function_t(int level, IntPtr message, IntPtr argsAddress, IntPtr userData);

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern void sentry_options_set_logger(IntPtr options, sentry_logger_function_t logger, IntPtr userData);

// The logger we should forward native messages to. This is referenced by nativeLog() which in turn for.
Expand Down Expand Up @@ -266,18 +266,18 @@ private static void WithMarshalledStruct<T>(T structure, Action<IntPtr> action)
action(ptr);
});

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern int sentry_init(IntPtr options);

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern int sentry_close();

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern int sentry_get_crashed_last_run();

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern int sentry_clear_crashed_last_run();

[DllImport("sentry")]
[DllImport("__Internal")]
private static extern void sentry_reinstall_backend();
}
52 changes: 26 additions & 26 deletions src/Sentry.Unity/NativeUtils/CFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,78 +77,78 @@ internal static void SetValueIfNotNull(sentry_value_t obj, string key, double? v
return null;
}

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern sentry_value_t sentry_value_new_object();

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern sentry_value_t sentry_value_new_null();

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern sentry_value_t sentry_value_new_bool(int value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern sentry_value_t sentry_value_new_double(double value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern sentry_value_t sentry_value_new_int32(int value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern sentry_value_t sentry_value_new_string(string value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern sentry_value_t sentry_value_new_breadcrumb(string? type, string? message);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern int sentry_value_set_by_key(sentry_value_t value, string k, sentry_value_t v);

internal static bool IsNull(sentry_value_t value) => sentry_value_is_null(value) != 0;

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern int sentry_value_is_null(sentry_value_t value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern int sentry_value_as_int32(sentry_value_t value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern double sentry_value_as_double(sentry_value_t value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern IntPtr sentry_value_as_string(sentry_value_t value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern UIntPtr sentry_value_get_length(sentry_value_t value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern sentry_value_t sentry_value_get_by_index(sentry_value_t value, UIntPtr index);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern sentry_value_t sentry_value_get_by_key(sentry_value_t value, string key);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern void sentry_set_context(string key, sentry_value_t value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern void sentry_add_breadcrumb(sentry_value_t breadcrumb);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern void sentry_set_tag(string key, string value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern void sentry_remove_tag(string key);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern void sentry_set_user(sentry_value_t user);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern void sentry_remove_user();

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern void sentry_set_extra(string key, sentry_value_t value);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern void sentry_remove_extra(string key);

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern void sentry_set_trace(string traceId, string parentSpanId);

internal static readonly Lazy<IEnumerable<DebugImage>> DebugImages = new(LoadDebugImages);
Expand Down Expand Up @@ -202,10 +202,10 @@ private static IEnumerable<DebugImage> LoadDebugImages()

// Returns a new reference to an immutable, frozen list.
// The reference must be released with `sentry_value_decref`.
[DllImport("sentry")]
[DllImport("__Internal")]
private static extern sentry_value_t sentry_get_modules_list();

[DllImport("sentry")]
[DllImport("__Internal")]
internal static extern void sentry_value_decref(sentry_value_t value);

// native union sentry_value_u/t
Expand Down
Loading