From 0cdce9dba23ba1bf45d2d41625f0b13c92ada6bd Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 25 Apr 2024 23:09:18 +0200 Subject: [PATCH] Upgrade GDK to `230305` and support `v143` MSVC toolset --- .../Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs | 9 ++------- Source/Tools/Flax.Build/Platforms/GDK/GDK.cs | 2 +- Source/Tools/Flax.Build/Platforms/GDK/GDKToolchain.cs | 10 +++++++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs index 318223228..3cc80f888 100644 --- a/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs +++ b/Source/Tools/Flax.Build/Deps/Dependencies/DirectXTex.cs @@ -73,13 +73,8 @@ namespace Flax.Deps.Dependencies case TargetPlatform.XboxOne: case TargetPlatform.XboxScarlett: { - var solutionPath = Path.Combine(root, "DirectXTex_GXDK_2019.sln"); - File.Copy(Path.Combine(GetBinariesFolder(options, platform), "DirectXTex_GXDK_2019.sln"), solutionPath, true); - var projectFileContents = File.ReadAllText(Path.Combine(GetBinariesFolder(options, platform), "DirectXTex_GXDK_2019.vcxproj")); - projectFileContents = projectFileContents.Replace("___VS_TOOLSET___", "v142"); - var projectPath = Path.Combine(root, "DirectXTex", "DirectXTex_GXDK_2019.vcxproj"); - File.WriteAllText(projectPath, projectFileContents); - var binFolder = Path.Combine(root, "DirectXTex", "Bin", "GXDK_2019"); + var solutionPath = Path.Combine(root, "DirectXTex_GDK_2022.sln"); + var binFolder = Path.Combine(root, "DirectXTex", "Bin", "GDK_2022"); var xboxName = platform == TargetPlatform.XboxOne ? "Gaming.Xbox.XboxOne.x64" : "Gaming.Xbox.Scarlett.x64"; Deploy.VCEnvironment.BuildSolution(solutionPath, configuration, xboxName); var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.x64); diff --git a/Source/Tools/Flax.Build/Platforms/GDK/GDK.cs b/Source/Tools/Flax.Build/Platforms/GDK/GDK.cs index 59f73b20d..a21a4bb1b 100644 --- a/Source/Tools/Flax.Build/Platforms/GDK/GDK.cs +++ b/Source/Tools/Flax.Build/Platforms/GDK/GDK.cs @@ -53,7 +53,7 @@ namespace Flax.Build.Platforms var versionText = contents.Substring(start, end - start); Version = new Version(int.Parse(versionText), 0); - var minEdition = 200500; + var minEdition = 230305; if (Version.Major < minEdition) { Log.Error(string.Format("Unsupported GDK version {0}. Minimum supported is edition {1}.", Version.Major, minEdition)); diff --git a/Source/Tools/Flax.Build/Platforms/GDK/GDKToolchain.cs b/Source/Tools/Flax.Build/Platforms/GDK/GDKToolchain.cs index 9da10ccc0..8e56950e7 100644 --- a/Source/Tools/Flax.Build/Platforms/GDK/GDKToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/GDK/GDKToolchain.cs @@ -26,8 +26,9 @@ namespace Flax.Build.Platforms SystemIncludePaths.Add(Path.Combine(GDK.Instance.RootPath, "GRDK\\GameKit\\Include")); SystemLibraryPaths.Add(Path.Combine(GDK.Instance.RootPath, "GRDK\\GameKit\\Lib\\amd64")); var xboxServicesPath = Path.Combine(GDK.Instance.RootPath, "GRDK\\ExtensionLibraries\\Xbox.Services.API.C\\DesignTime\\CommonConfiguration\\Neutral\\"); + var xboxServicesToolset = Toolset > WindowsPlatformToolset.v142 ? WindowsPlatformToolset.v142 : Toolset; SystemIncludePaths.Add(xboxServicesPath + "Include"); - SystemLibraryPaths.Add(xboxServicesPath + "Lib\\Release\\" + Toolset); + SystemLibraryPaths.Add(xboxServicesPath + "Lib\\Release\\" + xboxServicesToolset); } /// @@ -42,7 +43,8 @@ namespace Flax.Build.Platforms options.LinkEnv.InputLibraries.Add("xgameruntime.lib"); options.LinkEnv.InputLibraries.Add("xgameplatform.lib"); - options.LinkEnv.InputLibraries.Add($"Microsoft.Xbox.Services.{(int)Toolset}.GDK.C.lib"); + var xboxServicesToolset = Toolset > WindowsPlatformToolset.v142 ? WindowsPlatformToolset.v142 : Toolset; + options.LinkEnv.InputLibraries.Add($"Microsoft.Xbox.Services.{(int)xboxServicesToolset}.GDK.C.lib"); var toolsetPath = WindowsPlatformBase.GetToolsets()[Toolset]; var toolsPath = WindowsPlatformBase.GetVCToolPath64(Toolset); @@ -50,7 +52,9 @@ namespace Flax.Build.Platforms throw new Exception("Don't use debug CRT on GDK."); var name = Path.GetFileName(toolsetPath); var redistToolsPath = Path.Combine(toolsPath, "..", "..", "..", "..", "..", "..", "Redist/MSVC/"); - var paths = Directory.GetDirectories(redistToolsPath, name.Substring(0, 5) + "*"); + var paths = Directory.GetDirectories(redistToolsPath, name.Substring(0, 2) + "*"); + if (paths.Length == 0) + throw new Exception($"Failed to find MSVC redistribute binaries for toolset '{Toolset}' inside folder '{toolsPath}'"); redistToolsPath = Path.Combine(paths[0], "x64", "Microsoft.VC" + (int)Toolset + ".CRT"); redistToolsPath = Utilities.RemovePathRelativeParts(redistToolsPath); options.DependencyFiles.Add(Path.Combine(redistToolsPath, "concrt140.dll"));