Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Building playbackengine #622

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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 modules/sentry-native
Submodule sentry-native updated 83 files
+5 −1 .github/workflows/ci.yml
+1 −0 .gitignore
+65 −0 CHANGELOG.md
+55 −5 CMakeLists.txt
+11 −3 CONTRIBUTING.md
+10 −3 Makefile
+14 −0 README.md
+50 −0 examples/example.c
+2 −2 external/CMakeLists.txt
+1 −1 external/breakpad
+1 −1 external/crashpad
+560 −15 include/sentry.h
+11 −0 src/CMakeLists.txt
+2 −0 src/backends/sentry_backend_inproc.c
+109 −0 src/modulefinder/sentry_modulefinder_aix.c
+103 −17 src/modulefinder/sentry_modulefinder_linux.c
+6 −0 src/modulefinder/sentry_modulefinder_linux.h
+29 −3 src/path/sentry_path_unix.c
+412 −24 src/sentry_core.c
+37 −4 src/sentry_core.h
+42 −1 src/sentry_database.c
+10 −0 src/sentry_database.h
+62 −1 src/sentry_envelope.c
+6 −0 src/sentry_envelope.h
+44 −0 src/sentry_json.c
+58 −1 src/sentry_options.c
+4 −0 src/sentry_options.h
+67 −14 src/sentry_os.c
+8 −0 src/sentry_ratelimiter.c
+6 −0 src/sentry_ratelimiter.h
+74 −7 src/sentry_scope.c
+16 −0 src/sentry_scope.h
+10 −6 src/sentry_session.c
+0 −61 src/sentry_string.c
+56 −18 src/sentry_string.h
+76 −1 src/sentry_sync.c
+22 −0 src/sentry_sync.h
+520 −0 src/sentry_tracing.c
+51 −0 src/sentry_tracing.h
+19 −0 src/sentry_transport.c
+7 −0 src/sentry_transport.h
+27 −2 src/sentry_utils.c
+22 −0 src/sentry_uuid.c
+13 −3 src/sentry_uuid.h
+60 −0 src/sentry_value.c
+33 −0 src/sentry_value.h
+189 −0 src/symbolizer/sentry_symbolizer_unix.c
+13 −0 src/transports/sentry_transport_curl.c
+18 −0 src/transports/sentry_transport_winhttp.c
+8 −2 src/unwinder/sentry_unwinder_libbacktrace.c
+48 −2 tests/__init__.py
+36 −19 tests/assertions.py
+7 −2 tests/conditions.py
+1 −1 tests/test_build_static.py
+60 −1 tests/test_integration_http.py
+12 −0 tests/test_integration_ratelimits.py
+22 −0 tests/test_integration_stdout.py
+2 −0 tests/unit/CMakeLists.txt
+0 −2 tests/unit/fuzz.c
+0 −1 tests/unit/test_attachments.c
+69 −1 tests/unit/test_basic.c
+28 −1 tests/unit/test_concurrency.c
+0 −1 tests/unit/test_consent.c
+32 −1 tests/unit/test_envelopes.c
+0 −1 tests/unit/test_failures.c
+1 −1 tests/unit/test_fuzzfailures.c
+0 −1 tests/unit/test_logger.c
+0 −1 tests/unit/test_modulefinder.c
+0 −1 tests/unit/test_mpack.c
+0 −1 tests/unit/test_path.c
+0 −1 tests/unit/test_ratelimiter.c
+37 −0 tests/unit/test_sampling.c
+0 −1 tests/unit/test_session.c
+0 −1 tests/unit/test_slice.c
+12 −1 tests/unit/test_symbolizer.c
+20 −0 tests/unit/test_sync.c
+811 −0 tests/unit/test_tracing.c
+0 −2 tests/unit/test_uninit.c
+11 −2 tests/unit/test_unwinder.c
+0 −1 tests/unit/test_utils.c
+22 −2 tests/unit/test_uuid.c
+56 −1 tests/unit/test_value.c
+24 −0 tests/unit/tests.inc
50 changes: 3 additions & 47 deletions src/Sentry.Unity.Editor.iOS/BuildPostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public static void OnPostProcessBuild(BuildTarget target, string pathToProject)
// Unity doesn't allow an appending builds when switching iOS SDK versions and this will make sure we always copy the correct version of the Sentry.framework
var frameworkDirectory = PlayerSettings.iOS.sdkVersion == iOSSdkVersion.DeviceSDK ? "Device" : "Simulator";
var frameworkPath = Path.GetFullPath(Path.Combine("Packages", SentryPackageInfo.GetName(), "Plugins", "iOS", frameworkDirectory, "Sentry.framework"));
CopyFramework(frameworkPath, Path.Combine(pathToProject, "Frameworks", "Sentry.framework"), options?.DiagnosticLogger);
EditorFileIO.CopyDirectory(frameworkPath, Path.Combine(pathToProject, "Frameworks", "Sentry.framework"), options?.DiagnosticLogger);

