From e236d4578a6e65524938d7c868977e383d80e403 Mon Sep 17 00:00:00 2001 From: benblo Date: Sat, 14 May 2016 13:59:11 +0200 Subject: [PATCH 1/3] if a -logFile argument is found, use it instead of a temp file --- UnityProxy/Program.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/UnityProxy/Program.cs b/UnityProxy/Program.cs index 6c6db5f..b5e09c4 100644 --- a/UnityProxy/Program.cs +++ b/UnityProxy/Program.cs @@ -16,7 +16,18 @@ static void Main(string[] args) { string unityPath, artifactsPath; int startingArgumentIndex = ParseArguments(args, out unityPath, out artifactsPath); + string logPath = Path.GetTempFileName(); + bool hasLogFileArgument = false; + for (int i = startingArgumentIndex; i < args.Length; i++) + { + if (args[i] == "-logFile") + { + logPath = args[i + 1]; + hasLogFileArgument = true; + break; + } + } Watcher watcher = new Watcher(logPath); Thread watcherThread = new Thread(watcher.Run); @@ -25,7 +36,10 @@ static void Main(string[] args) Process unity = new Process(); unity.StartInfo = new ProcessStartInfo(unityPath); - unity.StartInfo.Arguments = "-logFile \"" + logPath + "\""; + if (!hasLogFileArgument) + { + unity.StartInfo.Arguments = "-logFile \"" + logPath + "\""; + } for (int i = startingArgumentIndex; i < args.Length; i++) { From 2ad20189e88f14a64e1351b06ecc680ad7c83ab6 Mon Sep 17 00:00:00 2001 From: benblo Date: Sat, 14 May 2016 14:22:10 +0200 Subject: [PATCH 2/3] if we not actually building, just route the Unity process exit code instead of looking for the "successful build" magic string --- UnityProxy/Program.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/UnityProxy/Program.cs b/UnityProxy/Program.cs index b5e09c4..57e5e3f 100644 --- a/UnityProxy/Program.cs +++ b/UnityProxy/Program.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics; using System.IO; +using System.Linq; using System.Threading; namespace UnityProxy @@ -61,15 +62,24 @@ static void Main(string[] args) SaveArtifacts(artifactsPath, watcher.FullLog); } - if (watcher.FullLog.Contains(SuccessMagicString)) + bool isBuilding = args.Contains("-executeMethod"); + if (isBuilding) { - Console.WriteLine("Success."); - Environment.Exit(0); + if (watcher.FullLog.Contains(SuccessMagicString)) + { + Console.WriteLine("Success."); + Environment.Exit(0); + } + else + { + Console.WriteLine("Failure."); + Environment.Exit(1); + } } else { - Console.WriteLine("Failure."); - Environment.Exit(1); + // just reimporting, not building + Environment.Exit(unity.ExitCode); } } From 9af0a2b0fc6de1fb7826216c05ac5f00a4759fd7 Mon Sep 17 00:00:00 2001 From: benblo Date: Sat, 14 May 2016 15:44:17 +0200 Subject: [PATCH 3/3] delete previous log file, if any --- UnityProxy/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/UnityProxy/Program.cs b/UnityProxy/Program.cs index 57e5e3f..172abe7 100644 --- a/UnityProxy/Program.cs +++ b/UnityProxy/Program.cs @@ -26,6 +26,10 @@ static void Main(string[] args) { logPath = args[i + 1]; hasLogFileArgument = true; + if (File.Exists(logPath)) + { + File.Delete(logPath); + } break; } }