Finish Mono AOT for iOS with .NET 7
This commit is contained in:
@@ -174,24 +174,36 @@ bool DeployDataStep::Perform(CookingData& data)
|
||||
String packFolder = srcDotnet / TEXT("../../../");
|
||||
String dstDotnetLibs = dstDotnet, srcDotnetLibs = srcDotnet;
|
||||
StringUtils::PathRemoveRelativeParts(packFolder);
|
||||
if (usAOT && srcDotnetFromEngine)
|
||||
if (usAOT)
|
||||
{
|
||||
// AOT runtime files inside Engine Platform folder
|
||||
packFolder /= TEXT("Dotnet");
|
||||
dstDotnetLibs /= TEXT("lib/net7.0");
|
||||
srcDotnetLibs = packFolder / TEXT("lib/net7.0");
|
||||
}
|
||||
else if (srcDotnetFromEngine)
|
||||
{
|
||||
// Runtime files inside Engine Platform folder
|
||||
dstDotnetLibs /= TEXT("lib/net7.0");
|
||||
srcDotnetLibs /= TEXT("lib/net7.0");
|
||||
if (srcDotnetFromEngine)
|
||||
{
|
||||
// AOT runtime files inside Engine Platform folder
|
||||
packFolder /= TEXT("Dotnet");
|
||||
dstDotnetLibs /= TEXT("lib/net7.0");
|
||||
srcDotnetLibs = packFolder / TEXT("lib/net7.0");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Runtime files inside Dotnet SDK folder but placed for AOT
|
||||
dstDotnetLibs /= TEXT("lib/net7.0");
|
||||
srcDotnetLibs /= TEXT("../lib/net7.0");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Runtime files inside Dotnet SDK folder
|
||||
dstDotnetLibs /= TEXT("shared/Microsoft.NETCore.App");
|
||||
srcDotnetLibs /= TEXT("../lib/net7.0");
|
||||
if (srcDotnetFromEngine)
|
||||
{
|
||||
// Runtime files inside Engine Platform folder
|
||||
dstDotnetLibs /= TEXT("lib/net7.0");
|
||||
srcDotnetLibs /= TEXT("lib/net7.0");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Runtime files inside Dotnet SDK folder
|
||||
dstDotnetLibs /= TEXT("shared/Microsoft.NETCore.App");
|
||||
srcDotnetLibs /= TEXT("../lib/net7.0");
|
||||
}
|
||||
}
|
||||
FileSystem::CopyFile(dstDotnet / TEXT("LICENSE.TXT"), packFolder / TEXT("LICENSE.txt"));
|
||||
FileSystem::CopyFile(dstDotnet / TEXT("LICENSE.TXT"), packFolder / TEXT("LICENSE.TXT"));
|
||||
|
||||
@@ -79,6 +79,7 @@ namespace Flax.Build.Platforms
|
||||
var inputFileAsm = inputFile + ".s";
|
||||
var inputFileObj = inputFile + ".o";
|
||||
var outputFileDylib = options.OutputFiles[0];
|
||||
var inputFileFolder = Path.GetDirectoryName(inputFile);
|
||||
|
||||
// Setup options
|
||||
var monoAotMode = "full";
|
||||
@@ -87,30 +88,35 @@ namespace Flax.Build.Platforms
|
||||
if (options.EnableDebugSymbols || options.EnableToolDebug)
|
||||
aotCompilerArgs = "--debug " + aotCompilerArgs;
|
||||
var envVars = new Dictionary<string, string>();
|
||||
envVars["MONO_PATH"] = options.AssembliesPath + ";" + options.ClassLibraryPath;
|
||||
envVars["MONO_PATH"] = options.AssembliesPath + ":" + options.ClassLibraryPath;
|
||||
if (options.EnableToolDebug)
|
||||
{
|
||||
envVars["MONO_LOG_LEVEL"] = "debug";
|
||||
}
|
||||
|
||||
// Run cross-compiler compiler (outputs assembly code)
|
||||
int result = Utilities.Run(aotCompilerPath, $"{aotCompilerArgs} \"{inputFile}\"", null, options.PlatformToolsPath, Utilities.RunOptions.AppMustExist | Utilities.RunOptions.ConsoleLogOutput, envVars);
|
||||
int result = Utilities.Run(aotCompilerPath, $"{aotCompilerArgs} \"{inputFile}\"", null, inputFileFolder, Utilities.RunOptions.AppMustExist | Utilities.RunOptions.ConsoleLogOutput, envVars);
|
||||
if (result != 0)
|
||||
{
|
||||
// Try without optimizations as a fallback
|
||||
aotCompilerArgs = aotCompilerArgs.Replace("-O=all", "");
|
||||
result = Utilities.Run(aotCompilerPath, $"{aotCompilerArgs} \"{inputFile}\"", null, options.PlatformToolsPath, Utilities.RunOptions.AppMustExist | Utilities.RunOptions.ConsoleLogOutput, envVars);
|
||||
result = Utilities.Run(aotCompilerPath, $"{aotCompilerArgs} \"{inputFile}\"", null, inputFileFolder, Utilities.RunOptions.AppMustExist | Utilities.RunOptions.ConsoleLogOutput, envVars);
|
||||
if (result != 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get build args for iOS
|
||||
var clangArgs = new List<string>();
|
||||
AddArgsCommon(null, clangArgs);
|
||||
var clangArgsText = string.Join(" ", clangArgs);
|
||||
|
||||
// Build object file
|
||||
result = Utilities.Run(clangPath, $"\"{inputFileAsm}\" \"{inputFileObj}\"", null, options.PlatformToolsPath, Utilities.RunOptions.AppMustExist | Utilities.RunOptions.ConsoleLogOutput, envVars);
|
||||
result = Utilities.Run(clangPath, $"\"{inputFileAsm}\" -c -o \"{inputFileObj}\" " + clangArgsText, null, inputFileFolder, Utilities.RunOptions.AppMustExist | Utilities.RunOptions.ConsoleLogOutput, envVars);
|
||||
if (result != 0)
|
||||
return true;
|
||||
|
||||
// Build dylib file
|
||||
result = Utilities.Run(clangPath, $"\"{inputFileObj}\" -dynamiclib -o \"{outputFileDylib}\"", null, options.PlatformToolsPath, Utilities.RunOptions.AppMustExist | Utilities.RunOptions.ConsoleLogOutput, envVars);
|
||||
result = Utilities.Run(clangPath, $"\"{inputFileObj}\" -dynamiclib -fPIC -o \"{outputFileDylib}\" " + clangArgsText, null, inputFileFolder, Utilities.RunOptions.AppMustExist | Utilities.RunOptions.ConsoleLogOutput, envVars);
|
||||
if (result != 0)
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user