Add Mono AOT for iOS to run C#
This commit is contained in:
@@ -407,6 +407,13 @@ namespace Flax.Build
|
||||
return exists;
|
||||
}
|
||||
|
||||
internal static string SelectVersionFolder(string root)
|
||||
{
|
||||
var versions = GetVersions(root);
|
||||
var version = GetVersion(versions);
|
||||
return Path.Combine(root, version);
|
||||
}
|
||||
|
||||
private static Version ParseVersion(string version)
|
||||
{
|
||||
// Give precedence to final releases over release candidate / beta releases
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Flax.Build.NativeCpp;
|
||||
|
||||
@@ -61,5 +62,37 @@ namespace Flax.Build.Platforms
|
||||
|
||||
args.Add("-miphoneos-version-min=" + Configuration.iOSMinVer);
|
||||
}
|
||||
|
||||
public override bool CompileCSharp(ref CSharpOptions options)
|
||||
{
|
||||
switch (options.Action)
|
||||
{
|
||||
case CSharpOptions.ActionTypes.GetPlatformTools:
|
||||
options.PlatformToolsPath = Path.Combine(DotNetSdk.SelectVersionFolder(Path.Combine(DotNetSdk.Instance.RootPath, "packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm64")), "tools");
|
||||
return false;
|
||||
case CSharpOptions.ActionTypes.MonoCompile:
|
||||
{
|
||||
var aotCompilerPath = Path.Combine(options.PlatformToolsPath, "mono-aot-cross");
|
||||
return true; // TODO: impl this (output assembly from aot cross-compiler and manually compile into shared library for ios)
|
||||
// Setup options
|
||||
var monoAotMode = "full";
|
||||
var monoDebugMode = options.EnableDebugSymbols ? "soft-debug" : "nodebug";
|
||||
var aotCompilerArgs = $"--aot={monoAotMode},verbose,stats,print-skipped,{monoDebugMode} -O=all";
|
||||
if (options.EnableDebugSymbols || options.EnableToolDebug)
|
||||
aotCompilerArgs = "--debug " + aotCompilerArgs;
|
||||
var envVars = new Dictionary<string, string>();
|
||||
envVars["MONO_PATH"] = options.AssembliesPath + ";" + options.ClassLibraryPath;
|
||||
if (options.EnableToolDebug)
|
||||
{
|
||||
envVars["MONO_LOG_LEVEL"] = "debug";
|
||||
}
|
||||
|
||||
// Run cross-compiler compiler
|
||||
int result = Utilities.Run(aotCompilerPath, $"{aotCompilerArgs} \"{options.InputFiles[0]}\"", null, options.PlatformToolsPath, Utilities.RunOptions.AppMustExist | Utilities.RunOptions.ConsoleLogOutput, envVars);
|
||||
return result != 0;
|
||||
}
|
||||
}
|
||||
return base.CompileCSharp(ref options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user