var nativeBridgePath = Path.GetFullPath(Path.Combine("Packages", SentryPackageInfo.GetName(), "Plugins", "iOS", "SentryNativeBridge.m"));
CopyFile(nativeBridgePath, Path.Combine(pathToProject, "Libraries", SentryPackageInfo.GetName(), "SentryNativeBridge.m"), options?.DiagnosticLogger);
EditorFileIO.CopyFile(nativeBridgePath, Path.Combine(pathToProject, "Libraries", SentryPackageInfo.GetName(), "SentryNativeBridge.m"), options?.DiagnosticLogger);

using var sentryXcodeProject = SentryXcodeProject.Open(pathToProject);
sentryXcodeProject.AddSentryFramework();
Expand All @@ -49,7 +49,7 @@ public static void OnPostProcessBuild(BuildTarget target, string pathToProject)
sentryXcodeProject.AddNativeOptions(options);
sentryXcodeProject.AddSentryToMain(options);

var sentryCliOptions = SentryCliOptions.LoadCliOptions();
var sentryCliOptions = SentryEditorOptions.LoadEditorOptions();
if (sentryCliOptions.IsValid(logger))
{
SentryCli.CreateSentryProperties(pathToProject, sentryCliOptions);
Expand All @@ -62,49 +62,5 @@ public static void OnPostProcessBuild(BuildTarget target, string pathToProject)
logger.LogError("Failed to add the Sentry framework to the generated Xcode project", e);
}
}

internal static void CopyFramework(string sourcePath, string targetPath, IDiagnosticLogger? logger)
{
if (Directory.Exists(targetPath))
{
logger?.LogDebug("'{0}' has already been copied to '{1}'", Path.GetFileName(targetPath), targetPath);
return;
}

if (Directory.Exists(sourcePath))
{
logger?.LogDebug("Copying from: '{0}' to '{1}'", sourcePath, targetPath);

Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(targetPath)));
FileUtil.CopyFileOrDirectory(sourcePath, targetPath);
}

if (!Directory.Exists(targetPath))
{
throw new DirectoryNotFoundException($"Failed to copy '{sourcePath}' to '{targetPath}'");
}
}

internal static void CopyFile(string sourcePath, string targetPath, IDiagnosticLogger? logger)
{
if (File.Exists(targetPath))
{
logger?.LogDebug("'{0}' has already been copied to '{1}'", Path.GetFileName(targetPath), targetPath);
return;
}

if (File.Exists(sourcePath))
{
logger?.LogDebug("Copying from: '{0}' to '{1}'", sourcePath, targetPath);

Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(targetPath)));
FileUtil.CopyFileOrDirectory(sourcePath, targetPath);
}

