diff --git a/Source/Tools/Flax.Build/Platforms/Android/AndroidToolchain.cs b/Source/Tools/Flax.Build/Platforms/Android/AndroidToolchain.cs
index 9fa1020f9..ed728e9d6 100644
--- a/Source/Tools/Flax.Build/Platforms/Android/AndroidToolchain.cs
+++ b/Source/Tools/Flax.Build/Platforms/Android/AndroidToolchain.cs
@@ -33,7 +33,7 @@ namespace Flax.Build.Platforms
/// The target architecture.
/// The toolchain root path.
public AndroidToolchain(AndroidPlatform platform, TargetArchitecture architecture, string toolchainRoot)
- : base(platform, architecture, toolchainRoot, false, string.Empty)
+ : base(platform, architecture, toolchainRoot, null, string.Empty)
{
var toolchain = ToolsetRoot.Replace('\\', '/');
SystemIncludePaths.Add(Path.Combine(toolchain, "sources/usr/include/c++/v1").Replace('\\', '/'));
diff --git a/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs b/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs
index f17e6768e..4455b926e 100644
--- a/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs
+++ b/Source/Tools/Flax.Build/Platforms/Linux/LinuxPlatform.cs
@@ -27,23 +27,40 @@ namespace Flax.Build.Platforms
public readonly string ToolchainRoot;
///
- /// True if use platform native system compiler instead of external package.
+ /// The compiler name.
///
- public readonly bool UseSystemCompiler;
+ public readonly string Compiler;
///
/// Initializes a new instance of the class.
///
public LinuxPlatform()
{
- // Check if use system compiler
- if (Environment.OSVersion.Platform == PlatformID.Unix && Which("clang++-7") != null)
+ // Try to use system compiler
+ if (Environment.OSVersion.Platform == PlatformID.Unix)
{
- // Build toolchain root path
+ // Pick the newest compiler (overriden by specified in command line)
+ if (Which(Compiler) != null)
+ Compiler = Configuration.Compiler;
+ else if (Which("clang++-10") != null)
+ Compiler = "clang++-10";
+ else if (Which("clang++-9") != null)
+ Compiler = "clang++-9";
+ else if (Which("clang++-8") != null)
+ Compiler = "clang++-8";
+ else if (Which("clang++-7") != null)
+ Compiler = "clang++-7";
+ else if (Which("clang++-6") != null)
+ Compiler = "clang++-6";
+ else if (Which("clang++") != null)
+ Compiler = "clang++";
+ }
+ if (Compiler != null)
+ {
+ // System compiler
ToolchainRoot = string.Empty;
- Log.Verbose("Using native Linux toolchain (system compiler)");
+ Log.Verbose($"Using native Linux toolchain (compiler {Compiler})");
HasRequiredSDKsInstalled = true;
- UseSystemCompiler = true;
}
else
{
@@ -60,11 +77,10 @@ namespace Flax.Build.Platforms
return;
}
- // Build toolchain root path
+ // Installed toolchain
ToolchainRoot = Path.Combine(toolchainsRoot, toolchainName).Replace('\\', '/');
Log.Verbose(string.Format("Found Linux Toolchain at {0}", ToolchainRoot));
HasRequiredSDKsInstalled = true;
- UseSystemCompiler = false;
}
}
diff --git a/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs b/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs
index 23a3a20ed..da3a01155 100644
--- a/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs
+++ b/Source/Tools/Flax.Build/Platforms/Linux/LinuxToolchain.cs
@@ -20,12 +20,12 @@ namespace Flax.Build.Platforms
/// The platform.
/// The target architecture.
public LinuxToolchain(LinuxPlatform platform, TargetArchitecture architecture)
- : base(platform, architecture, platform.ToolchainRoot, platform.UseSystemCompiler)
+ : base(platform, architecture, platform.ToolchainRoot, platform.Compiler)
{
// Setup system paths
SystemIncludePaths.Add(Path.Combine(ToolsetRoot, "usr", "include"));
SystemIncludePaths.Add(Path.Combine(ToolsetRoot, "include", "c++", "5.2.0"));
- SystemIncludePaths.Add(Path.Combine(ToolsetRoot, "lib", "clang", "7.0.1", "include"));
+ SystemIncludePaths.Add(Path.Combine(ToolsetRoot, "lib", "clang", ClangVersion.Major.ToString(), "include"));
}
///
diff --git a/Source/Tools/Flax.Build/Platforms/Unix/UnixPlatform.cs b/Source/Tools/Flax.Build/Platforms/Unix/UnixPlatform.cs
index b3e405859..1b4ee0d99 100644
--- a/Source/Tools/Flax.Build/Platforms/Unix/UnixPlatform.cs
+++ b/Source/Tools/Flax.Build/Platforms/Unix/UnixPlatform.cs
@@ -46,6 +46,9 @@ namespace Flax.Build.Platforms
/// The full path or null if not found anything valid.
public static string Which(string name)
{
+ if (string.IsNullOrEmpty(name))
+ return null;
+
Process proc = new Process
{
StartInfo =
diff --git a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs
index e9ab83ffa..e66af3ece 100644
--- a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs
+++ b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs
@@ -72,18 +72,18 @@ namespace Flax.Build.Platforms
/// The platform.
/// The target architecture.
/// The root folder for the toolchains installation.
- /// True if use system compiler instead of toolchain.
+ /// The system compiler to use. Null if use toolset root.
/// The custom toolchain folder location in directory. If nul the architecture name will be sued.
- protected UnixToolchain(UnixPlatform platform, TargetArchitecture architecture, string toolchainRoots, bool useSystemCompiler, string toolchainSubDir = null)
+ protected UnixToolchain(UnixPlatform platform, TargetArchitecture architecture, string toolchainRoots, string systemCompiler, string toolchainSubDir = null)
: base(platform, architecture)
{
ArchitectureName = GetToolchainName(platform.Target, architecture);
// Build paths
- if (useSystemCompiler)
+ if (systemCompiler != null)
{
ToolsetRoot = toolchainRoots;
- ClangPath = UnixPlatform.Which("clang++-7");
+ ClangPath = UnixPlatform.Which(systemCompiler);
ArPath = UnixPlatform.Which("ar");
LlvmArPath = UnixPlatform.Which("llvm-ar");
RanlibPath = UnixPlatform.Which("ranlib");