Add TargetCompiler to Flax.Build toolchains

This commit is contained in:
Wojtek Figat
2023-01-09 17:59:11 +01:00
parent 0595f38fe4
commit 17f9219cd0
4 changed files with 29 additions and 2 deletions

View File

@@ -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};");

View File

@@ -6,6 +6,22 @@ using Flax.Build.NativeCpp;
namespace Flax.Build
{
/// <summary>
/// The target platform compiler types.
/// </summary>
public enum TargetCompiler
{
/// <summary>
/// Microsoft C++ (MSVC) C and C++ compiler and linker.
/// </summary>
MSVC,
/// <summary>
/// LLVM-based open source compiler.
/// </summary>
Clang,
}
/// <summary>
/// The base class for all build toolchains.
/// </summary>
@@ -51,6 +67,11 @@ namespace Flax.Build
/// </summary>
public abstract string DllImport { get; }
/// <summary>
/// Gets the compiler type.
/// </summary>
public abstract TargetCompiler Compiler { get; }
/// <summary>
/// Initializes a new instance of the <see cref="Toolchain"/> class.
/// </summary>

View File

@@ -220,6 +220,9 @@ namespace Flax.Build.Platforms
/// <inheritdoc />
public override string DllImport => "";
/// <inheritdoc />
public override TargetCompiler Compiler => TargetCompiler.Clang;
/// <inheritdoc />
public override void LogInfo()
{

View File

@@ -344,6 +344,9 @@ namespace Flax.Build.Platforms
/// <inheritdoc />
public override string DllImport => "__declspec(dllimport)";
/// <inheritdoc />
public override TargetCompiler Compiler => TargetCompiler.MSVC;
/// <inheritdoc />
public override void LogInfo()
{