From ff7e6d82f8cff320cdbd7afb8049ad0dca89f434 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Wed, 11 Oct 2023 21:42:45 +0300 Subject: [PATCH] Hide exception when build errors occurs in referenced targets --- .../Tools/Flax.Build/Build/NativeCpp/Builder.NativeCpp.cs | 6 ++++++ Source/Tools/Flax.Build/Globals.cs | 5 +++++ Source/Tools/Flax.Build/Program.cs | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/Tools/Flax.Build/Build/NativeCpp/Builder.NativeCpp.cs b/Source/Tools/Flax.Build/Build/NativeCpp/Builder.NativeCpp.cs index 1e8550c4e..4192b0caa 100644 --- a/Source/Tools/Flax.Build/Build/NativeCpp/Builder.NativeCpp.cs +++ b/Source/Tools/Flax.Build/Build/NativeCpp/Builder.NativeCpp.cs @@ -628,7 +628,10 @@ namespace Flax.Build } } if (failed) + { + Globals.BuildErrors = true; throw new Exception($"Failed to build target {target.Name}. See log."); + } } else { @@ -689,7 +692,10 @@ namespace Flax.Build } } if (failed) + { + Globals.BuildErrors = true; throw new Exception($"Failed to build target {target.Name}. See log."); + } } else { diff --git a/Source/Tools/Flax.Build/Globals.cs b/Source/Tools/Flax.Build/Globals.cs index b5f3088d6..994094124 100644 --- a/Source/Tools/Flax.Build/Globals.cs +++ b/Source/Tools/Flax.Build/Globals.cs @@ -22,6 +22,11 @@ namespace Flax.Build /// public static ProjectInfo Project; + /// + /// Set when any build related errors were raised. + /// + public static bool BuildErrors = false; + /// /// All platforms array. /// diff --git a/Source/Tools/Flax.Build/Program.cs b/Source/Tools/Flax.Build/Program.cs index 5e7cf926c..bac1caaa8 100644 --- a/Source/Tools/Flax.Build/Program.cs +++ b/Source/Tools/Flax.Build/Program.cs @@ -171,7 +171,9 @@ namespace Flax.Build } catch (Exception ex) { - Log.Exception(ex); + // Ignore exception logging for build errors + if (!Globals.BuildErrors) + Log.Exception(ex); failed = true; } finally