Skip to content
Merged
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
135 changes: 135 additions & 0 deletions package-dev/Runtime/Sentry.Unity.Native.Console.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package-dev/Runtime/Sentry.Unity.Native.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/Sentry.Unity.Native/Sentry.Unity.Native.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,16 @@
<ProjectReference Include="../Sentry.Unity/Sentry.Unity.csproj" Private="false" />
</ItemGroup>

<!-- Build Console version after the Desktop version -->
<Target Name="BuildConsoleAssembly" AfterTargets="AfterBuild">
<Csc
Sources="@(Compile)"
References="@(ReferencePath)"
OutputAssembly="$(OutDir)Sentry.Unity.Native.Console.dll"
DefineConstants="$(DefineConstants);SENTRY_NATIVE_STATIC"
TargetType="library"
EmitDebugInformation="true"
/>
</Target>

</Project>
72 changes: 72 additions & 0 deletions src/Sentry.Unity.Native/SentryNativeBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,40 +111,84 @@ internal static string GetCacheDirectory(SentryUnityOptions options)
internal static void ReinstallBackend() => sentry_reinstall_backend();

// libsentry.so
#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern IntPtr sentry_options_new();

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern void sentry_options_set_dsn(IntPtr options, string dsn);

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern void sentry_options_set_release(IntPtr options, string release);

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern void sentry_options_set_debug(IntPtr options, int debug);

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern void sentry_options_set_environment(IntPtr options, string environment);

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern void sentry_options_set_sample_rate(IntPtr options, double rate);

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern void sentry_options_set_database_path(IntPtr options, string path);

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

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern void sentry_options_set_auto_session_tracking(IntPtr options, int debug);

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern void sentry_options_set_attach_screenshot(IntPtr options, int attachScreenshot);

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

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
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 @@ -238,10 +282,18 @@ private static void nativeLogImpl(int cLevel, IntPtr format, IntPtr args, IntPtr
}
}

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal", EntryPoint = "vsnprintf")]
#else
[DllImport("msvcrt", EntryPoint = "vsnprintf")]
#endif
private static extern int vsnprintf_windows(IntPtr buffer, UIntPtr bufferSize, IntPtr format, IntPtr args);

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal", EntryPoint = "vsnprintf")]
#else
[DllImport("libc", EntryPoint = "vsnprintf")]
#endif
private static extern int vsnprintf_linux(IntPtr buffer, UIntPtr bufferSize, IntPtr format, IntPtr args);

// https://stackoverflow.com/a/4958507/2386130
Expand Down Expand Up @@ -275,18 +327,38 @@ private static void WithMarshalledStruct<T>(T structure, Action<IntPtr> action)
action(ptr);
});

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern int sentry_init(IntPtr options);

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern int sentry_close();

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern int sentry_get_crashed_last_run();

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern int sentry_clear_crashed_last_run();

#if SENTRY_NATIVE_STATIC
[DllImport("__Internal")]
#else
[DllImport("sentry")]
#endif
private static extern void sentry_reinstall_backend();
}
1 change: 1 addition & 0 deletions src/Sentry.Unity/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
[assembly: InternalsVisibleTo("Sentry.Unity.Native.Console")]
[assembly: InternalsVisibleTo("Sentry.Unity.Tests")]
[assembly: InternalsVisibleTo("Sentry.Unity.Editor")]
[assembly: InternalsVisibleTo("Sentry.Unity.Editor.Tests")]
Expand Down
4 changes: 4 additions & 0 deletions test/Scripts.Tests/package-release.zip.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ Runtime/Sentry.Unity.iOS.dll
Runtime/Sentry.Unity.iOS.dll.meta
Runtime/Sentry.Unity.iOS.pdb
Runtime/Sentry.Unity.iOS.pdb.meta
Runtime/Sentry.Unity.Native.Console.dll
Runtime/Sentry.Unity.Native.Console.dll.meta
Runtime/Sentry.Unity.Native.Console.pdb
Runtime/Sentry.Unity.Native.Console.pdb.meta
Runtime/Sentry.Unity.Native.dll
Runtime/Sentry.Unity.Native.dll.meta
Runtime/Sentry.Unity.Native.pdb
Expand Down
Loading