You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Mono/C#: Add iOS support
Right now, games only work on devices when exported with FullAOT+Interpreter. There are some issues left that need to addressed for FullAOT alone. Right now, it's giving issues with the Godot.NativeCalls static constructor.
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace GodotTools.Utils
|
||||
{
|
||||
@@ -26,6 +27,7 @@ namespace GodotTools.Utils
|
||||
public const string UWP = "UWP";
|
||||
public const string Haiku = "Haiku";
|
||||
public const string Android = "Android";
|
||||
public const string iOS = "iOS";
|
||||
public const string HTML5 = "HTML5";
|
||||
}
|
||||
|
||||
@@ -38,6 +40,7 @@ namespace GodotTools.Utils
|
||||
public const string UWP = "uwp";
|
||||
public const string Haiku = "haiku";
|
||||
public const string Android = "android";
|
||||
public const string iOS = "iphone";
|
||||
public const string HTML5 = "javascript";
|
||||
}
|
||||
|
||||
@@ -50,6 +53,7 @@ namespace GodotTools.Utils
|
||||
[Names.UWP] = Platforms.UWP,
|
||||
[Names.Haiku] = Platforms.Haiku,
|
||||
[Names.Android] = Platforms.Android,
|
||||
[Names.iOS] = Platforms.iOS,
|
||||
[Names.HTML5] = Platforms.HTML5
|
||||
};
|
||||
|
||||
@@ -65,6 +69,7 @@ namespace GodotTools.Utils
|
||||
private static readonly Lazy<bool> _isUWP = new Lazy<bool>(() => IsOS(Names.UWP));
|
||||
private static readonly Lazy<bool> _isHaiku = new Lazy<bool>(() => IsOS(Names.Haiku));
|
||||
private static readonly Lazy<bool> _isAndroid = new Lazy<bool>(() => IsOS(Names.Android));
|
||||
private static readonly Lazy<bool> _isiOS = new Lazy<bool>(() => IsOS(Names.iOS));
|
||||
private static readonly Lazy<bool> _isHTML5 = new Lazy<bool>(() => IsOS(Names.HTML5));
|
||||
|
||||
public static bool IsWindows => _isWindows.Value || IsUWP;
|
||||
@@ -74,10 +79,11 @@ namespace GodotTools.Utils
|
||||
public static bool IsUWP => _isUWP.Value;
|
||||
public static bool IsHaiku => _isHaiku.Value;
|
||||
public static bool IsAndroid => _isAndroid.Value;
|
||||
public static bool IsiOS => _isiOS.Value;
|
||||
public static bool IsHTML5 => _isHTML5.Value;
|
||||
|
||||
private static bool? _isUnixCache;
|
||||
private static readonly string[] UnixLikePlatforms = { Names.OSX, Names.X11, Names.Server, Names.Haiku, Names.Android };
|
||||
private static readonly string[] UnixLikePlatforms = { Names.OSX, Names.X11, Names.Server, Names.Haiku, Names.Android, Names.iOS };
|
||||
|
||||
public static bool IsUnixLike()
|
||||
{
|
||||
@@ -91,12 +97,12 @@ namespace GodotTools.Utils
|
||||
|
||||
public static char PathSep => IsWindows ? ';' : ':';
|
||||
|
||||
public static string PathWhich(string name)
|
||||
public static string PathWhich([NotNull] string name)
|
||||
{
|
||||
return IsWindows ? PathWhichWindows(name) : PathWhichUnix(name);
|
||||
}
|
||||
|
||||
private static string PathWhichWindows(string name)
|
||||
private static string PathWhichWindows([NotNull] string name)
|
||||
{
|
||||
string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? new string[] { };
|
||||
string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep);
|
||||
@@ -121,7 +127,7 @@ namespace GodotTools.Utils
|
||||
select path + ext).FirstOrDefault(File.Exists);
|
||||
}
|
||||
|
||||
private static string PathWhichUnix(string name)
|
||||
private static string PathWhichUnix([NotNull] string name)
|
||||
{
|
||||
string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep);
|
||||
|
||||
@@ -163,5 +169,33 @@ namespace GodotTools.Utils
|
||||
User32Dll.AllowSetForegroundWindow(process.Id); // allows application to focus itself
|
||||
}
|
||||
}
|
||||
|
||||
public static int ExecuteCommand(string command, IEnumerable<string> arguments)
|
||||
{
|
||||
// TODO: Once we move to .NET Standard 2.1 we can use ProcessStartInfo.ArgumentList instead
|
||||
string CmdLineArgsToString(IEnumerable<string> args)
|
||||
{
|
||||
// Not perfect, but as long as we are careful...
|
||||
return string.Join(" ", args.Select(arg => arg.Contains(" ") ? $@"""{arg}""" : arg));
|
||||
}
|
||||
|
||||
var startInfo = new ProcessStartInfo(command, CmdLineArgsToString(arguments));
|
||||
|
||||
Console.WriteLine($"Executing: \"{startInfo.FileName}\" {startInfo.Arguments}");
|
||||
|
||||
// Print the output
|
||||
startInfo.RedirectStandardOutput = false;
|
||||
startInfo.RedirectStandardError = false;
|
||||
|
||||
startInfo.UseShellExecute = false;
|
||||
|
||||
using (var process = new Process { StartInfo = startInfo })
|
||||
{
|
||||
process.Start();
|
||||
process.WaitForExit();
|
||||
|
||||
return process.ExitCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user