Skip to content

Commit

Permalink
feat: sentry-native macOS integration (#2767)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind authored Nov 1, 2023
1 parent 835226b commit 63a05ba
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 5 deletions.
1 change: 1 addition & 0 deletions Sentry-CI-Build-macOS.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"src\\Sentry.Azure.Functions.Worker\\Sentry.Azure.Functions.Worker.csproj",
"src\\Sentry.Bindings.Android\\Sentry.Bindings.Android.csproj",
"src\\Sentry.Bindings.Cocoa\\Sentry.Bindings.Cocoa.csproj",
"src\\Sentry.Bindings.Native\\Sentry.Bindings.Native.csproj",
"src\\Sentry.DiagnosticSource\\Sentry.DiagnosticSource.csproj",
"src\\Sentry.EntityFramework\\Sentry.EntityFramework.csproj",
"src\\Sentry.Extensions.Logging\\Sentry.Extensions.Logging.csproj",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
<!--
After the above properties are configured, you can use the following features.
Uploading sources to Sentry during the build will enable Source Context in the Sentry issue details page.
Uploading symbols to Sentry will enable server-side symbolication. However, that is not necessary here
because the PDB file is present at runtime. Thus, .NET will symbolicate stack traces client-side.
Uploading symbols to Sentry will enable server-side symbolication (i.e. when the PDB is not present at runtime, or for AOT published programs).
-->
<SentryUploadSources>true</SentryUploadSources>
<SentryUploadSymbols>false</SentryUploadSymbols>
<SentryUploadSymbols>true</SentryUploadSymbols>
</PropertyGroup>


Expand Down
1 change: 0 additions & 1 deletion scripts/generate-solution-filters-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ filterConfigs:
- "**/*Maui.Device.TestApp.csproj"
- "**/*SourceGen.csproj"
- "**/Sentry.Samples.Android.csproj"
- "**/Sentry.Bindings.Native.csproj"

- outputPath: Sentry-CI-Build-Windows.slnf
include:
Expand Down
41 changes: 41 additions & 0 deletions src/Sentry.Bindings.Native/Sentry.Bindings.Native.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<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>
<NativeLibRelativePath-osx>osx\native\</NativeLibRelativePath-osx>
<SentryNativeOutputDirectory-osx>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-osx)</SentryNativeOutputDirectory-osx>
</PropertyGroup>

<!-- Packaging -->
Expand Down Expand Up @@ -48,6 +50,14 @@
</None>
</ItemGroup>

<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or $([MSBuild]::IsOsPlatform('OSX'))">
<None Include="$(SentryNativeOutputDirectory-osx)lib$(SentryNativeLibraryName).a">
<Pack>true</Pack>
<PackagePath>\runtimes\$(NativeLibRelativePath-osx)</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<Target Name="CleanNativeSDK" BeforeTargets="CoreClean">
<Message Text="Inside Custom Clean" Importance="high"/>
<RemoveDir Directories="$(SentryNativeOutputDirectory)" />
Expand Down Expand Up @@ -120,4 +130,35 @@
<Copy SourceFiles="@(NativeSdkArtifacts)"
DestinationFiles="@(NativeSdkArtifacts->'$(SentryNativeOutputDirectory-linux-x64)%(Filename)-native%(Extension)')" />
</Target>

<Target Name="_BuildSentryNativeSDK-osx"
BeforeTargets="DispatchToInnerBuilds;BeforeBuild"
Condition="$([MSBuild]::IsOsPlatform('OSX'))"
Inputs="..\..\.git\modules\modules\sentry-native\HEAD;$(MSBuildThisFileDirectory)Sentry.Bindings.Native.csproj"
Outputs="$(SentryNativeOutputDirectory-osx)lib$(SentryNativeLibraryName).a">
<MSBuild Projects="$(MSBuildProjectFile)"
Targets="_InnerBuildSentryNativeSDK-osx"
Properties="TargetFramework=once" />
</Target>

<Target Name="_InnerBuildSentryNativeSDK-osx">
<Message Importance="High"
Text="Building artifacts of Sentry Native SDK for osx." />

<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 \
-DCMAKE_OSX_ARCHITECTURES=&quot;arm64;x86_64&quot;" />
<Exec WorkingDirectory="$(SentryNativeSourceDirectory)" Command="cmake --build build --target sentry --parallel" />

<ItemGroup>
<NativeSdkArtifacts Include="$(SentryNativeSourceDirectory)build/libsentry.a" />
</ItemGroup>
<Copy SourceFiles="@(NativeSdkArtifacts)"
DestinationFiles="@(NativeSdkArtifacts->'$(SentryNativeOutputDirectory-osx)%(Filename)-native%(Extension)')" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@
<!-- Link statically -->
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\runtimes\linux-x64\native\libsentry-native.a" />
</ItemGroup>

<ItemGroup Condition="'$(OutputType)' == 'Exe' And ('$(RuntimeIdentifier)' == 'osx-x64' or '$(RuntimeIdentifier)' == 'osx-arm64')">
<!-- Generate direct PInvokes for Dependency -->
<DirectPInvoke Include="sentry-native" />

<!-- Link statically -->
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\runtimes\osx\native\libsentry-native.a" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Sentry/Sentry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- Platform-specific props included here -->
<Import Project="Platforms\Android\Sentry.Android.props" Condition="'$(TargetPlatformIdentifier)' == 'android'" />
<Import Project="Platforms\iOS\Sentry.iOS.props" Condition="'$(TargetPlatformIdentifier)' == 'ios' Or '$(TargetPlatformIdentifier)' == 'maccatalyst'" />
<Import Project="Platforms\Native\Sentry.Native.props" Condition="('$(TargetFramework)' == 'net7.0' Or '$(TargetFramework)' == 'net8.0') And ($([MSBuild]::IsOSPlatform('Linux')) Or $([MSBuild]::IsOSPlatform('Windows')))" />
<Import Project="Platforms\Native\Sentry.Native.props" Condition="('$(TargetFramework)' == 'net7.0' Or '$(TargetFramework)' == 'net8.0')" />

<!--
Ben.Demystifier is compiled directly into Sentry.
Expand Down

0 comments on commit 63a05ba

Please sign in to comment.