Skip to content

Commit adc6bda

Browse files
authored
feat: Split Sentry.Unity.Native into desktop and console (#2441)
1 parent be020a5 commit adc6bda

File tree

6 files changed

+229
-2
lines changed

6 files changed

+229
-2
lines changed

package-dev/Runtime/Sentry.Unity.Native.Console.dll.meta

Lines changed: 135 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-dev/Runtime/Sentry.Unity.Native.dll.meta

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Sentry.Unity.Native/Sentry.Unity.Native.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,16 @@
88
<ProjectReference Include="../Sentry.Unity/Sentry.Unity.csproj" Private="false" />
99
</ItemGroup>
1010

11+
<!-- Build Console version after the Desktop version -->
12+
<Target Name="BuildConsoleAssembly" AfterTargets="AfterBuild">
13+
<Csc
14+
Sources="@(Compile)"
15+
References="@(ReferencePath)"
16+
OutputAssembly="$(OutDir)Sentry.Unity.Native.Console.dll"
17+
DefineConstants="$(DefineConstants);SENTRY_NATIVE_STATIC"
18+
TargetType="library"
19+
EmitDebugInformation="true"
20+
/>
21+
</Target>
22+
1123
</Project>

src/Sentry.Unity.Native/SentryNativeBridge.cs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,40 +111,84 @@ internal static string GetCacheDirectory(SentryUnityOptions options)
111111
internal static void ReinstallBackend() => sentry_reinstall_backend();
112112

113113
// libsentry.so
114+
#if SENTRY_NATIVE_STATIC
115+
[DllImport("__Internal")]
116+
#else
114117
[DllImport("sentry")]
118+
#endif
115119
private static extern IntPtr sentry_options_new();
116120

121+
#if SENTRY_NATIVE_STATIC
122+
[DllImport("__Internal")]
123+
#else
117124
[DllImport("sentry")]
125+
#endif
118126
private static extern void sentry_options_set_dsn(IntPtr options, string dsn);
119127

128+
#if SENTRY_NATIVE_STATIC
129+
[DllImport("__Internal")]
130+
#else
120131
[DllImport("sentry")]
132+
#endif
121133
private static extern void sentry_options_set_release(IntPtr options, string release);
122134

135+
#if SENTRY_NATIVE_STATIC
136+
[DllImport("__Internal")]
137+
#else
123138
[DllImport("sentry")]
139+
#endif
124140
private static extern void sentry_options_set_debug(IntPtr options, int debug);
125141

142+
#if SENTRY_NATIVE_STATIC
143+
[DllImport("__Internal")]
144+
#else
126145
[DllImport("sentry")]
146+
#endif
127147
private static extern void sentry_options_set_environment(IntPtr options, string environment);
128148

149+
#if SENTRY_NATIVE_STATIC
150+
[DllImport("__Internal")]
151+
#else
129152
[DllImport("sentry")]
153+
#endif
130154
private static extern void sentry_options_set_sample_rate(IntPtr options, double rate);
131155

156+
#if SENTRY_NATIVE_STATIC
157+
[DllImport("__Internal")]
158+
#else
132159
[DllImport("sentry")]
160+
#endif
133161
private static extern void sentry_options_set_database_path(IntPtr options, string path);
134162

163+
#if SENTRY_NATIVE_STATIC
164+
[DllImport("__Internal")]
165+
#else
135166
[DllImport("sentry")]
167+
#endif
136168
private static extern void sentry_options_set_database_pathw(IntPtr options, [MarshalAs(UnmanagedType.LPWStr)] string path);
137169

170+
#if SENTRY_NATIVE_STATIC
171+
[DllImport("__Internal")]
172+
#else
138173
[DllImport("sentry")]
174+
#endif
139175
private static extern void sentry_options_set_auto_session_tracking(IntPtr options, int debug);
140176

177+
#if SENTRY_NATIVE_STATIC
178+
[DllImport("__Internal")]
179+
#else
141180
[DllImport("sentry")]
181+
#endif
142182
private static extern void sentry_options_set_attach_screenshot(IntPtr options, int attachScreenshot);
143183

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

187+
#if SENTRY_NATIVE_STATIC
188+
[DllImport("__Internal")]
189+
#else
147190
[DllImport("sentry")]
191+
#endif
148192
private static extern void sentry_options_set_logger(IntPtr options, sentry_logger_function_t logger, IntPtr userData);
149193

150194
// The logger we should forward native messages to. This is referenced by nativeLog() which in turn for.
@@ -238,10 +282,18 @@ private static void nativeLogImpl(int cLevel, IntPtr format, IntPtr args, IntPtr
238282
}
239283
}
240284

