Skip to content

Commit

Permalink
Fix conditional debug symbols uploading (#399)
Browse files Browse the repository at this point in the history
* Add check of enabled target/platform/config during sym upload on Mac/Linux

* Add check of enabled platform/config during sym upload for Android

* Update changelog

* Add check of enabled platform/config during sym upload for Windows

* Clean up code
  • Loading branch information
tustanivsky authored Oct 5, 2023
1 parent 62c27e4 commit 24fa6e4
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Fix issue with missing Sentry.framework in iOS app bundle UE 5.3 ([#390](https://github.com/getsentry/sentry-unreal/pull/390))
- Fix dependencies loading for desktop ([#393](https://github.com/getsentry/sentry-unreal/pull/393))
- Fix array/map Json string check to avoid unnecessary error messages in logs ([#394](https://github.com/getsentry/sentry-unreal/pull/394))
- Fix conditional debug symbols uploading ([#399](https://github.com/getsentry/sentry-unreal/pull/399))
- Fix compilation errors in UE 4.27 ([#398](https://github.com/getsentry/sentry-unreal/pull/398))

### Dependencies
Expand Down
57 changes: 54 additions & 3 deletions plugin-dev/Scripts/upload-debug-symbols-win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ setlocal enabledelayedexpansion
set TargetPlatform=%1
set TargetName=%2
set TargetType=%3
set ProjectPath=%4
set PluginPath=%5
set TargetConfig=%4
set ProjectPath=%5
set PluginPath=%6

set ProjectBinariesPath=%ProjectPath:"=%\Binaries\%TargetPlatform%
set PluginBinariesPath=%PluginPath:"=%\Source\ThirdParty\%TargetPlatform%
Expand Down Expand Up @@ -46,6 +47,41 @@ if /i "%IncludeSourceFiles%"=="True" (
set "CliArgs=--include-sources"
)

call :ParseIniFile "%ConfigPath%\DefaultEngine.ini" /Script/Sentry.SentrySettings EnableBuildPlatforms EnabledPlatforms
if not "%EnabledPlatforms%"=="" (
set PlatformToCheck=
if "%TargetPlatform%"=="Win64" (
set "PlatformToCheck=bEnableWindows=False"
) else (
set "PlatformToCheck=bEnable%TargetPlatform%=False"
)
call :FindString EnabledPlatforms PlatformToCheck IsPlatformDisabled
if "!IsPlatformDisabled!"=="true" (
echo "Sentry: Automatic symbols upload is disabled for build platform %TargetPlatform%. Skipping..."
exit
)
)

call :ParseIniFile "%ConfigPath%\DefaultEngine.ini" /Script/Sentry.SentrySettings EnableBuildTargets EnabledTargets
if not "%EnabledTargets%"=="" (
set TargetToCheck="bEnable%TargetType%=False"
call :FindString EnabledTargets TargetToCheck IsTargetDisabled
if "!IsTargetDisabled!"=="true" (
echo "Sentry: Automatic symbols upload is disabled for build target type %TargetType%. Skipping..."
exit
)
)

call :ParseIniFile "%ConfigPath%\DefaultEngine.ini" /Script/Sentry.SentrySettings EnableBuildConfigurations EnabledConfigurations
if not "%EnabledConfigurations%"=="" (
set ConfigToCheck="bEnable%TargetConfig%=False"
call :FindString EnabledConfigurations ConfigToCheck IsConfigDisabled
if "!IsConfigDisabled!"=="true" (
echo "Sentry: Automatic symbols upload is disabled for build configuration %TargetConfig%. Skipping..."
exit
)
)

set PropertiesFile=%ProjectPath:"=%\sentry.properties

if not exist "%PropertiesFile%" (
Expand All @@ -70,6 +106,19 @@ echo Sentry: Upload finished
endlocal
exit

:FindString <sourceStr> <findStr> <result>
setlocal
for /f "delims=" %%A in ('echo %%%1%%') do set str1=%%A
for /f "delims=" %%A in ('echo %%%2%%') do set str2=%%A
echo.%str1%|findstr /C:"%str2%" >nul 2>&1
endlocal
if not errorlevel 1 (
set %~3=true
) else (
set %~3=false
)
goto :eof

:ParseIniFile <filename> <section> <key> <result>
set %~4=
setlocal
Expand Down Expand Up @@ -97,4 +146,6 @@ exit
)
)
)
endlocal
endlocal
set insection=
goto :eof
32 changes: 30 additions & 2 deletions plugin-dev/Scripts/upload-debug-symbols.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
targetPlatform=$1
targetName=$2
targetType=$3
projectPath=$4
pluginPath=$5
targetConfig=$4
projectPath=$5
pluginPath=$6

PROJECT_BINARIES_PATH=$projectPath/Binaries/$targetPlatform
PLUGIN_BINARIES_PATH=$pluginPath/Source/ThirdParty/$targetPlatform
Expand Down Expand Up @@ -48,6 +49,33 @@ if [ -z $INCLUDE_SOURCES -a $UPLOAD_SYMBOLS == "True" ]; then
CLI_ARGS+=(--include-sources)
fi

ENABLED_PLATFORMS=$(grep "EnableBuildPlatforms" ${CONFIG_PATH}/DefaultEngine.ini | sed -n 's/^EnableBuildPlatforms=//p' | sed -e 's/^(\(.*\))$/\1/')
if [ ! -z $ENABLED_PLATFORMS ]; then
PLATFORMS_ARRAY=$(echo "$ENABLED_PLATFORMS" | sed -e 's/,/ /g')
if [[ "${PLATFORMS_ARRAY[@]}" =~ "bEnable$targetPlatform=False" ]]; then
echo "Sentry: Automatic symbols upload is disabled for build platform $targetPlatform. Skipping..."
exit
fi
fi

ENABLED_TARGETS=$(grep "EnableBuildTargets" ${CONFIG_PATH}/DefaultEngine.ini | sed -n 's/^EnableBuildTargets=//p' | sed -e 's/^(\(.*\))$/\1/')
if [ ! -z $ENABLED_TARGETS ]; then
TARGETS_ARRAY=$(echo "$ENABLED_TARGETS" | sed -e 's/,/ /g')
if [[ "${TARGETS_ARRAY[@]}" =~ "bEnable$targetType=False" ]]; then
echo "Sentry: Automatic symbols upload is disabled for target type $targetType. Skipping..."
exit
fi
fi

ENABLED_CONFIGS=$(grep "EnableBuildConfigurations" ${CONFIG_PATH}/DefaultEngine.ini | sed -n 's/^EnableBuildConfigurations=//p' | sed -e 's/^(\(.*\))$/\1/')
if [ ! -z $ENABLED_CONFIGS ]; then
CONFIGS_ARRAY=$(echo "$ENABLED_CONFIGS" | sed -e 's/,/ /g')
if [[ "${CONFIGS_ARRAY[@]}" =~ "bEnable$targetConfig=False" ]]; then
echo "Sentry: Automatic symbols upload is disabled for build configuration $targetConfig. Skipping..."
exit
fi
fi

export SENTRY_PROPERTIES="$projectPath/sentry.properties"
if [ ! -f "$SENTRY_PROPERTIES" ]; then
echo "Sentry: Properties file is missing: '$SENTRY_PROPERTIES'"
Expand Down
6 changes: 3 additions & 3 deletions plugin-dev/Sentry.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
"PostBuildSteps":
{
"Mac": [
"if [ -f \"$(PluginDir)/Scripts/upload-debug-symbols.sh\" ]; then\n sh \"$(PluginDir)/Scripts/upload-debug-symbols.sh\" $(TargetPlatform) $(TargetName) $(TargetType) \"$(ProjectDir)\" \"$(PluginDir)\"\nelse\n echo \"Sentry: Symbol upload script is missing. Skipping post build step.\"\nfi"
"if [ -f \"$(PluginDir)/Scripts/upload-debug-symbols.sh\" ]; then\n sh \"$(PluginDir)/Scripts/upload-debug-symbols.sh\" $(TargetPlatform) $(TargetName) $(TargetType) $(TargetConfiguration) \"$(ProjectDir)\" \"$(PluginDir)\"\nelse\n echo \"Sentry: Symbol upload script is missing. Skipping post build step.\"\nfi"
],
"Linux": [
"if [ -f \"$(PluginDir)/Scripts/upload-debug-symbols.sh\" ]; then\n sh \"$(PluginDir)/Scripts/upload-debug-symbols.sh\" $(TargetPlatform) $(TargetName) $(TargetType) \"$(ProjectDir)\" \"$(PluginDir)\"\nelse\n echo \"Sentry: Symbol upload script is missing. Skipping post build step.\"\nfi"
"if [ -f \"$(PluginDir)/Scripts/upload-debug-symbols.sh\" ]; then\n sh \"$(PluginDir)/Scripts/upload-debug-symbols.sh\" $(TargetPlatform) $(TargetName) $(TargetType) $(TargetConfiguration) \"$(ProjectDir)\" \"$(PluginDir)\"\nelse\n echo \"Sentry: Symbol upload script is missing. Skipping post build step.\"\nfi"
],
"Win64": [
"set SYM_UPLOAD_SCRIPT=\"$(PluginDir)/Scripts/upload-debug-symbols-win.bat\"",
"if exist \"%SYM_UPLOAD_SCRIPT%\" (call \"%SYM_UPLOAD_SCRIPT%\" $(TargetPlatform) $(TargetName) $(TargetType) \"$(ProjectDir)\" \"$(PluginDir)\") else (\necho Warning: Sentry: Symbol upload script is missing. Skipping post build step.\n)"
"if exist \"%SYM_UPLOAD_SCRIPT%\" (call \"%SYM_UPLOAD_SCRIPT%\" $(TargetPlatform) $(TargetName) $(TargetType) $(TargetConfiguration) \"$(ProjectDir)\" \"$(PluginDir)\") else (\necho Warning: Sentry: Symbol upload script is missing. Skipping post build step.\n)"
]
}
}
20 changes: 19 additions & 1 deletion plugin-dev/Source/Sentry/Sentry_Android_UPL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,26 @@
<init>
<log text="Sentry SDK Android UPL initialization"/>

<setBoolFromProperty result="bUploadSymbols" ini="Engine" section="/Script/Sentry.SentrySettings" property="UploadSymbolsAutomatically" default="false" />
<setBoolFromProperty result="bUploadSymbolsAutomatically" ini="Engine" section="/Script/Sentry.SentrySettings" property="UploadSymbolsAutomatically" default="false" />
<setBoolFromProperty result="bIncludeSources" ini="Engine" section="/Script/Sentry.SentrySettings" property="IncludeSources" default="false" />

<setStringFromProperty result="enabledBuildPlatforms" ini="Engine" section="/Script/Sentry.SentrySettings" property="EnableBuildPlatforms" default=""/>
<setStringFromProperty result="enabledBuildConfigurations" ini="Engine" section="/Script/Sentry.SentrySettings" property="EnableBuildConfigurations" default=""/>
<setStringFromProperty result="enabledBuildTargetTypes" ini="Engine" section="/Script/Sentry.SentrySettings" property="EnableBuildTargets" default=""/>

<setBoolContains result="bCurrentPlatformDisabled" source="$S(enabledBuildPlatforms)" find="bEnableAndroid=False"/>
<setBoolContains result="bCurrentConfigurationDisabled" source="$S(enabledBuildConfigurations)" find="bEnable$S(Configuration)=False"/>

<setBoolOr result="bSkipUpload" arg1="$B(bCurrentPlatformDisabled)" arg2="$B(bCurrentConfigurationDisabled)"/>

<if condition="bSkipUpload">
<true>
<setBool result="bUploadSymbols" value="false"/>
</true>
<false>
<setBool result="bUploadSymbols" value="$B(bUploadSymbolsAutomatically)"/>
</false>
</if>
</init>

<prebuildCopies>
Expand Down

0 comments on commit 24fa6e4

Please sign in to comment.