Skip to content
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Features

- Added Xbox Native Support ([#2314](https://github.com/getsentry/sentry-unity/pull/2314))
- Added Xbox Native Support ([#2314](https://github.com/getsentry/sentry-unity/pull/2314), [#2329](https://github.com/getsentry/sentry-unity/pull/2329))

### Fixes

Expand Down
14 changes: 13 additions & 1 deletion package-dev/Runtime/Sentry.Unity.Native.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 17 additions & 7 deletions src/Sentry.Unity.Editor/Native/BuildPostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,24 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath)
var isMono = PlayerSettings.GetScriptingBackend(targetGroup) == ScriptingImplementation.Mono2x;
#pragma warning restore CS0618

var executableName = Path.GetFileName(executablePath);
var buildOutputDir = Path.GetDirectoryName(executablePath);
// The executable path resolves to the following when pointing Unity into a `build/platform/` directory:
// - Desktop: `./samples/unity-of-bugs/builds/windows/unityofbugs.exe`
// - Xbox: `./samples/unity-of-bugs/builds/xsx/`
var buildOutputDir = targetGroup switch
{
BuildTargetGroup.Standalone => Path.GetDirectoryName(executablePath),
BuildTargetGroup.GameCoreXboxSeries => executablePath,
_ => string.Empty
};

if (string.IsNullOrEmpty(buildOutputDir))
{
logger.LogError("Failed to find build output directory based on the executable path '{0}'." +
"\nSkipping adding crash-handler and uploading debug symbols.", executablePath);
return;
}

UploadDebugSymbols(logger, target, buildOutputDir, executableName, options, cliOptions, isMono);
UploadDebugSymbols(logger, target, buildOutputDir, options, cliOptions, isMono);

if (!IsEnabledForPlatform(target, options))
{
Expand All @@ -62,7 +70,7 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath)

try
{
AddCrashHandler(logger, target, buildOutputDir, executableName);
AddCrashHandler(logger, target, buildOutputDir);
}
catch (Exception e)
{
Expand All @@ -81,7 +89,7 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath)
_ => false,
};

private static void AddCrashHandler(IDiagnosticLogger logger, BuildTarget target, string buildOutputDir, string executableName)
private static void AddCrashHandler(IDiagnosticLogger logger, BuildTarget target, string buildOutputDir)
{
switch (target)
{
Expand All @@ -97,7 +105,7 @@ private static void AddCrashHandler(IDiagnosticLogger logger, BuildTarget target
return;
case BuildTarget.GameCoreXboxSeries:
case BuildTarget.GameCoreXboxOne:
// TODO: Figure out if we need to ship with a crash handler
// No standalone crash handler for Xbox - comes with Breakpad
Copy link
Member

Choose a reason for hiding this comment

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

Note that we plan to move to crashpad.
I'll add a link to this comment to that ticket

return;
default:
throw new ArgumentException($"Unsupported build target: {target}");
Expand All @@ -112,7 +120,7 @@ private static void CopyHandler(IDiagnosticLogger logger, string buildOutputDir,
File.Copy(fullHandlerPath, targetHandlerPath, true);
}

private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget target, string buildOutputDir, string executableName, SentryUnityOptions options, SentryCliOptions? cliOptions, bool isMono)
private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget target, string buildOutputDir, SentryUnityOptions options, SentryCliOptions? cliOptions, bool isMono)
{
var projectDir = Directory.GetParent(Application.dataPath).FullName;
if (cliOptions?.IsValid(logger, EditorUserBuildSettings.development) is not true)
Expand All @@ -135,6 +143,8 @@ private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget tar
{
case BuildTarget.StandaloneWindows:
case BuildTarget.StandaloneWindows64:
case BuildTarget.GameCoreXboxSeries:
case BuildTarget.GameCoreXboxOne:
var windowsSentryPdb = Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/Windows/Sentry/sentry.pdb");
if (File.Exists(windowsSentryPdb))
{
Expand Down