Update to build for Xbox

This commit is contained in:
Wojtek Figat
2024-03-21 18:07:21 +01:00
parent d6f0062198
commit 9251b80b78
5 changed files with 58 additions and 27 deletions

View File

@@ -211,7 +211,7 @@ namespace Flax.Build
/// </summary> /// </summary>
/// <param name="targetPlatform">The target platform.</param> /// <param name="targetPlatform">The target platform.</param>
/// <param name="nullIfMissing">True if return null platform if it's missing, otherwise will invoke an exception.</param> /// <param name="nullIfMissing">True if return null platform if it's missing, otherwise will invoke an exception.</param>
/// <returns>The toolchain.</returns> /// <returns>The platform.</returns>
public static Platform GetPlatform(TargetPlatform targetPlatform, bool nullIfMissing = false) public static Platform GetPlatform(TargetPlatform targetPlatform, bool nullIfMissing = false)
{ {
if (_platforms == null) if (_platforms == null)

View File

@@ -30,6 +30,8 @@ namespace Flax.Deps.Dependencies
TargetPlatform.PS4, TargetPlatform.PS4,
TargetPlatform.PS5, TargetPlatform.PS5,
TargetPlatform.Switch, TargetPlatform.Switch,
TargetPlatform.XboxOne,
TargetPlatform.XboxScarlett,
}; };
case TargetPlatform.Linux: case TargetPlatform.Linux:
return new[] return new[]
@@ -85,6 +87,13 @@ namespace Flax.Deps.Dependencies
os = "windows"; os = "windows";
runtimeFlavor = "CoreCLR"; runtimeFlavor = "CoreCLR";
break; break;
case TargetPlatform.XboxOne:
case TargetPlatform.XboxScarlett:
os = "windows";
runtimeFlavor = "Mono";
buildMonoAotCross = true;
buildArgs = $" -subset mono+libs -cmakeargs \"-DDISABLE_JIT=1-DENABLE_PERFTRACING=0-DDISABLE_REFLECTION_EMIT=1-DDISABLE_EVENTPIPE=1-DDISABLE_COM=1-DDISABLE_PROFILER=1-DDISABLE_COMPONENTS=1\" /p:FeaturePerfTracing=false /p:FeatureManagedEtw=false /p:FeatureManagedEtwChannels=false /p:FeatureEtw=false /p:ApiCompatValidateAssemblies=false";
break;
case TargetPlatform.Linux: case TargetPlatform.Linux:
os = "linux"; os = "linux";
runtimeFlavor = "CoreCLR"; runtimeFlavor = "CoreCLR";
@@ -225,22 +234,42 @@ namespace Flax.Deps.Dependencies
if (!Directory.Exists(src1)) if (!Directory.Exists(src1))
throw new DirectoryNotFoundException(src1); throw new DirectoryNotFoundException(src1);
var src2 = Path.Combine(artifacts, "bin", "native", $"{framework}-{os}-{configuration}-{arch}"); var src2 = Path.Combine(artifacts, "bin", "native", $"{framework}-{os}-{configuration}-{arch}");
if (!Directory.Exists(src1)) if (!Directory.Exists(src2))
throw new DirectoryNotFoundException(src2); throw new DirectoryNotFoundException(src2);
foreach (var file in new[] string[] libs1, libs2;
{ switch (targetPlatform)
"libmonosgen-2.0.a", {
"libmono-profiler-aot.a", case TargetPlatform.Windows:
}) case TargetPlatform.XboxOne:
Utilities.FileCopy(Path.Combine(src1, "lib", file), Path.Combine(dstBinaries, file)); case TargetPlatform.XboxScarlett:
foreach (var file in new[] libs1 = new[]
{ {
"libSystem.Globalization.Native.a", "lib/coreclr.dll",
"libSystem.IO.Compression.Native.a", "lib/coreclr.import.lib",
"libSystem.IO.Ports.Native.a", };
"libSystem.Native.a", libs2 = new string[]
}) {
Utilities.FileCopy(Path.Combine(src2, "lib", file), Path.Combine(dstBinaries, file)); };
break;
default:
libs1 = new[]
{
"lib/libmonosgen-2.0.a",
"lib/libmono-profiler-aot.a",
};
libs2 = new[]
{
"lib/libSystem.Globalization.Native.a",
"lib/libSystem.IO.Compression.Native.a",
"lib/libSystem.IO.Ports.Native.a",
"lib/libSystem.Native.a",
};
break;
}
foreach (var file in libs1)
Utilities.FileCopy(Path.Combine(src1, file), Path.Combine(dstBinaries, Path.GetFileName(file)));
foreach (var file in libs2)
Utilities.FileCopy(Path.Combine(src2, file), Path.Combine(dstBinaries, Path.GetFileName(file)));
// Include headers // Include headers
Utilities.DirectoryDelete(Path.Combine(dstBinaries, "include")); Utilities.DirectoryDelete(Path.Combine(dstBinaries, "include"));
@@ -249,11 +278,13 @@ namespace Flax.Deps.Dependencies
if (buildMonoAotCross) if (buildMonoAotCross)
{ {
// AOT compiler // AOT compiler
Utilities.FileCopy(Path.Combine(artifacts, "bin", "mono", $"{os}.x64.{configuration}", "cross", $"{os}-x64", "mono-aot-cross.exe"), Path.Combine(dstPlatform, "Binaries", "Tools", "mono-aot-cross.exe")); Utilities.FileCopy(Path.Combine(artifacts, "bin", "mono", $"{os}.x64.{configuration}", "cross", $"{(os == "windows" ? "win" : os)}-x64", "mono-aot-cross.exe"), Path.Combine(dstPlatform, "Binaries", "Tools", "mono-aot-cross.exe"));
} }
// Class library // Class library
var dstDotnetLib = Path.Combine(dstPlatform, "Dotnet", "lib", framework); var dstDotnetLib = Path.Combine(dstPlatform, "Dotnet", "lib", framework);
foreach (var subDir in Directory.GetDirectories(Path.Combine(dstPlatform, "Dotnet", "lib")))
Utilities.DirectoryDelete(subDir);
SetupDirectory(dstDotnetLib, true); SetupDirectory(dstDotnetLib, true);
Utilities.FileCopy(Path.Combine(artifacts, "bin", "mono", $"{os}.{arch}.{configuration}", privateCoreLib), Path.Combine(dstDotnetLib, privateCoreLib)); Utilities.FileCopy(Path.Combine(artifacts, "bin", "mono", $"{os}.{arch}.{configuration}", privateCoreLib), Path.Combine(dstDotnetLib, privateCoreLib));
Utilities.DirectoryCopy(Path.Combine(artifacts, "bin", "runtime", $"{framework}-{os}-{configuration}-{arch}"), dstDotnetLib, false, true, "*.dll"); Utilities.DirectoryCopy(Path.Combine(artifacts, "bin", "runtime", $"{framework}-{os}-{configuration}-{arch}"), dstDotnetLib, false, true, "*.dll");
@@ -300,6 +331,8 @@ namespace Flax.Deps.Dependencies
{ {
case TargetPlatform.PS4: case TargetPlatform.PS4:
case TargetPlatform.PS5: case TargetPlatform.PS5:
case TargetPlatform.XboxOne:
case TargetPlatform.XboxScarlett:
Build(options, platform, TargetArchitecture.x64); Build(options, platform, TargetArchitecture.x64);
break; break;
case TargetPlatform.Android: case TargetPlatform.Android:

View File

@@ -18,13 +18,13 @@ namespace Flax.Build.Platforms
protected GDKPlatform() protected GDKPlatform()
{ {
// Visual Studio 2017 or newer required // Visual Studio 2017 or newer required
var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version == VisualStudioVersion.VisualStudio2017 || x.Version == VisualStudioVersion.VisualStudio2019); var visualStudio = VisualStudioInstance.GetInstances().FirstOrDefault(x => x.Version >= VisualStudioVersion.VisualStudio2017);
if (visualStudio == null) if (visualStudio == null)
_hasRequiredSDKsInstalled = false; _hasRequiredSDKsInstalled = false;
// Windows 10.0.19041.0 SDK or newer required // Windows 10.0.19041.0 SDK or newer required
var sdks = GetSDKs(); var sdks = GetSDKs();
if (!sdks.ContainsKey(WindowsPlatformSDK.v10_0_19041_0)) if (sdks.All(x => x.Key < WindowsPlatformSDK.v10_0_19041_0))
_hasRequiredSDKsInstalled = false; _hasRequiredSDKsInstalled = false;
// v141 toolset or newer required // v141 toolset or newer required
@@ -33,9 +33,7 @@ namespace Flax.Build.Platforms
!toolsets.ContainsKey(WindowsPlatformToolset.v142) && !toolsets.ContainsKey(WindowsPlatformToolset.v142) &&
!toolsets.ContainsKey(WindowsPlatformToolset.v143) && !toolsets.ContainsKey(WindowsPlatformToolset.v143) &&
!toolsets.ContainsKey(WindowsPlatformToolset.v144)) !toolsets.ContainsKey(WindowsPlatformToolset.v144))
{
_hasRequiredSDKsInstalled = false; _hasRequiredSDKsInstalled = false;
}
} }
} }
} }

