-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0621f61
commit f09bbf1
Showing
15 changed files
with
279 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
src/Sentry.Unity.Editor/ConfigurationWindow/DebugSymbolsTab.cs
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
src/Sentry.Unity.Editor/ConfigurationWindow/EditorOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using Sentry.Extensibility; | ||
using UnityEditor.PackageManager; | ||
|
||
namespace Sentry.Unity.Editor.Native | ||
{ | ||
internal static class MSBuildLocator | ||
{ | ||
public static void SetMSBuildPath(SentryEditorOptions editorOptions, IDiagnosticLogger? logger) | ||
{ | ||
if (!File.Exists(editorOptions.VSWherePath)) | ||
{ | ||
logger?.LogDebug("Failed to find 'VSWhere' at '{0}'. Trying to locate.", editorOptions.VSWherePath); | ||
SetVSWherePath(editorOptions, logger); | ||
} | ||
|
||
logger?.LogDebug("Using 'VSWhere' at '{0}' to locate MSBuild.", editorOptions.VSWherePath); | ||
|
||
var vsWhereOutput = ""; | ||
var process = new Process | ||
{ | ||
StartInfo = new ProcessStartInfo | ||
{ | ||
FileName = editorOptions.VSWherePath, | ||
Arguments = "-latest -requires Microsoft.Component.MSBuild -find MSBuild\\**\\Bin\\MSBuild.exe", | ||
UseShellExecute = false, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
CreateNoWindow = true | ||
} | ||
}; | ||
|
||
process.OutputDataReceived += (sender, args) => vsWhereOutput += args.Data; | ||
process.Start(); | ||
process.BeginOutputReadLine(); | ||
process.BeginErrorReadLine(); | ||
process.WaitForExit(); | ||
|
||
logger?.LogDebug("VSWhere returned with: '{0}'", vsWhereOutput); | ||
|
||
if (!File.Exists(vsWhereOutput)) | ||
{ | ||
throw new FileNotFoundException($"Failed to locate 'MSBuild'."); | ||
} | ||
|
||
editorOptions.MSBuildPath = vsWhereOutput; | ||
} | ||
|
||
internal static void SetVSWherePath(SentryEditorOptions editorOptions, IDiagnosticLogger? logger) | ||
{ | ||
logger?.LogDebug("Requesting packages from Client."); | ||
|
||
var packageListRequest = Client.List(true); | ||
while (!packageListRequest.IsCompleted) | ||
{ | ||
// TODO: timeout - can't use Task.Run because it has to be on the main thread | ||
} | ||
|
||
if (packageListRequest.Status == StatusCode.Success) | ||
{ | ||
logger?.LogDebug("Successfully retrieved installed packages."); | ||
|
||
var visualstudioPackage = packageListRequest.Result.FirstOrDefault(p => p.name == "com.unity.ide.visualstudio"); | ||
if (visualstudioPackage != null) | ||
{ | ||
logger?.LogDebug("Located com.unity.ide.visualstudio at '{0}'", visualstudioPackage.resolvedPath); | ||
|
||
var vsWherePath = Path.Combine(visualstudioPackage.resolvedPath, "Editor", "VSWhere", "vswhere.exe"); | ||
if (File.Exists(vsWherePath)) | ||
{ | ||
logger?.LogDebug("Setting 'VSWhere' to '{0}'", vsWherePath); | ||
editorOptions.VSWherePath = vsWherePath; | ||
} | ||
else | ||
{ | ||
throw new FileNotFoundException($"Failed to locate 'VSWhere' at {vsWherePath}"); | ||
} | ||
} | ||
else | ||
{ | ||
throw new Exception("Failed to locate the 'com.unity.ide.visualstudio' package."); | ||
} | ||
} | ||
else | ||
{ | ||
throw new Exception("Failed to retrieve installed packages."); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.