Fix crash when cross-compiling C# bindings-only without toolchain installed

This commit is contained in:
Wojtek Figat
2023-02-19 18:17:51 +01:00
parent 3b797ab1dc
commit bef4ba1829

View File

@@ -245,7 +245,7 @@ namespace Flax.Build.Bindings
public static void GenerateCppVirtualWrapperCallBaseMethod(BuildData buildData, StringBuilder contents, VirtualClassInfo classInfo, FunctionInfo functionInfo, string scriptVTableBase, string scriptVTableOffset)
{
contents.AppendLine(" // Prevent stack overflow by calling native base method");
if (buildData.Toolchain.Compiler == TargetCompiler.Clang)
if (buildData.Toolchain?.Compiler == TargetCompiler.Clang)
{
// Clang compiler
// TODO: secure VTableFunctionInjector with mutex (even at cost of performance)
@@ -1453,7 +1453,7 @@ namespace Flax.Build.Bindings
}
var t = functionInfo.IsConst ? " const" : string.Empty;
contents.AppendLine($" typedef {functionInfo.ReturnType} ({classInfo.NativeName}::*{functionInfo.UniqueName}_Signature)({thunkParams}){t};");
if (buildData.Toolchain.Compiler != TargetCompiler.Clang)
if (buildData.Toolchain?.Compiler != TargetCompiler.Clang)
{
// MSVC or other compiler
contents.AppendLine($" typedef {functionInfo.ReturnType} ({classInfo.NativeName}Internal::*{functionInfo.UniqueName}_Internal_Signature)({thunkParams}){t};");
@@ -1526,7 +1526,7 @@ namespace Flax.Build.Bindings
}
// Native interfaces override in managed code requires vtables hacking which requires additional inject on Clang-platforms
if (buildData.Toolchain.Compiler == TargetCompiler.Clang && classInfo.IsClass && classInfo.Interfaces != null)
if (buildData.Toolchain?.Compiler == TargetCompiler.Clang && classInfo.IsClass && classInfo.Interfaces != null)
{
// Override vtable entries of interface methods (for each virtual function in each interface)
foreach (var interfaceInfo in classInfo.Interfaces)
@@ -2374,7 +2374,7 @@ namespace Flax.Build.Bindings
contents.AppendLine();
// Native interfaces override in managed code requires vtables hacking which requires additional inject on Clang-platforms
if (buildData.Toolchain.Compiler == TargetCompiler.Clang)
if (buildData.Toolchain?.Compiler == TargetCompiler.Clang)
{
// Generate functions that inject script wrappers into vtable entry
foreach (var functionInfo in interfaceInfo.Functions)