Skip to content

Commit

Permalink
Release 8.3.0 UAT fixes (#861)
Browse files Browse the repository at this point in the history
* UAT fixes

* contributing

* u6 support

* extract playersettingscompat class

* forgotten import
  • Loading branch information
richardelms authored Dec 4, 2024
1 parent 97fad78 commit 5aa90b3
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 44 deletions.
53 changes: 28 additions & 25 deletions Bugsnag/Assets/Bugsnag/Editor/BugsnagAddScriptingSymbol.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class BugsnagAddScriptingSymbol : MonoBehaviour
namespace BugsnagUnity.Editor
{
private const string DEFINE_SYMBOL = "BUGSNAG_UNITY_WEB_REQUEST";
[InitializeOnLoad]
public class BugsnagAddScriptingSymbol : MonoBehaviour
{
private const string DEFINE_SYMBOL = "BUGSNAG_UNITY_WEB_REQUEST";

private static BuildTargetGroup[] _supportedPlatforms = { BuildTargetGroup.Android, BuildTargetGroup.Standalone, BuildTargetGroup.iOS, BuildTargetGroup.WebGL };
private static BuildTargetGroup[] _supportedPlatforms = { BuildTargetGroup.Android, BuildTargetGroup.Standalone, BuildTargetGroup.iOS, BuildTargetGroup.WebGL };

static BugsnagAddScriptingSymbol()
{
foreach (var target in _supportedPlatforms)
static BugsnagAddScriptingSymbol()
{
try
{
SetScriptingSymbol(target);
}
catch
foreach (var target in _supportedPlatforms)
{
// Some users might not have a platform installed, in that case ignore the error
try
{
SetScriptingSymbol(target);
}
catch
{
// Some users might not have a platform installed, in that case ignore the error
}
}
}
}

static void SetScriptingSymbol(BuildTargetGroup buildTargetGroup)
{
var existingSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
if (string.IsNullOrEmpty(existingSymbols))
static void SetScriptingSymbol(BuildTargetGroup buildTargetGroup)
{
existingSymbols = DEFINE_SYMBOL;
}
else if (!existingSymbols.Contains(DEFINE_SYMBOL))
{
existingSymbols += ";" + DEFINE_SYMBOL;
var existingSymbols = BugsnagPlayerSettingsCompat.GetScriptingDefineSymbols(buildTargetGroup);
if (string.IsNullOrEmpty(existingSymbols))
{
existingSymbols = DEFINE_SYMBOL;
}
else if (!existingSymbols.Contains(DEFINE_SYMBOL))
{
existingSymbols += ";" + DEFINE_SYMBOL;
}
BugsnagPlayerSettingsCompat.SetScriptingDefineSymbols(buildTargetGroup, existingSymbols);
}
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, existingSymbols);
}
}
}
39 changes: 39 additions & 0 deletions Bugsnag/Assets/Bugsnag/Editor/BugsnagPlayerSettingsCompat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using UnityEditor;
#if UNITY_6000_0_OR_NEWER
using UnityEditor.Build;
#endif
namespace BugsnagUnity.Editor
{
internal static class BugsnagPlayerSettingsCompat
{
// Get Scripting Backend
public static ScriptingImplementation GetScriptingBackend(BuildTargetGroup buildTargetGroup)
{
#if UNITY_6000_0_OR_NEWER
return PlayerSettings.GetScriptingBackend(NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup));
#else
return PlayerSettings.GetScriptingBackend(buildTargetGroup);
#endif
}

// Get Scripting Define Symbols
public static string GetScriptingDefineSymbols(BuildTargetGroup buildTargetGroup)
{
#if UNITY_6000_0_OR_NEWER
return PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup));
#else
return PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
#endif
}

// Set Scripting Define Symbols
public static void SetScriptingDefineSymbols(BuildTargetGroup buildTargetGroup, string defineSymbols)
{
#if UNITY_6000_0_OR_NEWER
PlayerSettings.SetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup), defineSymbols);
#else
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, defineSymbols);
#endif
}
}
}
11 changes: 11 additions & 0 deletions Bugsnag/Assets/Bugsnag/Editor/BugsnagPlayerSettingsCompat.cs.meta

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

36 changes: 18 additions & 18 deletions Bugsnag/Assets/Bugsnag/Editor/BuildPreprocessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
using UnityEngine;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;

public class BuildPreprocessor : IPreprocessBuildWithReport
namespace BugsnagUnity.Editor
{
public int callbackOrder => 0;

public void OnPreprocessBuild(BuildReport report)
public class BuildPreprocessor : IPreprocessBuildWithReport
{
if (PlayerSettings.GetScriptingBackend(report.summary.platformGroup) != ScriptingImplementation.IL2CPP)
{
return;
}

// Causes il2cpp to generate my-build-dir/Classes/Native/Symbols/LineNumberMappings.json
// Note: It used to be stored in the project root dir as:
// my-build-dir_BackUpThisFolder_ButDontShipItWithYourGame/il2cppOutput/Symbols/LineNumberMappings.json
const string emitIl2cppSourceMapping = "--emit-source-mapping";
public int callbackOrder => 0;

var args = PlayerSettings.GetAdditionalIl2CppArgs();
if (!args.Contains(emitIl2cppSourceMapping))
public void OnPreprocessBuild(BuildReport report)
{
PlayerSettings.SetAdditionalIl2CppArgs(args + emitIl2cppSourceMapping);
if (BugsnagPlayerSettingsCompat.GetScriptingBackend(report.summary.platformGroup) != ScriptingImplementation.IL2CPP)
{
return;
}
// Causes il2cpp to generate my-build-dir/Classes/Native/Symbols/LineNumberMappings.json
// Note: It used to be stored in the project root dir as:
// my-build-dir_BackUpThisFolder_ButDontShipItWithYourGame/il2cppOutput/Symbols/LineNumberMappings.json
const string emitIl2cppSourceMapping = "--emit-source-mapping";
var args = PlayerSettings.GetAdditionalIl2CppArgs();
if (!args.Contains(emitIl2cppSourceMapping))
{
PlayerSettings.SetAdditionalIl2CppArgs(args + emitIl2cppSourceMapping);
}
}
}
}
}
2 changes: 2 additions & 0 deletions Bugsnag/Assets/Bugsnag/Runtime/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
using System.Reflection;
[assembly: AssemblyVersion("8.3.0.0")]
11 changes: 11 additions & 0 deletions Bugsnag/Assets/Bugsnag/Runtime/AssemblyInfo.cs.meta

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

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bundle exec maze-runner features/handled_errors.feature
2. Checkout the `next` branch.
3. Set the new version in `CHANGELOG.md`
3. Set the new version in `CHANGELOG.md` and `Bugsnag/Assets/Bugsnag/Runtime/AssemblyInfo.cs`
4. Make a pull request to merge the changes into `master`
Expand Down

0 comments on commit 5aa90b3

Please sign in to comment.