Various porting patches
This commit is contained in:
@@ -281,17 +281,18 @@ bool MCore::LoadEngine()
|
||||
flaxLibraryPath = ::String(StringUtils::GetDirectoryName(Platform::GetExecutableFilePath())) / StringUtils::GetFileName(flaxLibraryPath);
|
||||
}
|
||||
#endif
|
||||
#if !PLATFORM_SWITCH
|
||||
if (!FileSystem::FileExists(flaxLibraryPath))
|
||||
{
|
||||
LOG(Error, "Flax Engine native library file is missing ({0})", flaxLibraryPath);
|
||||
}
|
||||
#endif
|
||||
RegisterNativeLibrary("FlaxEngine", flaxLibraryPath.Get());
|
||||
|
||||
MRootDomain = New<MDomain>("Root");
|
||||
MDomains.Add(MRootDomain);
|
||||
|
||||
void* GetRuntimeInformationPtr = GetStaticMethodPointer(TEXT("GetRuntimeInformation"));
|
||||
char* buildInfo = CallStaticMethod<char*>(GetRuntimeInformationPtr);
|
||||
char* buildInfo = CallStaticMethod<char*>(GetStaticMethodPointer(TEXT("GetRuntimeInformation")));
|
||||
LOG(Info, ".NET runtime version: {0}", ::String(buildInfo));
|
||||
MCore::GC::FreeMemory(buildInfo);
|
||||
|
||||
@@ -2047,7 +2048,7 @@ bool InitHostfxr()
|
||||
#endif
|
||||
|
||||
// Platform-specific setup
|
||||
#if PLATFORM_IOS
|
||||
#if PLATFORM_IOS || PLATFORM_SWITCH
|
||||
setenv("MONO_AOT_MODE", "aot", 1);
|
||||
setenv("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1", 1);
|
||||
#endif
|
||||
|
||||
@@ -180,8 +180,8 @@ namespace FlaxEngine
|
||||
|
||||
private static void OnLocalizationChanged()
|
||||
{
|
||||
// iOS uses globalization-invariant mode so ignore it
|
||||
#if !PLATFORM_IOS
|
||||
// Invariant-globalization only (see InitHostfxr with Mono)
|
||||
#if !(PLATFORM_IOS || PLATFORM_SWITCH)
|
||||
var currentThread = Thread.CurrentThread;
|
||||
var language = Localization.CurrentLanguage;
|
||||
if (language != null)
|
||||
@@ -238,6 +238,10 @@ namespace FlaxEngine
|
||||
|
||||
internal static ManagedHandle CultureInfoToManaged(int lcid)
|
||||
{
|
||||
#if PLATFORM_IOS || PLATFORM_SWITCH
|
||||
// Invariant-globalization only (see InitHostfxr with Mono)
|
||||
lcid = 0;
|
||||
#endif
|
||||
return ManagedHandle.Alloc(new CultureInfo(lcid));
|
||||
}
|
||||
|
||||
|
||||
22
Source/ThirdParty/nethost/nethost.Build.cs
vendored
22
Source/ThirdParty/nethost/nethost.Build.cs
vendored
@@ -74,12 +74,24 @@ public class nethost : ThirdPartyModule
|
||||
case TargetPlatform.Switch:
|
||||
case TargetPlatform.PS4:
|
||||
case TargetPlatform.PS5:
|
||||
options.OutputFiles.Add(Path.Combine(hostRuntime.Path, "libmonosgen-2.0.a"));
|
||||
options.OutputFiles.Add(Path.Combine(hostRuntime.Path, "libSystem.Native.a"));
|
||||
options.OutputFiles.Add(Path.Combine(hostRuntime.Path, "libSystem.IO.Ports.Native.a"));
|
||||
options.OutputFiles.Add(Path.Combine(hostRuntime.Path, "libSystem.IO.Compression.Native.a"));
|
||||
options.OutputFiles.Add(Path.Combine(hostRuntime.Path, "libSystem.Globalization.Native.a"));
|
||||
{
|
||||
var type = Flax.Build.Utilities.GetType($"Flax.Build.Platforms.{options.Platform.Target}.nethost");
|
||||
var onLink = type?.GetMethod("OnLink");
|
||||
if (onLink != null)
|
||||
{
|
||||
// Custom linking logic overriden by platform tools
|
||||
onLink.Invoke(null, new object[] { options, hostRuntime.Path });
|
||||
}
|
||||
else
|
||||
{
|
||||
options.OutputFiles.Add(Path.Combine(hostRuntime.Path, "libmonosgen-2.0.a"));
|
||||
options.OutputFiles.Add(Path.Combine(hostRuntime.Path, "libSystem.Native.a"));
|
||||
options.OutputFiles.Add(Path.Combine(hostRuntime.Path, "libSystem.IO.Ports.Native.a"));
|
||||
options.OutputFiles.Add(Path.Combine(hostRuntime.Path, "libSystem.IO.Compression.Native.a"));
|
||||
options.OutputFiles.Add(Path.Combine(hostRuntime.Path, "libSystem.Globalization.Native.a"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TargetPlatform.Android:
|
||||
options.PublicDefinitions.Add("USE_MONO_DYNAMIC_LIB");
|
||||
options.DependencyFiles.Add(Path.Combine(hostRuntime.Path, "libmonosgen-2.0.so"));
|
||||
|
||||
@@ -352,6 +352,16 @@ namespace Flax.Build
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls <see cref="Type.GetType()"/> within Flax.Build context - can be used by build scripts to properly find a type by name.
|
||||
/// </summary>
|
||||
/// <param name="name">The full name (namespace with class name).</param>
|
||||
/// <returns>Type or null if not found.</returns>
|
||||
public static Type GetType(string name)
|
||||
{
|
||||
return Type.GetType(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the external program.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user