diff --git a/Source/Tools/Flax.Build/Build/Toolchain.cs b/Source/Tools/Flax.Build/Build/Toolchain.cs index 6d90dc850..07bd01a88 100644 --- a/Source/Tools/Flax.Build/Build/Toolchain.cs +++ b/Source/Tools/Flax.Build/Build/Toolchain.cs @@ -73,6 +73,11 @@ namespace Flax.Build /// public abstract TargetCompiler Compiler { get; } + /// + /// Gets the main native files compiler path. + /// + public virtual string NativeCompilerPath { 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 b03dcbb90..88f3abf44 100644 --- a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs @@ -267,6 +267,9 @@ namespace Flax.Build.Platforms /// public override TargetCompiler Compiler => TargetCompiler.Clang; + /// + public override string NativeCompilerPath => ClangPath; + /// 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 91c3b44cd..d51a59836 100644 --- a/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs +++ b/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs @@ -358,6 +358,9 @@ namespace Flax.Build.Platforms /// public override TargetCompiler Compiler => TargetCompiler.MSVC; + /// + public override string NativeCompilerPath => _compilerPath; + /// public override void LogInfo() { diff --git a/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs b/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs index 27092b219..268bb87e1 100644 --- a/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs +++ b/Source/Tools/Flax.Build/Projects/VisualStudioCode/VisualStudioCodeProjectGenerator.cs @@ -542,6 +542,8 @@ namespace Flax.Build.Projects.VisualStudioCode var configuration = TargetConfiguration.Development; var architecture = TargetArchitecture.x64; + var compilerPath = string.Empty; + var cppVersion = NativeCpp.CppVersion.Cpp14; var includePaths = new HashSet(); var preprocessorDefinitions = new HashSet(); foreach (var e in mainProject.Defines) @@ -563,6 +565,8 @@ namespace Flax.Build.Projects.VisualStudioCode module.Key.SetupEnvironment(targetBuildOptions); } + cppVersion = targetBuildOptions.CompileEnv.CppVersion; + compilerPath = toolchain.NativeCompilerPath; foreach (var e in targetBuildOptions.CompileEnv.PreprocessorDefinitions) preprocessorDefinitions.Add(e); foreach (var e in targetBuildOptions.CompileEnv.IncludePaths) @@ -570,6 +574,28 @@ namespace Flax.Build.Projects.VisualStudioCode } } + if (compilerPath.Length != 0) + json.AddField("compilerPath", compilerPath); + + switch (cppVersion) + { + case NativeCpp.CppVersion.Cpp14: + json.AddField("cStandard", "c11"); + json.AddField("cppStandard", "c++14"); + break; + case NativeCpp.CppVersion.Cpp17: + case NativeCpp.CppVersion.Latest: + json.AddField("cStandard", "c17"); + json.AddField("cppStandard", "c++17"); + break; + case NativeCpp.CppVersion.Cpp20: + json.AddField("cStandard", "c17"); + json.AddField("cppStandard", "c++20"); + break; + default: + throw new Exception($"Visual Code project generator does not support C++ standard {cppVersion}."); + } + json.BeginArray("includePath"); { foreach (var path in includePaths)