if (!File.Exists(targetPath))
{
throw new FileNotFoundException($"Failed to copy '{sourcePath}' to '{targetPath}'");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Sentry.Unity.Editor.Android
public class AndroidManifestConfiguration : IPostGenerateGradleAndroidProject
{
private readonly Func<SentryUnityOptions?> _getOptions;
private readonly Func<SentryCliOptions?> _getSentryCliOptions;
private readonly Func<SentryEditorOptions?> _getSentryCliOptions;
private readonly IUnityLoggerInterceptor? _interceptor;

private readonly bool _isDevelopmentBuild;
Expand All @@ -24,7 +24,7 @@ public class AndroidManifestConfiguration : IPostGenerateGradleAndroidProject

public AndroidManifestConfiguration()
: this(() => ScriptableSentryUnityOptions.LoadSentryUnityOptions(BuildPipeline.isBuildingPlayer),
() => SentryCliOptions.LoadCliOptions(),
() => SentryEditorOptions.LoadEditorOptions(),
isDevelopmentBuild: EditorUserBuildSettings.development,
scriptingImplementation: PlayerSettings.GetScriptingBackend(BuildTargetGroup.Android))
{
Expand All @@ -33,7 +33,7 @@ public AndroidManifestConfiguration()
// Testing
internal AndroidManifestConfiguration(
Func<SentryUnityOptions?> getOptions,
Func<SentryCliOptions?> getSentryCliOptions,
Func<SentryEditorOptions?> getSentryCliOptions,
IUnityLoggerInterceptor? interceptor = null,
bool isDevelopmentBuild = false,
ScriptingImplementation scriptingImplementation = ScriptingImplementation.IL2CPP)
Expand Down
35 changes: 0 additions & 35 deletions src/Sentry.Unity.Editor/ConfigurationWindow/DebugSymbolsTab.cs

This file was deleted.

54 changes: 54 additions & 0 deletions src/Sentry.Unity.Editor/ConfigurationWindow/EditorOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using UnityEditor;
using UnityEngine;

namespace Sentry.Unity.Editor.ConfigurationWindow
{
internal static class EditorOptions
{
internal static void Display(SentryEditorOptions editorOptions)
{
editorOptions.UploadSymbols = EditorGUILayout.BeginToggleGroup(
new GUIContent("Upload Symbols", "Whether debug symbols should be uploaded automatically " +
"on release builds."),
editorOptions.UploadSymbols);

editorOptions.UploadDevelopmentSymbols = EditorGUILayout.Toggle(
new GUIContent("Upload Dev Symbols", "Whether debug symbols should be uploaded automatically " +
"on development builds."),
editorOptions.UploadDevelopmentSymbols);

EditorGUILayout.EndToggleGroup();

editorOptions.Auth = EditorGUILayout.TextField(
new GUIContent("Auth Token", "The authorization token from your user settings in Sentry"),
editorOptions.Auth);

editorOptions.Organization = EditorGUILayout.TextField(
new GUIContent("Org Slug", "The organization slug in Sentry"),
editorOptions.Organization);

editorOptions.Project = EditorGUILayout.TextField(
new GUIContent("Project Name", "The project name in Sentry"),
editorOptions.Project);

EditorGUILayout.Space();
EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), Color.gray);
EditorGUILayout.Space();

editorOptions.AddSentryToWindowsPlayer = EditorGUILayout.Toggle(
new GUIContent("Add Sentry to Windows Player", "If enabled the SDK will " +
"compile the Windows Player from source and add Sentry to it."),
editorOptions.AddSentryToWindowsPlayer);

editorOptions.MSBuildPath = EditorGUILayout.TextField(
new GUIContent("MSBuild Path", "The path to MSBuild, if left empty the SDK will " +
"try to locate it."),
editorOptions.MSBuildPath);

editorOptions.VSWherePath = EditorGUILayout.TextField(
new GUIContent("VSWhere Path", "The path to VSWhere used to locate MSBuild. If " +
"left empty the SDK will try to locate it."),
editorOptions.VSWherePath);
}
}
}
8 changes: 4 additions & 4 deletions src/Sentry.Unity.Editor/ConfigurationWindow/SentryWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static SentryWindow OpenSentryWindow()
protected virtual string SentryOptionsAssetName { get; } = ScriptableSentryUnityOptions.ConfigName;

public ScriptableSentryUnityOptions Options { get; private set; } = null!; // Set by OnEnable()
public SentryCliOptions CliOptions { get; private set; } = null!; // Set by OnEnable()
public SentryEditorOptions EditorOptions { get; private set; } = null!; // Set by OnEnable()

public event Action<ValidationError> OnValidationError = _ => { };

Expand All @@ -46,7 +46,7 @@ private void Awake()

CheckForAndConvertJsonConfig();
Options = LoadOptions();
CliOptions = SentryCliOptions.LoadCliOptions();
EditorOptions = SentryEditorOptions.LoadEditorOptions();
}

private ScriptableSentryUnityOptions LoadOptions()
Expand Down Expand Up @@ -147,7 +147,7 @@ private void OnGUI()
OptionsConfigurationTab.Display(Options);
break;
case 5:
DebugSymbolsTab.Display(CliOptions);
ConfigurationWindow.EditorOptions.Display(EditorOptions);
break;
default:
break;
Expand All @@ -169,7 +169,7 @@ private void OnLostFocus()
Validate();

