diff --git a/Source/Tools/Flax.Build/Build/Builder.Projects.cs b/Source/Tools/Flax.Build/Build/Builder.Projects.cs
index c928861eb..819ee74c3 100644
--- a/Source/Tools/Flax.Build/Build/Builder.Projects.cs
+++ b/Source/Tools/Flax.Build/Build/Builder.Projects.cs
@@ -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;
diff --git a/Source/Tools/Flax.Build/Build/Platform.cs b/Source/Tools/Flax.Build/Build/Platform.cs
index 526dd2c54..21002f26a 100644
--- a/Source/Tools/Flax.Build/Build/Platform.cs
+++ b/Source/Tools/Flax.Build/Build/Platform.cs
@@ -188,6 +188,16 @@ namespace Flax.Build
return false;
}
+ ///
+ /// Determines whether this platform can compile or cross-compile for the specified architecture.
+ ///
+ /// The architecture.
+ /// true if this platform can build the specified architecture; otherwise, false.
+ public virtual bool CanBuildArchitecture(TargetArchitecture targetArchitecture)
+ {
+ return IsPlatformSupported(Target, targetArchitecture);
+ }
+
///
/// Gets the path to the output file for the linker.
///
diff --git a/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatform.cs b/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatform.cs
index 8fd361700..924d29f86 100644
--- a/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatform.cs
+++ b/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatform.cs
@@ -70,6 +70,24 @@ namespace Flax.Build.Platforms
}
}
+ ///
+ 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;
+ }
+
///
void IVisualStudioProjectCustomizer.WriteVisualStudioBegin(VisualStudioProject project, Platform platform, StringBuilder vcProjectFileContent, StringBuilder vcFiltersFileContent, StringBuilder vcUserFileContent)
{
diff --git a/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatformBase.cs b/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatformBase.cs
index d2b490704..1f58d7b45 100644
--- a/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatformBase.cs
+++ b/Source/Tools/Flax.Build/Platforms/Windows/WindowsPlatformBase.cs
@@ -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);
}
}
diff --git a/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs b/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs
index 6df1c38eb..58a3c030f 100644
--- a/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs
+++ b/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs
@@ -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");