Fix crash when generating project files with toolchain setup that fails

#1537
This commit is contained in:
Wojtek Figat
2023-10-02 18:57:40 +02:00
parent dd66ee3521
commit 4149da5f9e
2 changed files with 16 additions and 8 deletions

View File

@@ -244,7 +244,19 @@ namespace Flax.Build
/// <returns>The toolchain.</returns>
public Toolchain TryGetToolchain(TargetArchitecture targetArchitecture)
{
return HasRequiredSDKsInstalled ? GetToolchain(targetArchitecture) : null;
Toolchain result = null;
if (HasRequiredSDKsInstalled)
{
try
{
result = GetToolchain(targetArchitecture);
}
catch (Exception ex)
{
Log.Exception(ex);
}
}
return result;
}
/// <summary>
@@ -260,16 +272,12 @@ namespace Flax.Build
if (_toolchains == null)
_toolchains = new Dictionary<TargetArchitecture, Toolchain>();
var key = targetArchitecture;
Toolchain toolchain;
if (_toolchains.TryGetValue(key, out toolchain))
{
if (_toolchains.TryGetValue(targetArchitecture, out toolchain))
return toolchain;
}
toolchain = CreateToolchain(targetArchitecture);
_toolchains.Add(key, toolchain);
_toolchains.Add(targetArchitecture, toolchain);
return toolchain;
}

View File

@@ -764,7 +764,7 @@ namespace Flax.Build
/// <summary>
/// Sorts the directories by name assuming they contain version text. Sorted from lowest to the highest version.
/// </summary>
/// <param name="file">The paths array to sort.</param>
/// <param name="paths">The paths array to sort.</param>
public static void SortVersionDirectories(string[] paths)
{
if (paths == null || paths.Length == 0)