EditorUtility.SetDirty(Options);
EditorUtility.SetDirty(CliOptions);
EditorUtility.SetDirty(EditorOptions);
AssetDatabase.SaveAssets();
}

Expand Down
43 changes: 43 additions & 0 deletions src/Sentry.Unity.Editor/FileUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.IO;
using Sentry.Extensibility;
using UnityEditor;

namespace Sentry.Unity.Editor
{
internal static class EditorFileIO
{
internal static void CopyDirectory(string sourcePath, string targetPath, IDiagnosticLogger? logger)
{
if (Directory.Exists(targetPath))
{
logger?.LogDebug("'{0}' already already exists.", targetPath);
return;
}

if (Directory.Exists(sourcePath))
{
logger?.LogDebug("Copying from: '{0}' to '{1}'", sourcePath, targetPath);

Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(targetPath)));
FileUtil.CopyFileOrDirectory(sourcePath, targetPath);
}
}

internal static void CopyFile(string sourcePath, string targetPath, IDiagnosticLogger? logger)
{
if (File.Exists(targetPath))
{
logger?.LogDebug("'{0}' has already been copied to '{1}'", Path.GetFileName(targetPath), targetPath);
return;
}

if (File.Exists(sourcePath))
{
logger?.LogDebug("Copying from: '{0}' to '{1}'", sourcePath, targetPath);

Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(targetPath)));
FileUtil.CopyFileOrDirectory(sourcePath, targetPath);
}
}
}
}
16 changes: 16 additions & 0 deletions src/Sentry.Unity.Editor/IEditorApplication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using UnityEditor;

namespace Sentry.Unity.Editor
{
internal interface IEditorApplication
{
string ApplicationContentsPath { get; }
}

internal sealed class EditorApplicationAdapter : IEditorApplication
{
public static readonly EditorApplicationAdapter Instance = new();

public string ApplicationContentsPath => EditorApplication.applicationContentsPath;
}
}
22 changes: 18 additions & 4 deletions src/Sentry.Unity.Editor/Native/BuildPostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Sentry.Unity.Editor.Native
public static class BuildPostProcess
{
[PostProcessBuild(1)]
public static void OnPostProcessBuild(BuildTarget target, string executablePath)
internal static void OnPostProcessBuild(BuildTarget target, string executablePath)
{
if (target is not (BuildTarget.StandaloneWindows or BuildTarget.StandaloneWindows64))
{
Expand All @@ -25,7 +25,7 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath)
{
if (PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup) != ScriptingImplementation.IL2CPP)
{
logger.LogWarning("Failed to enable Native support - only availabile with IL2CPP scripting backend.");
logger.LogWarning("Failed to enable Native support - only available with IL2CPP scripting backend.");
return;
}

Expand All @@ -41,10 +41,24 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath)
return;
}

var editorOptions = SentryEditorOptions.LoadEditorOptions();
if (editorOptions.AddSentryToWindowsPlayer)
{
if (!File.Exists(editorOptions.MSBuildPath))
{
logger.LogDebug("Failed to find 'MSBuild' at '{0}'. Trying to locate.", editorOptions.MSBuildPath);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
logger.LogDebug("Failed to find 'MSBuild' at '{0}'. Trying to locate.", editorOptions.MSBuildPath);
logger.LogDebug("'MSBuild' not known. '{0}'. Trying to locate.", editorOptions.MSBuildPath);

MSBuildLocator.SetMSBuildPath(editorOptions, options.DiagnosticLogger);
}

var windowsPlayerBuilder = SentryWindowsPlayer.Create(options.DiagnosticLogger);
windowsPlayerBuilder.AddNativeOptions();
windowsPlayerBuilder.AddSentryToMain();
windowsPlayerBuilder.Build(editorOptions.MSBuildPath, executablePath);
}

var projectDir = Path.GetDirectoryName(executablePath);
AddCrashHandler(logger, projectDir);
UploadDebugSymbols(logger, projectDir, Path.GetFileName(executablePath));

}
catch (Exception e)
{
Expand All @@ -64,7 +78,7 @@ private static void AddCrashHandler(IDiagnosticLogger logger, string projectDir)

private static void UploadDebugSymbols(IDiagnosticLogger logger, string projectDir, string executableName)
{
var cliOptions = SentryCliOptions.LoadCliOptions();
var cliOptions = SentryEditorOptions.LoadEditorOptions();
if (!cliOptions.IsValid(logger))
{
return;
Expand Down
Loading