Support using native host MSVC binaries on ARM64
This commit is contained in:
@@ -47,7 +47,7 @@ namespace Flax.Build.Platforms
|
|||||||
options.LinkEnv.InputLibraries.Add($"Microsoft.Xbox.Services.{(int)xboxServicesToolset}.GDK.C.lib");
|
options.LinkEnv.InputLibraries.Add($"Microsoft.Xbox.Services.{(int)xboxServicesToolset}.GDK.C.lib");
|
||||||
|
|
||||||
var toolsetPath = WindowsPlatformBase.GetToolsets()[Toolset];
|
var toolsetPath = WindowsPlatformBase.GetToolsets()[Toolset];
|
||||||
var toolsPath = WindowsPlatformBase.GetVCToolPath64(Toolset);
|
var toolsPath = WindowsPlatformBase.GetVCToolPath(Toolset, TargetArchitecture.x64, Architecture);
|
||||||
if (options.CompileEnv.UseDebugCRT)
|
if (options.CompileEnv.UseDebugCRT)
|
||||||
throw new Exception("Don't use debug CRT on GDK.");
|
throw new Exception("Don't use debug CRT on GDK.");
|
||||||
var name = Path.GetFileName(toolsetPath);
|
var name = Path.GetFileName(toolsetPath);
|
||||||
|
|||||||
@@ -409,101 +409,68 @@ namespace Flax.Build.Platforms
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the path to the 32-bit tool binaries.
|
/// Gets the path to the VC++ tool binaries for specified host and target architectures.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="toolset">The version of the toolset to use.</param>
|
/// <param name="toolset">The version of the toolset to use.</param>
|
||||||
/// <returns>The directory containing the 64-bit toolchain binaries.</returns>
|
/// <param name="hostArchitecture">The host architecture for native binaries.</param>
|
||||||
public static string GetVCToolPath32(WindowsPlatformToolset toolset)
|
/// <param name="architecture">The target architecture to build for.</param>
|
||||||
|
/// <returns>The directory containing the toolchain binaries.</returns>
|
||||||
|
public static string GetVCToolPath(WindowsPlatformToolset toolset, TargetArchitecture hostArchitecture, TargetArchitecture architecture)
|
||||||
{
|
{
|
||||||
|
if (architecture == TargetArchitecture.AnyCPU)
|
||||||
|
architecture = hostArchitecture;
|
||||||
var toolsets = GetToolsets();
|
var toolsets = GetToolsets();
|
||||||
var vcToolChainDir = toolsets[toolset];
|
var vcToolChainDir = toolsets[toolset];
|
||||||
|
|
||||||
switch (toolset)
|
switch (toolset)
|
||||||
{
|
{
|
||||||
case WindowsPlatformToolset.v140:
|
case WindowsPlatformToolset.v140:
|
||||||
{
|
|
||||||
string compilerPath = Path.Combine(vcToolChainDir, "bin", "cl.exe");
|
|
||||||
if (File.Exists(compilerPath))
|
|
||||||
{
|
{
|
||||||
return Path.GetDirectoryName(compilerPath);
|
if (hostArchitecture != TargetArchitecture.x86)
|
||||||
}
|
{
|
||||||
|
string nativeCompilerPath = Path.Combine(vcToolChainDir, "bin", "amd64", "cl.exe");
|
||||||
|
if (File.Exists(nativeCompilerPath))
|
||||||
|
{
|
||||||
|
return Path.GetDirectoryName(nativeCompilerPath);
|
||||||
|
}
|
||||||
|
|
||||||
throw new Exception(string.Format("No 32-bit compiler toolchain found in {0}", compilerPath));
|
string crossCompilerPath = Path.Combine(vcToolChainDir, "bin", "x86_amd64", "cl.exe");
|
||||||
}
|
if (File.Exists(crossCompilerPath))
|
||||||
case WindowsPlatformToolset.v141:
|
{
|
||||||
case WindowsPlatformToolset.v142:
|
return Path.GetDirectoryName(crossCompilerPath);
|
||||||
case WindowsPlatformToolset.v143:
|
}
|
||||||
case WindowsPlatformToolset.v144:
|
throw new Exception(string.Format("No {0} host compiler toolchain found in {1} or {2}", hostArchitecture.ToString(), nativeCompilerPath, crossCompilerPath));
|
||||||
{
|
}
|
||||||
/*
|
else
|
||||||
string crossCompilerPath = Path.Combine(vcToolChainDir, "bin", "HostX64", "x86", "cl.exe");
|
{
|
||||||
if (File.Exists(crossCompilerPath))
|
string compilerPath = Path.Combine(vcToolChainDir, "bin", "cl.exe");
|
||||||
|
if (File.Exists(compilerPath))
|
||||||
|
{
|
||||||
|
return Path.GetDirectoryName(compilerPath);
|
||||||
|
}
|
||||||
|
throw new Exception(string.Format("No {0} host compiler toolchain found in {1}", hostArchitecture.ToString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case WindowsPlatformToolset.v141:
|
||||||
|
case WindowsPlatformToolset.v142:
|
||||||
|
case WindowsPlatformToolset.v143:
|
||||||
|
case WindowsPlatformToolset.v144:
|
||||||
{
|
{
|
||||||
return Path.GetDirectoryName(crossCompilerPath);
|
string hostFolder = hostArchitecture == TargetArchitecture.x86 ? "HostX86" : $"Host{hostArchitecture.ToString().ToLower()}";
|
||||||
|
string nativeCompilerPath = Path.Combine(vcToolChainDir, "bin", hostFolder, architecture.ToString().ToLower(), "cl.exe");
|
||||||
|
if (File.Exists(nativeCompilerPath))
|
||||||
|
{
|
||||||
|
return Path.GetDirectoryName(nativeCompilerPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
string crossCompilerPath = Path.Combine(vcToolChainDir, "bin", hostFolder, architecture.ToString().ToLower(), "cl.exe");
|
||||||
|
if (File.Exists(crossCompilerPath))
|
||||||
|
{
|
||||||
|
return Path.GetDirectoryName(crossCompilerPath);
|
||||||
|
}
|
||||||
|
throw new Exception(string.Format("No {0} host compiler toolchain found in {1} or {2}", hostArchitecture.ToString(), nativeCompilerPath, crossCompilerPath));
|
||||||
}
|
}
|
||||||
*/
|
default: throw new ArgumentOutOfRangeException(nameof(toolset), toolset, null);
|
||||||
|
|
||||||
string nativeCompilerPath = Path.Combine(vcToolChainDir, "bin", "HostX86", "x86", "cl.exe");
|
|
||||||
if (File.Exists(nativeCompilerPath))
|
|
||||||
{
|
|
||||||
return Path.GetDirectoryName(nativeCompilerPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
//throw new Exception(string.Format("No 32-bit compiler toolchain found in {0} or {1}", crossCompilerPath, nativeCompilerPath));
|
|
||||||
throw new Exception(string.Format("No 32-bit compiler toolchain found in {0}", nativeCompilerPath));
|
|
||||||
}
|
|
||||||
default: throw new ArgumentOutOfRangeException(nameof(toolset), toolset, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the path to the 64-bit tool binaries.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="toolset">The version of the toolset to use.</param>
|
|
||||||
/// <returns>The directory containing the 64-bit toolchain binaries.</returns>
|
|
||||||
public static string GetVCToolPath64(WindowsPlatformToolset toolset)
|
|
||||||
{
|
|
||||||
var toolsets = GetToolsets();
|
|
||||||
var vcToolChainDir = toolsets[toolset];
|
|
||||||
|
|
||||||
switch (toolset)
|
|
||||||
{
|
|
||||||
case WindowsPlatformToolset.v140:
|
|
||||||
{
|
|
||||||
string nativeCompilerPath = Path.Combine(vcToolChainDir, "bin", "amd64", "cl.exe");
|
|
||||||
if (File.Exists(nativeCompilerPath))
|
|
||||||
{
|
|
||||||
return Path.GetDirectoryName(nativeCompilerPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
string crossCompilerPath = Path.Combine(vcToolChainDir, "bin", "x86_amd64", "cl.exe");
|
|
||||||
if (File.Exists(crossCompilerPath))
|
|
||||||
{
|
|
||||||
return Path.GetDirectoryName(crossCompilerPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception(string.Format("No 64-bit compiler toolchain found in {0} or {1}", nativeCompilerPath, crossCompilerPath));
|
|
||||||
}
|
|
||||||
case WindowsPlatformToolset.v141:
|
|
||||||
case WindowsPlatformToolset.v142:
|
|
||||||
case WindowsPlatformToolset.v143:
|
|
||||||
case WindowsPlatformToolset.v144:
|
|
||||||
{
|
|
||||||
string nativeCompilerPath = Path.Combine(vcToolChainDir, "bin", "HostX64", "x64", "cl.exe");
|
|
||||||
if (File.Exists(nativeCompilerPath))
|
|
||||||
{
|
|
||||||
return Path.GetDirectoryName(nativeCompilerPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
string crossCompilerPath = Path.Combine(vcToolChainDir, "bin", "HostX86", "x64", "cl.exe");
|
|
||||||
if (File.Exists(crossCompilerPath))
|
|
||||||
{
|
|
||||||
return Path.GetDirectoryName(crossCompilerPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception(string.Format("No 64-bit compiler toolchain found in {0} or {1}", nativeCompilerPath, crossCompilerPath));
|
|
||||||
}
|
|
||||||
default: throw new ArgumentOutOfRangeException(nameof(toolset), toolset, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Flax.Build.Graph;
|
using Flax.Build.Graph;
|
||||||
@@ -133,16 +134,12 @@ namespace Flax.Build.Platforms
|
|||||||
throw new Exception(string.Format("Missing SDK {0} for platform Windows", SDK));
|
throw new Exception(string.Format("Missing SDK {0} for platform Windows", SDK));
|
||||||
|
|
||||||
// Get the tools paths
|
// Get the tools paths
|
||||||
string vcToolPath;
|
var hostArchitecture = Platform.BuildTargetArchitecture;
|
||||||
if (Architecture == TargetArchitecture.x64)
|
_vcToolPath = WindowsPlatformBase.GetVCToolPath(Toolset, hostArchitecture, Architecture);
|
||||||
vcToolPath = WindowsPlatformBase.GetVCToolPath64(Toolset);
|
_compilerPath = Path.Combine(_vcToolPath, "cl.exe");
|
||||||
else
|
_linkerPath = Path.Combine(_vcToolPath, "link.exe");
|
||||||
vcToolPath = WindowsPlatformBase.GetVCToolPath32(Toolset);
|
_libToolPath = Path.Combine(_vcToolPath, "lib.exe");
|
||||||
_vcToolPath = vcToolPath;
|
_xdcmakePath = Path.Combine(_vcToolPath, "xdcmake.exe");
|
||||||
_compilerPath = Path.Combine(vcToolPath, "cl.exe");
|
|
||||||
_linkerPath = Path.Combine(vcToolPath, "link.exe");
|
|
||||||
_libToolPath = Path.Combine(vcToolPath, "lib.exe");
|
|
||||||
_xdcmakePath = Path.Combine(vcToolPath, "xdcmake.exe");
|
|
||||||
|
|
||||||
// Add Visual C++ toolset include and library paths
|
// Add Visual C++ toolset include and library paths
|
||||||
var vcToolChainDir = toolsets[Toolset];
|
var vcToolChainDir = toolsets[Toolset];
|
||||||
@@ -166,7 +163,7 @@ namespace Flax.Build.Platforms
|
|||||||
case TargetArchitecture.x64:
|
case TargetArchitecture.x64:
|
||||||
SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib", "amd64"));
|
SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib", "amd64"));
|
||||||
break;
|
break;
|
||||||
default: throw new InvalidArchitectureException(architecture);
|
default: throw new InvalidArchitectureException(Architecture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When using Visual Studio 2015 toolset and using pre-Windows 10 SDK, find a Windows 10 SDK and add the UCRT include paths
|
// When using Visual Studio 2015 toolset and using pre-Windows 10 SDK, find a Windows 10 SDK and add the UCRT include paths
|
||||||
@@ -198,7 +195,7 @@ namespace Flax.Build.Platforms
|
|||||||
case TargetArchitecture.x64:
|
case TargetArchitecture.x64:
|
||||||
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x64"));
|
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x64"));
|
||||||
break;
|
break;
|
||||||
default: throw new InvalidArchitectureException(architecture);
|
default: throw new InvalidArchitectureException(Architecture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -223,7 +220,7 @@ namespace Flax.Build.Platforms
|
|||||||
case TargetArchitecture.x64:
|
case TargetArchitecture.x64:
|
||||||
SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib", "x64"));
|
SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib", "x64"));
|
||||||
break;
|
break;
|
||||||
default: throw new InvalidArchitectureException(architecture);
|
default: throw new InvalidArchitectureException(Architecture);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -274,7 +271,7 @@ namespace Flax.Build.Platforms
|
|||||||
_makepriPath = Path.Combine(binRootDir, "makepri.exe");
|
_makepriPath = Path.Combine(binRootDir, "makepri.exe");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: throw new InvalidArchitectureException(architecture);
|
default: throw new InvalidArchitectureException(Architecture);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -312,13 +309,16 @@ namespace Flax.Build.Platforms
|
|||||||
{
|
{
|
||||||
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "arm64"));
|
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "arm64"));
|
||||||
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "arm64"));
|
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "arm64"));
|
||||||
|
var binRootDir = Path.Combine(windowsSdkDir, "bin", sdkVersionName, hostArchitecture.ToString().ToLower());
|
||||||
|
_resourceCompilerPath = Path.Combine(binRootDir, "rc.exe");
|
||||||
|
_makepriPath = Path.Combine(binRootDir, "makepri.exe");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TargetArchitecture.x86:
|
case TargetArchitecture.x86:
|
||||||
{
|
{
|
||||||
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x86"));
|
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x86"));
|
||||||
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "x86"));
|
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "x86"));
|
||||||
var binRootDir = Path.Combine(windowsSdkDir, "bin", sdkVersionName, "x86");
|
var binRootDir = Path.Combine(windowsSdkDir, "bin", sdkVersionName, hostArchitecture.ToString().ToLower());
|
||||||
_resourceCompilerPath = Path.Combine(binRootDir, "rc.exe");
|
_resourceCompilerPath = Path.Combine(binRootDir, "rc.exe");
|
||||||
_makepriPath = Path.Combine(binRootDir, "makepri.exe");
|
_makepriPath = Path.Combine(binRootDir, "makepri.exe");
|
||||||
break;
|
break;
|
||||||
@@ -327,12 +327,12 @@ namespace Flax.Build.Platforms
|
|||||||
{
|
{
|
||||||
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x64"));
|
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x64"));
|
||||||
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "x64"));
|
SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "x64"));
|
||||||
var binRootDir = Path.Combine(windowsSdkDir, "bin", sdkVersionName, "x64");
|
var binRootDir = Path.Combine(windowsSdkDir, "bin", sdkVersionName, hostArchitecture.ToString().ToLower());
|
||||||
_resourceCompilerPath = Path.Combine(binRootDir, "rc.exe");
|
_resourceCompilerPath = Path.Combine(binRootDir, "rc.exe");
|
||||||
_makepriPath = Path.Combine(binRootDir, "makepri.exe");
|
_makepriPath = Path.Combine(binRootDir, "makepri.exe");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: throw new InvalidArchitectureException(architecture);
|
default: throw new InvalidArchitectureException(Architecture);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user