Skip to content
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

Feat: desktop crash support #699

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ package-dev/**/*.meta
package-dev/**/*.framework
package-dev/**/*.pdb
package-dev/**/*.xml
package-dev/**/*.dylib
package-dev/**/*.dSYM
package-dev/**/TestSentryOptions.json
package-dev/Tests/Editor/TestFiles/
package-dev/Plugins/*/Sentry/crashpad_handler*

# Adding .meta to control target platforms for all of our DLLs
!package-dev/**/Sentry*.dll.meta
!package-dev/**/libsentry.dylib.meta

# required to be marked as iOS only
!package-dev/**/*.framework.meta
Expand Down
30 changes: 28 additions & 2 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<SentryAndroidArtifactsDestination>$(SentryArtifactsDestination)/Android/Sentry/</SentryAndroidArtifactsDestination>
<!-- Native -->
<SentryNativeRoot>$(RepoRoot)modules/sentry-native/</SentryNativeRoot>
<SentrymacOSArtifactsDestination>$(SentryArtifactsDestination)/macOS/Sentry/</SentrymacOSArtifactsDestination>
<SentryWindowsArtifactsDestination>$(SentryArtifactsDestination)/Windows/Sentry/</SentryWindowsArtifactsDestination>
</PropertyGroup>

Expand Down Expand Up @@ -117,8 +118,9 @@ Expected to exist:
<RemoveDir Directories="$(SentryAndroidArtifactsDestination)" ContinueOnError="true" />
</Target>

<Target Name="CleanWindowsSDK" AfterTargets="Clean" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
<Target Name="CleanNativeSDK" AfterTargets="Clean" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
<RemoveDir Directories="$(SentryNativeRoot)build/" ContinueOnError="true" />
<RemoveDir Directories="$(SentrymacOSArtifactsDestination)" ContinueOnError="true" />
<RemoveDir Directories="$(SentryWindowsArtifactsDestination)" ContinueOnError="true" />
</Target>

Expand Down Expand Up @@ -168,6 +170,26 @@ Expected to exist:
<Error Condition="!Exists('$(SentryAndroidArtifactsDestination)')" Text="Failed to build the Android SDK."></Error>
</Target>

<!-- Build the Sentry Native SDK for macOS: dotnet msbuild /t:BuildmacOSSDK src/Sentry.Unity -->
<Target Name="BuildmacOSSDK" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'
And $([MSBuild]::IsOsPlatform('OSX'))
And !Exists('$(SentrymacOSArtifactsDestination)')" DependsOnTargets="BuildNativeSDK" BeforeTargets="BeforeBuild">
<Error Condition="!Exists('$(SentryNativeRoot)')" Text="Couldn't find the Native root at $(SentryNativeRoot)."></Error>
<Message Importance="High" Text="Copying artifacts of Sentry Native SDK for macOS to UPM package."></Message>

<ItemGroup>
<NativeSdkArtifacts Include="$(SentryNativeRoot)build/crashpad_build/handler/crashpad_handler" />
<NativeSdkArtifacts Include="$(SentryNativeRoot)build/libsentry.dylib" />
</ItemGroup>

<ItemGroup>
<NativeSdkDebugSymbols Include="$(SentryNativeRoot)build/libsentry.dylib.dSYM/**/*.*" />
</ItemGroup>

<Copy SourceFiles="@(NativeSdkArtifacts)" DestinationFiles="@(NativeSdkArtifacts->'$(SentrymacOSArtifactsDestination)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(NativeSdkDebugSymbols)" DestinationFiles="$(SentrymacOSArtifactsDestination)/libsentry.dylib.dSYM/%(RecursiveDir)%(Filename)%(Extension)" />
</Target>

<!-- Build the Sentry Native SDK for Windows: dotnet msbuild /t:BuildWindowsSDK src/Sentry.Unity -->
<Target Name="BuildWindowsSDK" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'
And $([MSBuild]::IsOsPlatform('Windows'))
Expand All @@ -187,7 +209,11 @@ Expected to exist:
<Target Name="BuildNativeSDK">
<Error Condition="!Exists('$(SentryNativeRoot)')" Text="Couldn't find the Native root at $(SentryNativeRoot)."></Error>

