Skip to content

Commit 4ec6db1

Browse files
tustanivskyvaind
andauthored
Add debug symbols upload (#59)
* Add CLI tools * Add debug symbols upload for iOS, Mac and Linux * Add debug symbols upload script for Windows * Fix errors with debug symbols upload on Linux * Remove redundant script * Update location of symbols upload scripts * Update .gitignore * Fix packaging issue on Linux * Add plugin binaries symbols upload * Remove Sentry CLI binaries * Fix download script * Fix workflow * Fix script name * Fix workflow once again * Fix empty line * Fix typo * Fix CLI pathj * Remo redundant message * Fix CLI download sript * Remo user credentials for debug symbols upload from plugin settings * Update debug symbols upload script for win * Fix regex * Update changelog * chore: rename cli download script * use sentry.properties as a relative path * fix: android debug symbol upload * Fix issue with reading sentry.properties file path from settings on Mac Co-authored-by: Ivan Dlugos <[email protected]>
1 parent ed92731 commit 4ec6db1

20 files changed

+346
-157
lines changed

.github/workflows/ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ jobs:
4141
- name: Checkout
4242
uses: actions/checkout@v3
4343

44+
- name: Download CLI
45+
shell: pwsh
46+
run: ./scripts/download-cli.ps1
47+
4448
- uses: actions/download-artifact@v2
4549
with:
4650
name: Android-sdk

.github/workflows/update-dependencies.yml

+8
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,13 @@ jobs:
3131
with:
3232
path: modules/sentry-cocoa
3333
name: Cocoa SDK (iOS)
34+
secrets:
35+
api_token: ${{ secrets.CI_DEPLOY_KEY }}
36+
37+
cli:
38+
uses: getsentry/github-workflows/.github/workflows/updater.yml@v1
39+
with:
40+
path: modules/sentry-cli.properties
41+
name: CLI
3442
secrets:
3543
api_token: ${{ secrets.CI_DEPLOY_KEY }}

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Features
66

7+
- Add debug symbols upload ([#59](https://github.com/getsentry/sentry-unreal/pull/59))
78
- Bump Cocoa SDK (iOS) to v7.21.0 ([#37](https://github.com/getsentry/sentry-unreal/pull/37))
89
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7210)
910
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.14.0...7.21.0)

modules/sentry-cli.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version=2.5.0
2+
repo=https://github.com/getsentry/sentry-cli

plugin-dev/Config/FilterPlugin.ini

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
; /README.txt
77
; /Extras/...
88
; /Binaries/ThirdParty/*.dll
9+
10+
/Scripts/...

plugin-dev/Resources/sentry.properties

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
param([string] $TargetPlatform, [string] $TargetName, [string] $TargetType, [string] $ProjectPath, [string] $PluginPath)
2+
3+
$ProjectBinariesPath = "$ProjectPath\Binaries\$TargetPlatform"
4+
$PluginBinariesPath = "$PluginPath\Source\ThirdParty\$TargetPlatform"
5+
$ConfigPath = "$ProjectPath\Config"
6+
7+
Write-Host "Sentry: Start debug symbols upload"
8+
9+
If ($TargetType -eq "Editor")
10+
{
11+
Write-Host "Sentry: Automatic symbols upload is not required for Editor target. Skipping..."
12+
Exit
13+
}
14+
15+
If ($TargetPlatform -eq "Win64")
16+
{
17+
$CliExec = "$PluginPath\Source\ThirdParty\CLI\sentry-cli-Windows-x86_64.exe"
18+
}
19+
Else
20+
{
21+
Write-Warning "Sentry: Unexpected platform $TargetPlatform. Skipping..."
22+
Exit
23+
}
24+
25+
function ParseIniFile
26+
{
27+
param([parameter(Mandatory = $true)] [string] $filePath)
28+
29+
$anonymous = "NoSection"
30+
31+
$ini = @{}
32+
switch -regex -file $filePath
33+
{
34+
"^\[(.+)\]$" # Section
35+
{
36+
$section = $matches[1]
37+
$ini[$section] = @{}
38+
$CommentCount = 0
39+
}
40+
41+
"^(;.*)$" # Comment
42+
{
43+
if (!($section))
44+
{
45+
$section = $anonymous
46+
$ini[$section] = @{}
47+
}
48+
$value = $matches[1]
49+
$CommentCount = $CommentCount + 1
50+
$name = "Comment" + $CommentCount
51+
$ini[$section][$name] = $value
52+
}
53+
54+
"(.+?)\s*=\s*(.*)" # Key
55+
{
56+
if (!($section))
57+
{
58+
$section = $anonymous
59+
$ini[$section] = @{}
60+
}
61+
$name, $value = $matches[1..2]
62+
$ini[$section][$name] = $value
63+
}
64+
}
65+
66+
return $ini
67+
}
68+
69+
$ConfigIni = ParseIniFile "$ConfigPath\DefaultEngine.ini"
70+
$SentrySettingsSection = "/Script/Sentry.SentrySettings"
71+
72+
$UploadSymbols = $ConfigIni.$SentrySettingsSection.UploadSymbolsAutomatically
73+
74+
If ("$UploadSymbols".ToLower() -ne "true")
75+
{
76+
Write-Host "Sentry: Automatic symbols upload is disabled in plugin settings. Skipping..."
77+
Exit
78+
}
79+
80+
Write-Host "Sentry: Parse project settings"
81+
82+
$PropertiesFile = "$ProjectPath/$($ConfigIni.$SentrySettingsSection.PropertiesFilePath)".Replace('\', '/')
83+
84+
Write-Host "Sentry: Upload started using PropertiesFile '$PropertiesFile'"
85+
86+
$env:SENTRY_PROPERTIES = $PropertiesFile
87+
& $CliExec upload-dif --include-sources --log-level info $ProjectBinariesPath $PluginBinariesPath
88+
89+
Write-Host "Sentry: Upload finished"
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
targetPlatform=$1
4+
targetName=$2
5+
targetType=$3
6+
projectPath=$4
7+
pluginPath=$5
8+
9+
PROJECT_BINARIES_PATH=$projectPath/Binaries/$targetPlatform
10+
PLUGIN_BINARIES_PATH=$pluginPath/Source/ThirdParty/$targetPlatform
11+
CONFIG_PATH=$projectPath/Config
12+
13+
echo "Sentry: Start debug symbols upload"
14+
15+
if [ $targetType = "Editor" ]; then
16+
echo "Sentry: Automatic symbols upload is not required for Editor target. Skipping..."
17+
exit
18+
fi
19+
20+
if [ $targetPlatform = "IOS" ] || [ $targetPlatform = "Mac" ]; then
21+
SENTRY_CLI_EXEC=$pluginPath/Source/ThirdParty/CLI/sentry-cli-Darwin-universal
22+
elif [ $targetPlatform = "Linux" ]; then
23+
SENTRY_CLI_EXEC=$pluginPath/Source/ThirdParty/CLI/sentry-cli-Linux-x86_64
24+
else
25+
echo "Sentry: Unexpected platform ${targetPlatform}. Skipping..."
26+
exit
27+
fi
28+
29+
UPLOAD_SYMBOLS=$(awk -F "=" '/UploadSymbolsAutomatically/ {print $2}' ${CONFIG_PATH}/DefaultEngine.ini)
30+
31+
if [ -z $UPLOAD_SYMBOLS ]; then
32+
echo "Sentry: Automatic symbols upload is disabled in plugin settings. Skipping..."
33+
exit
34+
fi
35+
36+
if [ $UPLOAD_SYMBOLS != "True" ]; then
37+
echo "Sentry: Automatic symbols upload is disabled in plugin settings. Skipping..."
38+
exit
39+
fi
40+
41+
PROP_FILE_PATH=$(awk -F "=" '/PropertiesFilePath/ {print $2}' ${CONFIG_PATH}/DefaultEngine.ini)
42+
43+
export SENTRY_PROPERTIES="$projectPath/$PROP_FILE_PATH"
44+
45+
echo "Sentry: Upload started using PropertiesFile '$SENTRY_PROPERTIES'"
46+
47+
chmod +x $SENTRY_CLI_EXEC
48+
49+
$SENTRY_CLI_EXEC upload-dif --include-sources $PROJECT_BINARIES_PATH $PLUGIN_BINARIES_PATH
50+
51+
echo "Sentry: Upload finished"

plugin-dev/Sentry.uplugin

+13-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,17 @@
2121
"LoadingPhase": "Default",
2222
"WhitelistPlatforms": [ "Win64", "Mac", "Android", "IOS", "Linux" ]
2323
}
24-
]
24+
],
25+
"PostBuildSteps":
26+
{
27+
"Mac": [
28+
"sh $(PluginDir)/Scripts/upload-debug-symbols.sh $(TargetPlatform) $(TargetName) $(TargetType) $(ProjectDir) $(PluginDir)"
29+
],
30+
"Linux": [
31+
"sh $(PluginDir)/Scripts/upload-debug-symbols.sh $(TargetPlatform) $(TargetName) $(TargetType) $(ProjectDir) $(PluginDir)"
32+
],
33+
"Win64": [
34+
"powershell -ExecutionPolicy RemoteSigned -File $(PluginDir)/Scripts/upload-debug-symbols-win.ps1 $(TargetPlatform) $(TargetName) $(TargetType) $(ProjectDir) $(PluginDir)"
35+
]
36+
}
2537
}

plugin-dev/Source/Sentry/Private/SentrySettings.cpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
#include "SentrySettings.h"
44

5-
USentrySettings::USentrySettings(const FObjectInitializer& ObjectInitializer)
6-
: Super(ObjectInitializer)
7-
, InitAutomatically(false)
8-
, UploadSymbolsAutomatically(false)
9-
{
10-
DsnUrl = TEXT("");
11-
Release = TEXT("");
12-
ProjectName = TEXT("");
13-
OrganisationName = TEXT("");
14-
AuthToken = TEXT("");
5+
USentrySettings::USentrySettings(const FObjectInitializer &ObjectInitializer)
6+
: Super(ObjectInitializer), InitAutomatically(false),
7+
UploadSymbolsAutomatically(false) {
8+
DsnUrl = TEXT("");
9+
Release = TEXT("");
10+
PropertiesFilePath = TEXT("Config/sentry.properties");
1511
}

plugin-dev/Source/Sentry/Public/SentrySettings.h

+3-10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "CoreMinimal.h"
66
#include "UObject/NoExportTypes.h"
7+
#include "Engine/EngineTypes.h"
78
#include "SentrySettings.generated.h"
89

910
USTRUCT(BlueprintType)
@@ -62,14 +63,6 @@ class SENTRY_API USentrySettings : public UObject
6263
bool UploadSymbolsAutomatically;
6364

6465
UPROPERTY(Config, EditAnywhere, Category = "Debug Symbols",
65-
Meta = (DisplayName = "Project name", ToolTip = "Name of the project for which debug symbols should be uploaded.", EditCondition = "UploadSymbolsAutomatically"))
66-
FString ProjectName;
67-
68-
UPROPERTY(Config, EditAnywhere, Category = "Debug Symbols",
69-
Meta = (DisplayName = "Organisation name", ToolTip = "Name of the organisation associated with the project.", EditCondition = "UploadSymbolsAutomatically"))
70-
FString OrganisationName;
71-
72-
UPROPERTY(Config, EditAnywhere, Category = "Debug Symbols",
73-
Meta = (DisplayName = "Authentication token", ToolTip = "Authentication token for performing actions against Sentry API.", EditCondition = "UploadSymbolsAutomatically"))
74-
FString AuthToken;
66+
Meta = (DisplayName = "Properties file", ToolTip = "Path to the `sentry.properties` file.", EditCondition = "UploadSymbolsAutomatically"))
67+
FString PropertiesFilePath;
7568
};

plugin-dev/Source/Sentry/Sentry_Android_UPL.xml

+6-29
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<log text="Sentry SDK Android UPL initialization"/>
55

66
<setBoolFromProperty result="bUploadSymbols" ini="Engine" section="/Script/Sentry.SentrySettings" property="UploadSymbolsAutomatically" default="true" />
7-
<setStringFromProperty result="ProjectName" ini="Engine" section="/Script/Sentry.SentrySettings" property="ProjectName"/>
8-
<setStringFromProperty result="OrganisationName" ini="Engine" section="/Script/Sentry.SentrySettings" property="OrganisationName"/>
9-
<setStringFromProperty result="AuthToken" ini="Engine" section="/Script/Sentry.SentrySettings" property="AuthToken"/>
7+
8+
<setStringFromProperty result="PropertiesFilePath" ini="Engine" section="/Script/Sentry.SentrySettings" property="PropertiesFilePath"/>
9+
<setStringReplace result="PropertiesFilePath" source="$S(PropertiesFilePath)" find="(FilePath=&quot;" with=""/>
10+
<setStringReplace result="PropertiesFilePath" source="$S(PropertiesFilePath)" find="&quot;)" with=""/>
1011
</init>
1112

1213
<prebuildCopies>
1314
<copyDir src="$S(PluginDir)/Private/Android/Java" dst="$S(BuildDir)/src/com/sentry/unreal" />
14-
<copyFile src="$S(PluginDir)/../../Resources/sentry.properties" dst="$S(BuildDir)/gradle/sentry.properties" />
15-
15+
<copyFile src="$S(ProjectDir)/$S(PropertiesFilePath)" dst="$S(BuildDir)/gradle/sentry.properties" />
1616
<copyFile src="$S(PluginDir)/../ThirdParty/Android/sentry.jar" dst="$S(BuildDir)/gradle/app/libs/sentry.jar" />
1717
<copyFile src="$S(PluginDir)/../ThirdParty/Android/sentry-android-core-release.aar" dst="$S(BuildDir)/gradle/app/libs/sentry-android-core-release.aar" />
1818
<copyFile src="$S(PluginDir)/../ThirdParty/Android/sentry-android-ndk-release.aar" dst="$S(BuildDir)/gradle/app/libs/sentry-android-ndk-release.aar" />
@@ -93,7 +93,7 @@
9393
'android.support.v4.content.ContextCompat': 'androidx.core.content.ContextCompat',
9494
'android.support.v4.content.FileProvider': 'androidx.core.content.FileProvider',
9595
]
96-
96+
9797
beforeEvaluate { project ->
9898
project.rootProject.projectDir.traverse(type: groovy.io.FileType.FILES, nameFilter: ~/.*\.java$/) { f ->
9999
mappings.each { entry ->
@@ -107,29 +107,6 @@
107107
}
108108
</insert>
109109
</baseBuildGradleAdditions>
110-
111-
<baseBuildGradleAdditions>
112-
<if condition="bUploadSymbols">
113-
<true>
114-
<insert>
115-
allprojects {
116-
beforeEvaluate { project ->
117-
project.rootProject.projectDir.traverse(type: groovy.io.FileType.FILES, nameFilter: ~/sentry\.properties$/) { f ->
118-
</insert>
119-
<insertValue value="ant.replace(file: f, token: 'your-project', value: '$S(ProjectName)')"/>
120-
<insertNewline/>
121-
<insertValue value="ant.replace(file: f, token: 'your-org', value: '$S(OrganisationName)')"/>
122-
<insertNewline/>
123-
<insertValue value="ant.replace(file: f, token: 'YOUR_AUTH_TOKEN', value: '$S(AuthToken)')"/>
124-
<insertNewline/>
125-
<insert>
126-
}
127-
}
128-
}
129-
</insert>
130-
</true>
131-
</if>
132-
</baseBuildGradleAdditions>
133110

134111
<buildscriptGradleAdditions>
135112
<insert>

sample/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,5 @@ Plugins/*/Intermediate/*
7474

7575
# Cache files for the editor to use
7676
DerivedDataCache/*
77+
78+
**/sentry.properties

sample/Config/DefaultEngine.ini

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
[/Script/EngineSettings.GameMapsSettings]
42
EditorStartupMap=/Sentry/Maps/SentryDemo.SentryDemo
53
LocalMapOptions=
@@ -266,6 +264,9 @@ bGeneratedSYMBundle=True
266264
DsnUrl="https://[email protected]/6253052"
267265
InitAutomatically=False
268266
AutomaticBreadcrumbs=(bOnMapLoadingStarted=True,bOnMapLoaded=True,bOnGameStateClassChanged=True,bOnGameSessionIDChanged=True,bOnUserActivityStringChanged=True)
267+
UploadSymbolsAutomatically=True
268+
Release=
269+
PropertiesFilePath=Config/sentry.properties
269270

270271
[/Script/MacTargetPlatform.MacTargetSettings]
271272
SpatializationPlugin=Built-in Spatialization

0 commit comments

Comments
 (0)