You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
C#: Use Sdks in GodotTools csprojs and switch to nuget Microsoft.Build
This commit is contained in:
@@ -22,7 +22,10 @@ namespace GodotTools.Utils
|
||||
{
|
||||
public const string Windows = "Windows";
|
||||
public const string OSX = "OSX";
|
||||
public const string X11 = "X11";
|
||||
public const string Linux = "Linux";
|
||||
public const string FreeBSD = "FreeBSD";
|
||||
public const string NetBSD = "NetBSD";
|
||||
public const string BSD = "BSD";
|
||||
public const string Server = "Server";
|
||||
public const string UWP = "UWP";
|
||||
public const string Haiku = "Haiku";
|
||||
@@ -35,7 +38,7 @@ namespace GodotTools.Utils
|
||||
{
|
||||
public const string Windows = "windows";
|
||||
public const string OSX = "osx";
|
||||
public const string X11 = "linuxbsd";
|
||||
public const string LinuxBSD = "linuxbsd";
|
||||
public const string Server = "server";
|
||||
public const string UWP = "uwp";
|
||||
public const string Haiku = "haiku";
|
||||
@@ -48,7 +51,10 @@ namespace GodotTools.Utils
|
||||
{
|
||||
[Names.Windows] = Platforms.Windows,
|
||||
[Names.OSX] = Platforms.OSX,
|
||||
[Names.X11] = Platforms.X11,
|
||||
[Names.Linux] = Platforms.LinuxBSD,
|
||||
[Names.FreeBSD] = Platforms.LinuxBSD,
|
||||
[Names.NetBSD] = Platforms.LinuxBSD,
|
||||
[Names.BSD] = Platforms.LinuxBSD,
|
||||
[Names.Server] = Platforms.Server,
|
||||
[Names.UWP] = Platforms.UWP,
|
||||
[Names.Haiku] = Platforms.Haiku,
|
||||
@@ -62,38 +68,39 @@ namespace GodotTools.Utils
|
||||
return name.Equals(GetPlatformName(), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static bool IsAnyOS(IEnumerable<string> names)
|
||||
{
|
||||
return names.Any(p => p.Equals(GetPlatformName(), StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private static readonly IEnumerable<string> LinuxBSDPlatforms =
|
||||
new[] {Names.Linux, Names.FreeBSD, Names.NetBSD, Names.BSD};
|
||||
|
||||
private static readonly IEnumerable<string> UnixLikePlatforms =
|
||||
new[] {Names.OSX, Names.Server, Names.Haiku, Names.Android, Names.iOS}
|
||||
.Concat(LinuxBSDPlatforms).ToArray();
|
||||
|
||||
private static readonly Lazy<bool> _isWindows = new Lazy<bool>(() => IsOS(Names.Windows));
|
||||
private static readonly Lazy<bool> _isOSX = new Lazy<bool>(() => IsOS(Names.OSX));
|
||||
private static readonly Lazy<bool> _isX11 = new Lazy<bool>(() => IsOS(Names.X11));
|
||||
private static readonly Lazy<bool> _isLinuxBSD = new Lazy<bool>(() => IsAnyOS(LinuxBSDPlatforms));
|
||||
private static readonly Lazy<bool> _isServer = new Lazy<bool>(() => IsOS(Names.Server));
|
||||
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));
|
||||
private static readonly Lazy<bool> _isUnixLike = new Lazy<bool>(() => IsAnyOS(UnixLikePlatforms));
|
||||
|
||||
public static bool IsWindows => _isWindows.Value || IsUWP;
|
||||
public static bool IsOSX => _isOSX.Value;
|
||||
public static bool IsX11 => _isX11.Value;
|
||||
public static bool IsLinuxBSD => _isLinuxBSD.Value;
|
||||
public static bool IsServer => _isServer.Value;
|
||||
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, Names.iOS };
|
||||
|
||||
public static bool IsUnixLike()
|
||||
{
|
||||
if (_isUnixCache.HasValue)
|
||||
return _isUnixCache.Value;
|
||||
|
||||
string osName = GetPlatformName();
|
||||
_isUnixCache = UnixLikePlatforms.Any(p => p.Equals(osName, StringComparison.OrdinalIgnoreCase));
|
||||
return _isUnixCache.Value;
|
||||
}
|
||||
public static bool IsUnixLike => _isUnixLike.Value;
|
||||
|
||||
public static char PathSep => IsWindows ? ';' : ':';
|
||||
|
||||
@@ -121,10 +128,10 @@ namespace GodotTools.Utils
|
||||
return searchDirs.Select(dir => Path.Combine(dir, name)).FirstOrDefault(File.Exists);
|
||||
|
||||
return (from dir in searchDirs
|
||||
select Path.Combine(dir, name)
|
||||
select Path.Combine(dir, name)
|
||||
into path
|
||||
from ext in windowsExts
|
||||
select path + ext).FirstOrDefault(File.Exists);
|
||||
from ext in windowsExts
|
||||
select path + ext).FirstOrDefault(File.Exists);
|
||||
}
|
||||
|
||||
private static string PathWhichUnix([NotNull] string name)
|
||||
@@ -189,7 +196,7 @@ namespace GodotTools.Utils
|
||||
|
||||
startInfo.UseShellExecute = false;
|
||||
|
||||
using (var process = new Process { StartInfo = startInfo })
|
||||
using (var process = new Process {StartInfo = startInfo})
|
||||
{
|
||||
process.Start();
|
||||
process.WaitForExit();
|
||||
|
||||
Reference in New Issue
Block a user