<Exec WorkingDirectory="$(SentryNativeRoot)" Command="cmake -B build -D SENTRY_BACKEND=crashpad -S ."></Exec>
<Exec Command="which python3" ConsoleToMSBuild="true" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="PythonExecutable" />
</Exec>

<Exec WorkingDirectory="$(SentryNativeRoot)" Command="cmake -B build -D SENTRY_BACKEND=crashpad -D CMAKE_OSX_ARCHITECTURES=&quot;arm64;x86_64&quot; -D PYTHON_EXECUTABLE=$(PythonExecutable) -S ."></Exec>
<Exec WorkingDirectory="$(SentryNativeRoot)" Command="cmake --build build --target sentry --config RelWithDebInfo --parallel"></Exec>
<Exec WorkingDirectory="$(SentryNativeRoot)" Command="cmake --build build --target crashpad_handler --config Release --parallel"></Exec>
</Target>
Expand Down

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

81 changes: 81 additions & 0 deletions package-dev/Plugins/macOS/Sentry/libsentry.dylib.meta

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

6 changes: 3 additions & 3 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.

13 changes: 9 additions & 4 deletions package-dev/Runtime/SentryInitialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
#define SENTRY_NATIVE_IOS
#elif UNITY_ANDROID
#define SENTRY_NATIVE_ANDROID
// After enabling support for Linux, we can use UNITY_STANDALONE:
// #elif UNITY_STANDALONE && ENABLE_IL2CPP
// #define SENTRY_NATIVE_STANDALONE
#elif UNITY_STANDALONE_WIN && ENABLE_IL2CPP
#define SENTRY_NATIVE_WINDOWS
#define SENTRY_NATIVE_STANDALONE
#elif UNITY_STANDALONE_OSX && ENABLE_IL2CPP
#define SENTRY_NATIVE_STANDALONE
#elif UNITY_WEBGL
#define SENTRY_WEBGL
#endif
Expand All @@ -15,9 +20,9 @@

#if SENTRY_NATIVE_IOS
using Sentry.Unity.iOS;
#elif UNITY_ANDROID
#elif SENTRY_NATIVE_ANDROID
using Sentry.Unity.Android;
#elif SENTRY_NATIVE_WINDOWS
#elif SENTRY_NATIVE_STANDALONE
using Sentry.Unity.Native;
#elif SENTRY_WEBGL
using Sentry.Unity.WebGL;
Expand All @@ -41,7 +46,7 @@ public static void Init()
SentryNativeIos.Configure(options);
#elif SENTRY_NATIVE_ANDROID
SentryNativeAndroid.Configure(options, sentryUnityInfo);
#elif SENTRY_NATIVE_WINDOWS
#elif SENTRY_NATIVE_STANDALONE
SentryNative.Configure(options);
#elif SENTRY_WEBGL
SentryWebGL.Configure(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ MonoBehaviour:
<IosNativeSupportEnabled>k__BackingField: 1
<AndroidNativeSupportEnabled>k__BackingField: 1
<WindowsNativeSupportEnabled>k__BackingField: 1
<MacosNativeSupportEnabled>k__BackingField: 1
<OptionsConfiguration>k__BackingField: {fileID: 11400000, guid: bda1a724b0875436aade31393b0129c0,
type: 2}
<Debug>k__BackingField: 1
Expand Down
7 changes: 5 additions & 2 deletions src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ internal static void Display(ScriptableSentryUnityOptions options)
options.AndroidNativeSupportEnabled);

options.WindowsNativeSupportEnabled = EditorGUILayout.Toggle(
new GUIContent("Windows Native Support", "Whether to enable Native Windows support to " +
"capture errors written in languages such as C and C++."),
new GUIContent("Windows Native Support", "Whether to enable native crashes support on Windows."),
options.WindowsNativeSupportEnabled);

options.MacosNativeSupportEnabled = EditorGUILayout.Toggle(
new GUIContent("macOS Native Support", "Whether to enable native crashes support on macOS."),
options.MacosNativeSupportEnabled);
}


Expand Down
Loading