View File

@@ -2,7 +2,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using Flax.Build.NativeCpp; using Flax.Build.NativeCpp;
namespace Flax.Build.Platforms namespace Flax.Build.Platforms
@@ -19,8 +18,9 @@ namespace Flax.Build.Platforms
/// </summary> /// </summary>
/// <param name="platform">The platform.</param> /// <param name="platform">The platform.</param>
/// <param name="architecture">The architecture.</param> /// <param name="architecture">The architecture.</param>
protected GDKToolchain(GDKPlatform platform, TargetArchitecture architecture) /// <param name="toolset">The Windows toolset to use.</param>
: base(platform, architecture, WindowsPlatformBase.GetToolsets().Keys.Where(x => x <= WindowsPlatformToolset.v142).Max(), WindowsPlatformSDK.v10_0_19041_0) protected GDKToolchain(GDKPlatform platform, TargetArchitecture architecture, WindowsPlatformToolset toolset = WindowsPlatformToolset.Latest)
: base(platform, architecture, toolset, WindowsPlatformSDK.Latest)
{ {
// Setup system paths // Setup system paths
SystemIncludePaths.Add(Path.Combine(GDK.Instance.RootPath, "GRDK\\GameKit\\Include")); SystemIncludePaths.Add(Path.Combine(GDK.Instance.RootPath, "GRDK\\GameKit\\Include"));
@@ -42,7 +42,7 @@ namespace Flax.Build.Platforms
options.LinkEnv.InputLibraries.Add("xgameruntime.lib"); options.LinkEnv.InputLibraries.Add("xgameruntime.lib");
options.LinkEnv.InputLibraries.Add("xgameplatform.lib"); options.LinkEnv.InputLibraries.Add("xgameplatform.lib");
options.LinkEnv.InputLibraries.Add("Microsoft.Xbox.Services.142.GDK.C.lib"); options.LinkEnv.InputLibraries.Add($"Microsoft.Xbox.Services.{(int)Toolset}.GDK.C.lib");
var toolsetPath = WindowsPlatformBase.GetToolsets()[Toolset]; var toolsetPath = WindowsPlatformBase.GetToolsets()[Toolset];
var toolsPath = WindowsPlatformBase.GetVCToolPath64(Toolset); var toolsPath = WindowsPlatformBase.GetVCToolPath64(Toolset);

View File

@@ -62,10 +62,10 @@ namespace Flax.Build.Platforms
case TargetPlatform.UWP: return GetSDKs().FirstOrDefault(x => x.Key != WindowsPlatformSDK.v8_1).Value != null; case TargetPlatform.UWP: return GetSDKs().FirstOrDefault(x => x.Key != WindowsPlatformSDK.v8_1).Value != null;
case TargetPlatform.PS4: return Sdk.HasValid("PS4Sdk"); case TargetPlatform.PS4: return Sdk.HasValid("PS4Sdk");
case TargetPlatform.PS5: return Sdk.HasValid("PS5Sdk"); case TargetPlatform.PS5: return Sdk.HasValid("PS5Sdk");
case TargetPlatform.XboxOne:
case TargetPlatform.XboxScarlett: return GetSDKs().ContainsKey(WindowsPlatformSDK.v10_0_19041_0) && Sdk.HasValid("GDK");
case TargetPlatform.Android: return AndroidSdk.Instance.IsValid && AndroidNdk.Instance.IsValid; case TargetPlatform.Android: return AndroidSdk.Instance.IsValid && AndroidNdk.Instance.IsValid;
case TargetPlatform.Switch: return Sdk.HasValid("SwitchSdk"); case TargetPlatform.Switch: return Sdk.HasValid("SwitchSdk");
case TargetPlatform.XboxOne:
case TargetPlatform.XboxScarlett: return GetPlatform(platform, true)?.HasRequiredSDKsInstalled ?? false;
default: return false; default: return false;
} }
} }