diff --git a/Source/ThirdParty/nethost/nethost.Build.cs b/Source/ThirdParty/nethost/nethost.Build.cs index 380ec4d11..8b355d765 100644 --- a/Source/ThirdParty/nethost/nethost.Build.cs +++ b/Source/ThirdParty/nethost/nethost.Build.cs @@ -39,6 +39,8 @@ public class nethost : ThirdPartyModule return; // Ignore missing Host Runtime when engine is already prebuilt if (options.Flags.HasFlag(BuildFlags.GenerateProject)) return; // Ignore missing Host Runtime at projects evaluation stage (not important) + if (Configuration.BuildBindingsOnly) + return; // Ignore missing Host Runtime when just building C# bindings (without native code) throw new Exception($"Missing NET SDK runtime for {options.Platform.Target} {options.Architecture}."); } diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs index c5650e2e9..86dbd0cfe 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs @@ -1035,7 +1035,7 @@ namespace Flax.Build.Bindings contents.Append("bool bind);"); #else string libraryEntryPoint; - if (buildData.Toolchain.Compiler == TargetCompiler.MSVC) + if (buildData.Toolchain?.Compiler == TargetCompiler.MSVC) libraryEntryPoint = $"{classInfo.FullNameManaged}::Internal_{eventInfo.Name}_Bind"; // MSVC allows to override exported symbol name else libraryEntryPoint = CppNameMangling.MangleFunctionName(buildData, eventInfo.Name + "_ManagedBind", classInfo.FullNameNativeInternal + "Internal", CSharpEventBindReturn, eventInfo.IsStatic ? null : new TypeInfo(classInfo.FullNameNative) { IsPtr = true }, CSharpEventBindParams); diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index c9a4ca277..665063613 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -984,7 +984,7 @@ namespace Flax.Build.Bindings bool useLibraryExportInPlainC = false; // True if generate separate wrapper for library imports that uses plain-C style binding (without C++ name mangling) #if USE_NETCORE string libraryEntryPoint; - if (buildData.Toolchain.Compiler == TargetCompiler.MSVC) + if (buildData.Toolchain?.Compiler == TargetCompiler.MSVC) { libraryEntryPoint = $"{caller.FullNameManaged}::Internal_{functionInfo.UniqueName}"; // MSVC allows to override exported symbol name } @@ -1123,7 +1123,7 @@ namespace Flax.Build.Bindings contents.AppendLine(); contents.Append(prevIndent).AppendLine("{"); #if USE_NETCORE - if (buildData.Toolchain.Compiler == TargetCompiler.MSVC && !useLibraryExportInPlainC) + if (buildData.Toolchain?.Compiler == TargetCompiler.MSVC && !useLibraryExportInPlainC) contents.Append(indent).AppendLine($"MSVC_FUNC_EXPORT(\"{libraryEntryPoint}\")"); // Export generated function binding under the C# name #endif if (!functionInfo.IsStatic) @@ -2003,7 +2003,7 @@ namespace Flax.Build.Bindings bool useSeparateImpl = false; // True if separate function declaration from implementation contents.AppendFormat(" DLLEXPORT static void {0}_ManagedBind(", eventInfo.Name); var signatureStart = contents.Length; - if (buildData.Toolchain.Compiler == TargetCompiler.Clang) + if (buildData.Toolchain?.Compiler == TargetCompiler.Clang) useSeparateImpl = true; // DLLEXPORT doesn't properly export function thus separate implementation from declaration if (!eventInfo.IsStatic) contents.AppendFormat("{0}* obj, ", classTypeNameNative); @@ -2021,7 +2021,7 @@ namespace Flax.Build.Bindings indent = null; } contents.AppendLine().Append(indent).Append('{').AppendLine(); - if (buildData.Toolchain.Compiler == TargetCompiler.MSVC) + if (buildData.Toolchain?.Compiler == TargetCompiler.MSVC) contents.Append(indent).AppendLine($" MSVC_FUNC_EXPORT(\"{classTypeNameManaged}::Internal_{eventInfo.Name}_Bind\")"); // Export generated function binding under the C# name contents.Append(indent).Append(" Function