From 7fce25a2e4cf09522ad80e45e276041aada35201 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 6 Mar 2023 16:19:16 +0100 Subject: [PATCH] Fix building consoles --- .../Flax.Build/Build/NativeCpp/IncludesCache.cs | 14 ++++++++------ Source/Tools/Flax.Build/Flax.Build.csproj | 8 ++++++++ .../Tools/Flax.Build/Platforms/Mac/MacToolchain.cs | 2 +- .../Flax.Build/Platforms/Unix/UnixToolchain.cs | 9 ++++++--- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Source/Tools/Flax.Build/Build/NativeCpp/IncludesCache.cs b/Source/Tools/Flax.Build/Build/NativeCpp/IncludesCache.cs index 51872df44..eecd1479f 100644 --- a/Source/Tools/Flax.Build/Build/NativeCpp/IncludesCache.cs +++ b/Source/Tools/Flax.Build/Build/NativeCpp/IncludesCache.cs @@ -13,12 +13,12 @@ namespace Flax.Build.NativeCpp /// public static class IncludesCache { - private static Dictionary DirectIncludesCache = new Dictionary(); - private static Dictionary AllIncludesCache = new Dictionary(); - private static Dictionary DirectIncludesTimestampCache = new Dictionary(); - private static Dictionary AllIncludesTimestampCache = new Dictionary(); - private static Dictionary FileExistsCache = new Dictionary(); - private static Dictionary FileTimestampCache = new Dictionary(); + private static Dictionary DirectIncludesCache = new(); + private static Dictionary AllIncludesCache = new(); + private static Dictionary DirectIncludesTimestampCache = new(); + private static Dictionary AllIncludesTimestampCache = new(); + private static Dictionary FileExistsCache = new(); + private static Dictionary FileTimestampCache = new(); private static readonly string IncludeToken = "include"; private static string CachePath; @@ -231,6 +231,8 @@ namespace Flax.Build.NativeCpp private static string[] GetDirectIncludes(string sourceFile) { + if (!FileExists(sourceFile)) + return Array.Empty(); DateTime? lastModified = null; // Try hit the cache diff --git a/Source/Tools/Flax.Build/Flax.Build.csproj b/Source/Tools/Flax.Build/Flax.Build.csproj index a083363a7..c9d152d27 100644 --- a/Source/Tools/Flax.Build/Flax.Build.csproj +++ b/Source/Tools/Flax.Build/Flax.Build.csproj @@ -12,6 +12,7 @@ false false true + False false false USE_NETCORE @@ -24,6 +25,13 @@ + + + + + + + diff --git a/Source/Tools/Flax.Build/Platforms/Mac/MacToolchain.cs b/Source/Tools/Flax.Build/Platforms/Mac/MacToolchain.cs index 762fc962f..01acd699c 100644 --- a/Source/Tools/Flax.Build/Platforms/Mac/MacToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/Mac/MacToolchain.cs @@ -56,7 +56,7 @@ namespace Flax.Build.Platforms ClangPath = Path.Combine(ToolchainPath, "usr/bin/clang++"); LinkerPath = Path.Combine(ToolchainPath, "usr/bin/clang++"); ArchiverPath = Path.Combine(ToolchainPath, "usr/bin/libtool"); - ClangVersion = GetClangVersion(ClangPath); + ClangVersion = GetClangVersion(platform.Target, ClangPath); SdkPath = Path.Combine(SdkPath, "SDKs"); var sdks = Directory.GetDirectories(SdkPath); var sdkPrefix = "MacOSX"; diff --git a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs index 41fabc840..4a1ca8475 100644 --- a/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/Unix/UnixToolchain.cs @@ -140,7 +140,7 @@ namespace Flax.Build.Platforms } // Determinate compiler version - ClangVersion = GetClangVersion(ClangPath); + ClangVersion = GetClangVersion(platform.Target, ClangPath); LibStdCppVersion = GetLibStdCppVersion(ClangPath) ?? ClangVersion.ToString(); // Check version @@ -156,13 +156,16 @@ namespace Flax.Build.Platforms return libName; } - public static Version GetClangVersion(string path) + public static Version GetClangVersion(TargetPlatform platform, string path) { if (!File.Exists(path)) throw new Exception(string.Format("Missing Clang ({0})", path)); // Parse the version - string output = Utilities.ReadProcessOutput(path, "--version -dumpversion"); + string arg = "--version -dumpversion"; + if (platform == TargetPlatform.PS4) + arg = "--version"; + string output = Utilities.ReadProcessOutput(path, arg); Regex versionPattern = new Regex("\\d+(\\.\\d+)+"); Match versionMatch = versionPattern.Match(output); if (versionMatch.Success)