Skip setup of ARM64 configuration for Windows with no compiler support

This commit is contained in:
2024-05-15 21:48:22 +03:00
parent ba397836a6
commit b0904fef69
5 changed files with 66 additions and 43 deletions

View File

@@ -125,9 +125,7 @@ namespace Flax.Build
continue;
if (!platform.HasRequiredSDKsInstalled && (!projectInfo.IsCSharpOnlyProject || platform != Platform.BuildPlatform))
continue;
// Prevent generating configuration data for Windows x86
if (architecture == TargetArchitecture.x86 && targetPlatform == TargetPlatform.Windows)
if (!platform.CanBuildArchitecture(architecture))
continue;
string configurationText = targetName + '.' + platformName + '.' + configurationName;

View File

@@ -188,6 +188,16 @@ namespace Flax.Build
return false;
}
/// <summary>
/// Determines whether this platform can compile or cross-compile for the specified architecture.
/// </summary>
/// <param name="targetArchitecture">The architecture.</param>
/// <returns><c>true</c> if this platform can build the specified architecture; otherwise, <c>false</c>.</returns>
public virtual bool CanBuildArchitecture(TargetArchitecture targetArchitecture)
{
return IsPlatformSupported(Target, targetArchitecture);
}
/// <summary>
/// Gets the path to the output file for the linker.
/// </summary>

View File

@@ -70,6 +70,24 @@ namespace Flax.Build.Platforms
}
}
/// <inheritdoc />
public override bool CanBuildArchitecture(TargetArchitecture targetArchitecture)
{
// Prevent generating configuration data for Windows x86 (deprecated)
if (targetArchitecture == TargetArchitecture.x86)
return false;
// Check if we have a compiler for this architecture
var toolsets = GetToolsets();
foreach (var toolset in toolsets)
{
if (GetVCToolPath(toolset.Key, BuildTargetArchitecture, targetArchitecture) != null)
return true;
}
return false;
}
/// <inheritdoc />
void IVisualStudioProjectCustomizer.WriteVisualStudioBegin(VisualStudioProject project, Platform platform, StringBuilder vcProjectFileContent, StringBuilder vcFiltersFileContent, StringBuilder vcUserFileContent)
{

View File

@@ -424,53 +424,48 @@ namespace Flax.Build.Platforms
switch (toolset)
{
case WindowsPlatformToolset.v140:
case WindowsPlatformToolset.v140:
{
if (hostArchitecture != TargetArchitecture.x86)
{
if (hostArchitecture != TargetArchitecture.x86)
{
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 {0} host compiler toolchain found in {1} or {2}", hostArchitecture.ToString(), nativeCompilerPath, crossCompilerPath));
}
else
{
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:
{
string hostFolder = hostArchitecture == TargetArchitecture.x86 ? "HostX86" : $"Host{hostArchitecture.ToString().ToLower()}";
string nativeCompilerPath = Path.Combine(vcToolChainDir, "bin", hostFolder, architecture.ToString().ToLower(), "cl.exe");
string nativeCompilerPath = Path.Combine(vcToolChainDir, "bin", "amd64", "cl.exe");
if (File.Exists(nativeCompilerPath))
{
return Path.GetDirectoryName(nativeCompilerPath);
}
string crossCompilerPath = Path.Combine(vcToolChainDir, "bin", hostFolder, architecture.ToString().ToLower(), "cl.exe");
string crossCompilerPath = Path.Combine(vcToolChainDir, "bin", "x86_amd64", "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));
Log.Verbose(string.Format("No {0} host compiler toolchain found in {1} or {2}", hostArchitecture.ToString(), nativeCompilerPath, crossCompilerPath));
return null;
}
default: throw new ArgumentOutOfRangeException(nameof(toolset), toolset, null);
else
{
string compilerPath = Path.Combine(vcToolChainDir, "bin", "cl.exe");
if (File.Exists(compilerPath))
return Path.GetDirectoryName(compilerPath);
Log.Verbose(string.Format("No {0} host compiler toolchain found in {1}", hostArchitecture.ToString()));
return null;
}
}
case WindowsPlatformToolset.v141:
case WindowsPlatformToolset.v142:
case WindowsPlatformToolset.v143:
case WindowsPlatformToolset.v144:
{
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);
Log.Verbose(string.Format("No {0} host compiler toolchain found in {1} or {2}", hostArchitecture.ToString(), nativeCompilerPath, crossCompilerPath));
return null;
}
default: throw new ArgumentOutOfRangeException(nameof(toolset), toolset, null);
}
}

View File

@@ -136,6 +136,8 @@ namespace Flax.Build.Platforms
// Get the tools paths
var hostArchitecture = Platform.BuildTargetArchitecture;
_vcToolPath = WindowsPlatformBase.GetVCToolPath(Toolset, hostArchitecture, Architecture);
if (string.IsNullOrEmpty(_vcToolPath))
throw new Exception(string.Format("No {0} host compiler tools found for target architecture {1}", hostArchitecture, Architecture));
_compilerPath = Path.Combine(_vcToolPath, "cl.exe");
_linkerPath = Path.Combine(_vcToolPath, "link.exe");
_libToolPath = Path.Combine(_vcToolPath, "lib.exe");