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: sentry-native macOS integration #2767

Merged
merged 3 commits into from
Nov 1, 2023
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
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
Loading