Skip to content

Commit

Permalink
chore: include debug info in sentry-native static build (#2765)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind authored Nov 1, 2023
1 parent a448ab3 commit 835226b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
10 changes: 4 additions & 6 deletions src/Sentry.Bindings.Native/Sentry.Bindings.Native.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@

<!-- 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)">
<None Include="$(SentryNativeOutputDirectory-win-x64)$(SentryNativeLibraryName).lib">
<Pack>true</Pack>
<PackagePath>\runtimes\$(NativeLibRelativePath-win-x64)</PackagePath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand All @@ -61,7 +59,7 @@
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">
Outputs="$(SentryNativeOutputDirectory-win-x64)$(SentryNativeLibraryName).lib">
<MSBuild Projects="$(MSBuildProjectFile)"
Targets="_InnerBuildSentryNativeSDK-win-x64"
Properties="TargetFramework=once" />
Expand All @@ -77,13 +75,13 @@
-D SENTRY_BUILD_SHARED_LIBS=0 ^
-D SENTRY_BUILD_RUNTIMESTATIC=1 ^
-D SENTRY_BACKEND=none ^
-D SENTRY_TRANSPORT=none " />
-D SENTRY_TRANSPORT=none ^
-C $(MSBuildThisFileDirectory)windows-config.cmake" />
<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)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@
<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>
Expand Down
3 changes: 3 additions & 0 deletions src/Sentry.Bindings.Native/windows-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Include debug info in the static library itself. See https://github.com/getsentry/sentry-native/issues/895 for context.
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Z7 /O2 /Ob1 /DNDEBUG" CACHE STRING "C Flags for RelWithDebInfo" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Z7 /O2 /Ob1 /DNDEBUG" CACHE STRING "CXX Flags for RelWithDebInfo" FORCE)

0 comments on commit 835226b

Please sign in to comment.