Skip to content
Open
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
10 changes: 10 additions & 0 deletions modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ To make sure we're not exposing any API from that library externally.
Fork [getsentry/perfview](https://github.com/getsentry/perfview/).
Tool from the .NET team which includes several utilities used for profiling .NET code.
We use that in our `Sentry.Profiling` package.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we also miss an entry for sentry-native ... but that's not part of this changeset ... I can follow-up on that afterwards.

### sentry-cocoa

By default, `Sentry.Bindings.Cocoa` downloads a pre-built Sentry Cocoa SDK from
GitHub Releases. The version is specified in `sentry-cocoa.properties`.

If you want to build an unreleased Sentry Cocoa SDK version from source instead,
replace the pre-built SDK with [getsentry/sentry-cocoa](https://github.com/getsentry/sentry-cocoa/)
by cloning it into the `modules/sentry-cocoa` directory. To switch back to the
pre-built SDK, delete the `modules/sentry-cocoa` directory.
4 changes: 2 additions & 2 deletions scripts/build-sentry-cocoa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ echo "::endgroup::"

# Copy headers - used for generating bindings
mkdir Carthage/Headers
find Carthage/Build-ios/Sentry.xcframework/ios-arm64 -name '*.h' -exec cp {} Carthage/Headers \;
find Carthage/Build-ios/Sentry.xcframework/ios-arm64_arm64e -name '*.h' -exec cp {} Carthage/Headers \;

# Remove anything we don't want to bundle in the nuget package.
find Carthage/Build* \( -name Headers -o -name PrivateHeaders -o -name Modules \) -exec rm -rf {} +
rm -rf Carthage/output-*

cp ../../.git/modules/modules/sentry-cocoa/HEAD Carthage/.built-from-sha
cp .git/HEAD Carthage/.built-from-sha
echo ""

popd >/dev/null
22 changes: 17 additions & 5 deletions scripts/generate-cocoa-bindings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

$RootPath = (Get-Item $PSScriptRoot).Parent.FullName
$CocoaSdkPath = "$RootPath/modules/sentry-cocoa/Sentry.framework"
$CocoaSdkPath = "$RootPath/modules/sentry-cocoa"
if (Test-Path "$CocoaSdkPath/.git")
{
# Cocoa SDK cloned to modules/sentry-cocoa for local development
$HeadersPath = "$CocoaSdkPath/Carthage/Headers"
$PrivateHeadersPath = "$CocoaSdkPath/Carthage/Headers"
}
else
{
# Cocoa SDK downloaded from GitHub releases and extracted into modules/sentry-cocoa
$HeadersPath = "$CocoaSdkPath/Sentry.framework/Headers"
$PrivateHeadersPath = "$CocoaSdkPath/Sentry.framework/PrivateHeaders"
}
$BindingsPath = "$RootPath/src/Sentry.Bindings.Cocoa"
$BackupPath = "$BindingsPath/obj/_unpatched"

Expand Down Expand Up @@ -101,7 +113,7 @@ Write-Output "iPhoneSdkVersion: $iPhoneSdkVersion"
# ...instead of:
# `#import "SomeHeader.h"`
# This causes sharpie to fail resolve those headers
$filesToPatch = Get-ChildItem -Path "$CocoaSdkPath/Headers" -Filter *.h -Recurse | Select-Object -ExpandProperty FullName
$filesToPatch = Get-ChildItem -Path "$HeadersPath" -Filter *.h -Recurse | Select-Object -ExpandProperty FullName
foreach ($file in $filesToPatch)
{
if (Test-Path $file)
Expand All @@ -116,7 +128,7 @@ foreach ($file in $filesToPatch)
Write-Host "File not found: $file"
}
}
$privateHeaderFile = "$CocoaSdkPath/PrivateHeaders/PrivatesHeader.h"
$privateHeaderFile = "$PrivateHeadersPath/PrivatesHeader.h"
if (Test-Path $privateHeaderFile)
{
$content = Get-Content -Path $privateHeaderFile -Raw
Expand All @@ -134,8 +146,8 @@ else
Write-Output 'Generating bindings with Objective Sharpie.'
sharpie bind -sdk $iPhoneSdkVersion `
-scope "$CocoaSdkPath" `
"$CocoaSdkPath/Headers/Sentry.h" `
"$CocoaSdkPath/PrivateHeaders/PrivateSentrySDKOnly.h" `
"$HeadersPath/Sentry.h" `
"$PrivateHeadersPath/PrivateSentrySDKOnly.h" `
-o $BindingsPath `
-c -Wno-objc-property-no-attribute

Expand Down
33 changes: 27 additions & 6 deletions src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@
<SentryCocoaProperties>$([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)../../modules/sentry-cocoa.properties"))</SentryCocoaProperties>
<SentryCocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($(SentryCocoaProperties), 'version\s*=\s*([^\s]+)').Groups[1].Value)</SentryCocoaVersion>
<SentryCocoaFramework>$(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework</SentryCocoaFramework>
<SentryCocoaBindingInputs>../../modules/sentry-cocoa.properties;../../scripts/generate-cocoa-bindings.ps1</SentryCocoaBindingInputs>
<!-- SentrySpan.g.cs: error CS0108: 'ISentrySpan.Serialize()' hides inherited member 'ISentrySerializable.Serialize()'. Use the new keyword if hiding was intended -->
<NoWarn>$(NoWarn);CS0108</NoWarn>
</PropertyGroup>

<!-- Override values for local Cocoa SDK builds -->
<PropertyGroup Condition="Exists('$(SentryCocoaCache).git')">
<SentryCocoaFramework>$(SentryCocoaCache)Carthage\Build-$(TargetPlatformIdentifier)\Sentry.xcframework</SentryCocoaFramework>
<SentryCocoaBindingInputs>../../scripts/generate-cocoa-bindings.ps1;../../modules/sentry-cocoa/Carthage/.built-from-sha</SentryCocoaBindingInputs>
</PropertyGroup>

<!-- Build empty assemblies when not on macOS, to pass the solution build. -->
<ItemGroup Condition="!$([MSBuild]::IsOSPlatform('OSX'))">
<Compile Remove="*" />
Expand Down Expand Up @@ -52,8 +59,8 @@
</ItemGroup>

<!-- Downloads and sets up the Cocoa SDK: dotnet msbuild /t:setupCocoaSDK src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj -->
<Target Name="_SetupCocoaSDK"
Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(SentryCocoaFramework)')">
<Target Name="_DownloadCocoaSDK"
Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(SentryCocoaCache).git') And !Exists('$(SentryCocoaFramework)')">

<Message Importance="High" Text="Setting up the Cocoa SDK version '$(SentryCocoaVersion)'." />

Expand Down Expand Up @@ -84,14 +91,28 @@
SkipUnchangedFiles="true" />
</Target>

<!-- Build the Sentry Cocoa SDK from source -->
<Target Name="_BuildCocoaSDK"
Condition="$([MSBuild]::IsOSPlatform('OSX')) And Exists('$(SentryCocoaCache).git')"
Inputs="..\..\modules\sentry-cocoa\.git\HEAD;..\..\scripts\build-sentry-cocoa.sh" Outputs="..\..\modules\sentry-cocoa\Carthage\.built-from-sha">

<Message Importance="High" Text="Building the Cocoa SDK from source." />
<Exec Command="bash ../../scripts/build-sentry-cocoa.sh" IgnoreStandardErrorWarningFormat="true" />
</Target>

<!-- Choose between download and build -->
<Target Name="_SetupCocoaSDK"
DependsOnTargets="_DownloadCocoaSDK;_BuildCocoaSDK"
Condition="$([MSBuild]::IsOSPlatform('OSX'))" />

<!-- Setup exactly once: https://learn.microsoft.com/visualstudio/msbuild/run-target-exactly-once -->
<Target Name="SetupCocoaSDKBeforeOuterBuild" DependsOnTargets="_SetupCocoaSDK"
Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(SentryCocoaFramework)')"
Condition="$([MSBuild]::IsOSPlatform('OSX'))"
BeforeTargets="DispatchToInnerBuilds" />

<Target Name="SetupCocoaSDK"
BeforeTargets="BeforeBuild"
Condition="$([MSBuild]::IsOSPlatform('OSX')) And !Exists('$(SentryCocoaFramework)')">
Condition="$([MSBuild]::IsOSPlatform('OSX'))">
<!-- Setup exactly once: https://learn.microsoft.com/visualstudio/msbuild/run-target-exactly-once -->
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_SetupCocoaSDK" RemoveProperties="TargetFramework" />
</Target>
Expand All @@ -102,8 +123,8 @@

<!-- Generate bindings -->
<Target Name="_GenerateSentryCocoaBindings" AfterTargets="SetupCocoaSDK"
Condition="$([MSBuild]::IsOSPlatform('OSX')) and Exists('$(SentryCocoaFrameworkHeaders)')"
Inputs="../../modules/sentry-cocoa.properties;../../scripts/generate-cocoa-bindings.ps1"
Condition="$([MSBuild]::IsOSPlatform('OSX'))"
Inputs="$(SentryCocoaBindingInputs)"
Outputs="ApiDefinitions.cs;StructsAndEnums.cs">
<MSBuild Projects="$(MSBuildProjectFile)" Targets="_InnerGenerateSentryCocoaBindings" Properties="TargetFramework=once" />
</Target>
Expand Down
Loading