285+
#if SENTRY_NATIVE_STATIC
286+
[DllImport("__Internal", EntryPoint = "vsnprintf")]
287+
#else
241288
[DllImport("msvcrt", EntryPoint = "vsnprintf")]
289+
#endif
242290
private static extern int vsnprintf_windows(IntPtr buffer, UIntPtr bufferSize, IntPtr format, IntPtr args);
243291

292+
#if SENTRY_NATIVE_STATIC
293+
[DllImport("__Internal", EntryPoint = "vsnprintf")]
294+
#else
244295
[DllImport("libc", EntryPoint = "vsnprintf")]
296+
#endif
245297
private static extern int vsnprintf_linux(IntPtr buffer, UIntPtr bufferSize, IntPtr format, IntPtr args);
246298

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

330+
#if SENTRY_NATIVE_STATIC
331+
[DllImport("__Internal")]
332+
#else
278333
[DllImport("sentry")]
334+
#endif
279335
private static extern int sentry_init(IntPtr options);
280336

337+
#if SENTRY_NATIVE_STATIC
338+
[DllImport("__Internal")]
339+
#else
281340
[DllImport("sentry")]
341+
#endif
282342
private static extern int sentry_close();
283343

344+
#if SENTRY_NATIVE_STATIC
345+
[DllImport("__Internal")]
346+
#else
284347
[DllImport("sentry")]
348+
#endif
285349
private static extern int sentry_get_crashed_last_run();
286350

351+
#if SENTRY_NATIVE_STATIC
352+
[DllImport("__Internal")]
353+
#else
287354
[DllImport("sentry")]
355+
#endif
288356
private static extern int sentry_clear_crashed_last_run();
289357

358+
#if SENTRY_NATIVE_STATIC
359+
[DllImport("__Internal")]
360+
#else
290361
[DllImport("sentry")]
362+
#endif
291363
private static extern void sentry_reinstall_backend();
292364
}

src/Sentry.Unity/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Runtime.CompilerServices;
22

33
[assembly: InternalsVisibleTo("Sentry.Unity.Native")]
4+
[assembly: InternalsVisibleTo("Sentry.Unity.Native.Console")]
45
[assembly: InternalsVisibleTo("Sentry.Unity.Tests")]
56
[assembly: InternalsVisibleTo("Sentry.Unity.Editor")]
67
[assembly: InternalsVisibleTo("Sentry.Unity.Editor.Tests")]

test/Scripts.Tests/package-release.zip.snapshot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ Runtime/Sentry.Unity.iOS.dll
279279
Runtime/Sentry.Unity.iOS.dll.meta
280280
Runtime/Sentry.Unity.iOS.pdb
281281
Runtime/Sentry.Unity.iOS.pdb.meta
282+
Runtime/Sentry.Unity.Native.Console.dll
283+
Runtime/Sentry.Unity.Native.Console.dll.meta
284+
Runtime/Sentry.Unity.Native.Console.pdb
285+
Runtime/Sentry.Unity.Native.Console.pdb.meta
282286
Runtime/Sentry.Unity.Native.dll
283287
Runtime/Sentry.Unity.Native.dll.meta
284288
Runtime/Sentry.Unity.Native.pdb

0 commit comments

Comments
 (0)