Fix building bindings-only cross-platform with dotnet7
This commit is contained in:
2
Source/ThirdParty/nethost/nethost.Build.cs
vendored
2
Source/ThirdParty/nethost/nethost.Build.cs
vendored
@@ -39,6 +39,8 @@ public class nethost : ThirdPartyModule
|
|||||||
return; // Ignore missing Host Runtime when engine is already prebuilt
|
return; // Ignore missing Host Runtime when engine is already prebuilt
|
||||||
if (options.Flags.HasFlag(BuildFlags.GenerateProject))
|
if (options.Flags.HasFlag(BuildFlags.GenerateProject))
|
||||||
return; // Ignore missing Host Runtime at projects evaluation stage (not important)
|
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}.");
|
throw new Exception($"Missing NET SDK runtime for {options.Platform.Target} {options.Architecture}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1035,7 +1035,7 @@ namespace Flax.Build.Bindings
|
|||||||
contents.Append("bool bind);");
|
contents.Append("bool bind);");
|
||||||
#else
|
#else
|
||||||
string libraryEntryPoint;
|
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
|
libraryEntryPoint = $"{classInfo.FullNameManaged}::Internal_{eventInfo.Name}_Bind"; // MSVC allows to override exported symbol name
|
||||||
else
|
else
|
||||||
libraryEntryPoint = CppNameMangling.MangleFunctionName(buildData, eventInfo.Name + "_ManagedBind", classInfo.FullNameNativeInternal + "Internal", CSharpEventBindReturn, eventInfo.IsStatic ? null : new TypeInfo(classInfo.FullNameNative) { IsPtr = true }, CSharpEventBindParams);
|
libraryEntryPoint = CppNameMangling.MangleFunctionName(buildData, eventInfo.Name + "_ManagedBind", classInfo.FullNameNativeInternal + "Internal", CSharpEventBindReturn, eventInfo.IsStatic ? null : new TypeInfo(classInfo.FullNameNative) { IsPtr = true }, CSharpEventBindParams);
|
||||||
|
|||||||
@@ -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)
|
bool useLibraryExportInPlainC = false; // True if generate separate wrapper for library imports that uses plain-C style binding (without C++ name mangling)
|
||||||
#if USE_NETCORE
|
#if USE_NETCORE
|
||||||
string libraryEntryPoint;
|
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
|
libraryEntryPoint = $"{caller.FullNameManaged}::Internal_{functionInfo.UniqueName}"; // MSVC allows to override exported symbol name
|
||||||
}
|
}
|
||||||
@@ -1123,7 +1123,7 @@ namespace Flax.Build.Bindings
|
|||||||
contents.AppendLine();
|
contents.AppendLine();
|
||||||
contents.Append(prevIndent).AppendLine("{");
|
contents.Append(prevIndent).AppendLine("{");
|
||||||
#if USE_NETCORE
|
#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
|
contents.Append(indent).AppendLine($"MSVC_FUNC_EXPORT(\"{libraryEntryPoint}\")"); // Export generated function binding under the C# name
|
||||||
#endif
|
#endif
|
||||||
if (!functionInfo.IsStatic)
|
if (!functionInfo.IsStatic)
|
||||||
@@ -2003,7 +2003,7 @@ namespace Flax.Build.Bindings
|
|||||||
bool useSeparateImpl = false; // True if separate function declaration from implementation
|
bool useSeparateImpl = false; // True if separate function declaration from implementation
|
||||||
contents.AppendFormat(" DLLEXPORT static void {0}_ManagedBind(", eventInfo.Name);
|
contents.AppendFormat(" DLLEXPORT static void {0}_ManagedBind(", eventInfo.Name);
|
||||||
var signatureStart = contents.Length;
|
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
|
useSeparateImpl = true; // DLLEXPORT doesn't properly export function thus separate implementation from declaration
|
||||||
if (!eventInfo.IsStatic)
|
if (!eventInfo.IsStatic)
|
||||||
contents.AppendFormat("{0}* obj, ", classTypeNameNative);
|
contents.AppendFormat("{0}* obj, ", classTypeNameNative);
|
||||||
@@ -2021,7 +2021,7 @@ namespace Flax.Build.Bindings
|
|||||||
indent = null;
|
indent = null;
|
||||||
}
|
}
|
||||||
contents.AppendLine().Append(indent).Append('{').AppendLine();
|
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).AppendLine($" MSVC_FUNC_EXPORT(\"{classTypeNameManaged}::Internal_{eventInfo.Name}_Bind\")"); // Export generated function binding under the C# name
|
||||||
contents.Append(indent).Append(" Function<void(");
|
contents.Append(indent).Append(" Function<void(");
|
||||||
for (var i = 0; i < paramsCount; i++)
|
for (var i = 0; i < paramsCount; i++)
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ namespace Flax.Build
|
|||||||
{
|
{
|
||||||
if (name.Contains(":"))
|
if (name.Contains(":"))
|
||||||
throw new NotImplementedException("No nested types mangling support.");
|
throw new NotImplementedException("No nested types mangling support.");
|
||||||
|
if (buildData.Toolchain == null)
|
||||||
|
return name; // Ignore when building C# bindings only without native toolchain
|
||||||
var sb = BindingsGenerator.GetStringBuilder();
|
var sb = BindingsGenerator.GetStringBuilder();
|
||||||
switch (buildData.Toolchain.Compiler)
|
switch (buildData.Toolchain.Compiler)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user