-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
sentry-native SDK integration #2704
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4fe3227
native bridge from unity
bruno-garcia 8b6fb29
bridge native
bruno-garcia 545544f
mac bridge
bruno-garcia b964139
pack
bruno-garcia ba8f995
cocoa binding
bruno-garcia fbac943
console runs
bruno-garcia 47cd5b1
crash cli natively
bruno-garcia dcee9d4
crash captured by sentry cocoa
bruno-garcia c28271a
Merge remote-tracking branch 'origin/feat/4.0.0' into feat/native-cra…
vaind d71c58a
trying to get this to compile
vaind abc3543
fix compilation
vaind e1e5927
chore: remove macos stuff
vaind 56d181e
remove more macos stuff
vaind 5c6a94d
windows net48 test issue
vaind 5896483
feat: add sentry-native submodule & bindings project
vaind 144f1c3
restore unintended formatting changs
vaind 041deaa
chore: update solution filters
vaind e999663
update native bindings msbuild
vaind 47f5758
native packaging
vaind 6037759
trim trailing spaces
vaind 4c515b3
wip: native lib static linking
vaind 476e538
refactor: change DebugImage.ImageAddress to long
vaind 4ff2d58
finish native debug image collection
vaind f509b42
native aot linux support
vaind 42b8096
Merge branch 'feat/4.0.0' into feat/sentry-native-integration
vaind 9607da4
remove unused native binding code
vaind 29d02a4
fixup changelog
vaind 146f2a0
chore: remove unused code
vaind 5700783
chore: add sentry-native updater entry
vaind 5922415
chore: update changelog
vaind 17133c3
fixup: log an unexpected image
vaind eb30270
chore: remove unnecessary todo
vaind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule sentry-native
added at
79899a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
runtimes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This package supports the Sentry SDK for .NET. It is not intended to be referenced directly. | ||
Instead, reference the main package: | ||
|
||
- [`Sentry`](https://www.nuget.org/packages/Sentry) |
125 changes: 125 additions & 0 deletions
125
src/Sentry.Bindings.Native/Sentry.Bindings.Native.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<Description>.NET Bindings for the Sentry Native SDK</Description> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<SentryNativeSourceDirectory>..\..\modules\sentry-native\</SentryNativeSourceDirectory> | ||
<SentryNativeLibraryName>sentry-native</SentryNativeLibraryName> | ||
<SentryNativeOutputDirectory>$(MSBuildThisFileDirectory)runtimes\</SentryNativeOutputDirectory> | ||
<!-- List of runtime identifiers: https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json --> | ||
<NativeLibRelativePath-win-x64>win-x64\native\</NativeLibRelativePath-win-x64> | ||
<SentryNativeOutputDirectory-win-x64>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-win-x64)</SentryNativeOutputDirectory-win-x64> | ||
<NativeLibRelativePath-linux-x64>linux-x64\native\</NativeLibRelativePath-linux-x64> | ||
<SentryNativeOutputDirectory-linux-x64>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-linux-x64)</SentryNativeOutputDirectory-linux-x64> | ||
</PropertyGroup> | ||
|
||
<!-- Packaging --> | ||
<ItemGroup> | ||
<!-- Use a separate readme file in the nuget. --> | ||
<None Remove="$(MSBuildThisFileDirectory)..\..\README.md" /> | ||
<None Include="$(MSBuildThisFileDirectory)README.md" | ||
Pack="true" | ||
PackagePath="" /> | ||
|
||
<!-- Don't add the changelog to the nuget. --> | ||
<PackageReference Remove="SIL.ReleaseTasks" /> | ||
|
||
<!-- Include our transitive build targets in the nuget. --> | ||
<None Include="buildTransitive\Sentry.Bindings.Native.targets"> | ||
<Pack>true</Pack> | ||
<PackagePath>buildTransitive\</PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
<!-- Packaging the native library --> | ||
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or $([MSBuild]::IsOsPlatform('Windows'))"> | ||
<NativeLibs Include="$(SentryNativeOutputDirectory-win-x64)$(SentryNativeLibraryName).lib" /> | ||
<NativeLibs Include="$(SentryNativeOutputDirectory-win-x64)$(SentryNativeLibraryName).pdb" /> | ||
<None Include="@(NativeLibs)"> | ||
<Pack>true</Pack> | ||
<PackagePath>\runtimes\$(NativeLibRelativePath-win-x64)</PackagePath> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or $([MSBuild]::IsOsPlatform('Linux'))"> | ||
<None Include="$(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a"> | ||
<Pack>true</Pack> | ||
<PackagePath>\runtimes\$(NativeLibRelativePath-linux-x64)</PackagePath> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<Target Name="CleanNativeSDK" BeforeTargets="CoreClean"> | ||
<Message Text="Inside Custom Clean" Importance="high"/> | ||
<RemoveDir Directories="$(SentryNativeOutputDirectory)" /> | ||
<RemoveDir Directories="$(SentryNativeSourceDirectory)build" /> | ||
</Target> | ||
|
||
<!-- Build the Sentry Native SDK --> | ||
<Target Name="_BuildSentryNativeSDK-win-x64" | ||
BeforeTargets="DispatchToInnerBuilds;BeforeBuild" | ||
Condition="$([MSBuild]::IsOsPlatform('Windows'))" | ||
Inputs="..\..\.git\modules\modules\sentry-native\HEAD;$(MSBuildThisFileDirectory)Sentry.Bindings.Native.csproj" | ||
Outputs="$(SentryNativeOutputDirectory-win-x64)$(SentryNativeLibraryName).lib;$(SentryNativeOutputDirectory-win-x64)$(SentryNativeLibraryName).pdb"> | ||
<MSBuild Projects="$(MSBuildProjectFile)" | ||
Targets="_InnerBuildSentryNativeSDK-win-x64" | ||
Properties="TargetFramework=once" /> | ||
</Target> | ||
|
||
<Target Name="_InnerBuildSentryNativeSDK-win-x64"> | ||
<Message Importance="High" | ||
Text="Building artifacts of Sentry Native SDK for win-x64." /> | ||
|
||
<Exec WorkingDirectory="$(SentryNativeSourceDirectory)" | ||
Command="cmake -B build -S . ^ | ||
-D SENTRY_SDK_NAME=sentry.native.dotnet ^ | ||
-D SENTRY_BUILD_SHARED_LIBS=0 ^ | ||
-D SENTRY_BUILD_RUNTIMESTATIC=1 ^ | ||
-D SENTRY_BACKEND=none ^ | ||
-D SENTRY_TRANSPORT=none " /> | ||
<Exec WorkingDirectory="$(SentryNativeSourceDirectory)" | ||
Command="cmake --build build --target sentry --config RelWithDebInfo --parallel" /> | ||
|
||
<ItemGroup> | ||
<NativeSdkArtifacts Include="$(SentryNativeSourceDirectory)build/RelWithDebInfo/sentry.lib" /> | ||
<NativeSdkArtifacts Include="$(SentryNativeSourceDirectory)build/RelWithDebInfo/sentry.pdb" /> | ||
</ItemGroup> | ||
|
||
<Copy SourceFiles="@(NativeSdkArtifacts)" | ||
DestinationFiles="@(NativeSdkArtifacts->'$(SentryNativeOutputDirectory-win-x64)%(Filename)-native%(Extension)')" /> | ||
|
||
<!-- Explicitly update timestamp on output files so that this target doesn't run again even if the CMake build reused previously built artifacts. --> | ||
<Touch Files="@(NativeSdkArtifacts)" /> | ||
</Target> | ||
|
||
<Target Name="_BuildSentryNativeSDK-linux-x64" | ||
BeforeTargets="DispatchToInnerBuilds;BeforeBuild" | ||
Condition="$([MSBuild]::IsOsPlatform('Linux'))" | ||
Inputs="..\..\.git\modules\modules\sentry-native\HEAD;$(MSBuildThisFileDirectory)Sentry.Bindings.Native.csproj" | ||
Outputs="$(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a"> | ||
<MSBuild Projects="$(MSBuildProjectFile)" | ||
Targets="_InnerBuildSentryNativeSDK-linux-x64" | ||
Properties="TargetFramework=once" /> | ||
</Target> | ||
|
||
<Target Name="_InnerBuildSentryNativeSDK-linux-x64"> | ||
<Message Importance="High" | ||
Text="Building artifacts of Sentry Native SDK for linux-x64." /> | ||
|
||
<Exec WorkingDirectory="$(SentryNativeSourceDirectory)" | ||
Command="cmake -B build -S . \ | ||
-D CMAKE_BUILD_TYPE=RelWithDebInfo \ | ||
-D SENTRY_SDK_NAME=sentry.native.dotnet \ | ||
-D SENTRY_BUILD_SHARED_LIBS=0 \ | ||
-D SENTRY_BACKEND=none \ | ||
-D SENTRY_TRANSPORT=none " /> | ||
<Exec WorkingDirectory="$(SentryNativeSourceDirectory)" Command="cmake --build build --target sentry --parallel" /> | ||
|
||
<ItemGroup> | ||
<NativeSdkArtifacts Include="$(SentryNativeSourceDirectory)build/libsentry.a" /> | ||
</ItemGroup> | ||
<Copy SourceFiles="@(NativeSdkArtifacts)" | ||
DestinationFiles="@(NativeSdkArtifacts->'$(SentryNativeOutputDirectory-linux-x64)%(Filename)-native%(Extension)')" /> | ||
</Target> | ||
</Project> |
24 changes: 24 additions & 0 deletions
24
src/Sentry.Bindings.Native/buildTransitive/Sentry.Bindings.Native.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project> | ||
<ItemGroup Condition="'$(OutputType)' == 'Exe' And '$(RuntimeIdentifier)' == 'win-x64'"> | ||
<!-- Generate direct PInvokes for Dependency --> | ||
<DirectPInvoke Include="sentry-native" /> | ||
|
||
<!-- Link statically --> | ||
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\native\sentry-native.lib" /> | ||
<NativeLibrary Include="dbghelp.lib" /> | ||
|
||
<!-- Copy debug symbols to the app output directory so that it can get uploaded by Sentry CLI. --> | ||
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\native\sentry-native.pdb"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
<Link>%(FileName)%(Extension)</Link> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(OutputType)' == 'Exe' And '$(RuntimeIdentifier)' == 'linux-x64'"> | ||
<!-- Generate direct PInvokes for Dependency --> | ||
<DirectPInvoke Include="sentry-native" /> | ||
|
||
<!-- Link statically --> | ||
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\runtimes\linux-x64\native\libsentry-native.a" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine this
CI_PUBLISHING_BUILD
stuff is on the other binding projects and got copied here. But why do we need this? I'm concerned about stuff behaving differently in CI vs locallyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's intentional here though not yet necessary, I've extracted that as a "next step" in the PR description:
As to why: because we can't build all platforms on a single machine and I don't really want to do the download from a CI job the way I had to do in sentry-unity because that is very painful whenever there's a change, e.g. you want to run different sentry-native version on your branch than what has been compiled as an artifact on the main branch.
The way this project is currently implemented is that it compiles for your platform locally and only if necessary (i.e. sentry-native submodule checkout has changed or if there's a change in this
Sentry.Bindings.Native.csproj
file). In CI, it will collect and package for all platforms. At least that's the idea.