diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index 4cf911131..1d69efc78 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -245,7 +245,7 @@ namespace Flax.Build.Bindings public static void GenerateCppVirtualWrapperCallBaseMethod(BuildData buildData, StringBuilder contents, VirtualClassInfo classInfo, FunctionInfo functionInfo, string scriptVTableBase, string scriptVTableOffset) { contents.AppendLine(" // Prevent stack overflow by calling native base method"); - if (buildData.Toolchain is Platforms.UnixToolchain) + if (buildData.Toolchain.Compiler == TargetCompiler.Clang) { // Clang compiler // TODO: secure VTableFunctionInjector with mutex (even at cost of performance) @@ -1448,7 +1448,7 @@ namespace Flax.Build.Bindings } var t = functionInfo.IsConst ? " const" : string.Empty; contents.AppendLine($" typedef {functionInfo.ReturnType} ({classInfo.NativeName}::*{functionInfo.UniqueName}_Signature)({thunkParams}){t};"); - if (!(buildData.Toolchain is Platforms.UnixToolchain)) + if (buildData.Toolchain.Compiler != TargetCompiler.Clang) { // MSVC or other compiler contents.AppendLine($" typedef {functionInfo.ReturnType} ({classInfo.NativeName}Internal::*{functionInfo.UniqueName}_Internal_Signature)({thunkParams}){t};"); diff --git a/Source/Tools/Flax.Build/Build/Toolchain.cs b/Source/Tools/Flax.Build/Build/Toolchain.cs index 4ef77fabb..de3e0518c 100644 --- a/Source/Tools/Flax.Build/Build/Toolchain.cs +++ b/Source/Tools/Flax.Build/Build/Toolchain.cs @@ -6,6 +6,22 @@ using Flax.Build.NativeCpp; namespace Flax.Build { + /// + /// The target platform compiler types. + /// + public enum TargetCompiler + { + /// + /// Microsoft C++ (MSVC) C and C++ compiler and linker. + /// + MSVC, + + /// + /// LLVM-based open source compiler. + /// + Clang, + } + /// /// The base class for all build toolchains. /// @@ -51,6 +67,11 @@ namespace Flax.Build /// public abstract string DllImport { get; } + /// + /// Gets the compiler type. + /// + public abstract TargetCompiler Compiler { get; } + /// /// Initializes a new instance of the class. /// diff --git a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs index 5418575c6..ca2d8b966 100644 --- a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs @@ -220,6 +220,9 @@ namespace Flax.Build.Platforms /// public override string DllImport => ""; + /// + public override TargetCompiler Compiler => TargetCompiler.Clang; + /// public override void LogInfo() { diff --git a/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs b/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs index 3919fcafa..50afc88b3 100644 --- a/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs +++ b/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs @@ -344,6 +344,9 @@ namespace Flax.Build.Platforms /// public override string DllImport => "__declspec(dllimport)"; + /// + public override TargetCompiler Compiler => TargetCompiler.MSVC; + /// public override void LogInfo() {