From a3a43ba2b6983d2e489909f438304b36f29c9f7f Mon Sep 17 00:00:00 2001 From: JLIOSM1 <774727341@qq.com> Date: Sat, 21 Aug 2021 18:51:32 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=83=AD=E6=9B=B4=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E3=80=91=E4=BC=98=E5=8C=96IOS=E6=9B=B4=E6=96=B0=E5=8D=A1?= =?UTF-8?q?=E6=AD=BB=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GameEditor/FrameTool/HotFixWindow.cs | 23 +++++--- Assets/Scripts/Editor/Util/ProcessUtil.cs | 54 ++++++++++--------- 2 files changed, 46 insertions(+), 31 deletions(-) diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs b/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs index eaf35dde00..67e41b70c8 100644 --- a/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs +++ b/Assets/Scripts/Editor/GameEditor/FrameTool/HotFixWindow.cs @@ -330,15 +330,21 @@ namespace GameEditor.FrameTool log.Add("CDN TYPE: " + cdnType); string toolsDir = HotfixWindow._HotFixProjectPath + "/Tools/" + cdnType; log.Add("TOOLS DIR: " + toolsDir); - string command = string.Format("python UpLoad.py {0} {1} {2}>>{3}", HotfixWindow._HotFixProjectPath + "/Root/" + dir_name, dir_cdn_setting, changeFileName, logPath + logName + ".log"); + // MAC机器上pathon脚本中使用多线程会导致unity卡死 + int isThread = 1; +#if UNITY_IOS + isThread = 0; +#endif + string command = string.Format("python UpLoad.py {0} {1} {2} {3} >>{4}", HotfixWindow._HotFixProjectPath + "/Root/" + dir_name, dir_cdn_setting, changeFileName, isThread, logPath + logName + ".log"); log.Add("UPLOAD COMMAND: " + command); ProcessUtil.ProcessCommand(toolsDir, command); - string flushCommand = string.Format("python Flush.py {0}>>{1}", cdn_version.resUrl, logPath + logName + ".log"); + string flushCommand = string.Format("python Flush.py {0} >>{1}", cdn_version.resUrl, logPath + logName + ".log"); log.Add("Flush COMMAND: " + flushCommand); ProcessUtil.ProcessCommand(toolsDir, flushCommand); // write log - EditorUtility.DisplayProgressBar("正在生成Log文件:", logName, 1f); - HotFixTool.WriteLog(logPath, logName, log.ToArray()); + string unityLog = changeFileName + "_Unity"; + EditorUtility.DisplayProgressBar("正在生成Log文件:", unityLog, 1f); + HotFixTool.WriteLog(logPath, unityLog, log.ToArray()); // git commit string commitName = desc + "更新:" + updateName; EditorUtility.DisplayProgressBar("正在提交到GIT:", commitName, 1f); @@ -691,10 +697,15 @@ namespace GameEditor.FrameTool log.Add("CDN TYPE: "+ info["cdn_type"]); string toolsDir = _HotFixProjectPath + "/Tools/" + info["cdn_type"]; log.Add("TOOLS DIR: " + toolsDir); - string command = string.Format("python UpLoad.py {0} {1} {2}>>{3}", _HotFixProjectPath + "/Root/" + hfs.dir_name, hfs.dir_cdn_setting, changeFileName, hfs.path_cdn_setting + "__HotFixLog/" + logName + ".log"); + // MAC机器上pathon脚本中使用多线程会导致unity卡死 + int isThread = 1; +#if UNITY_IOS + isThread = 0; +#endif + string command = string.Format("python UpLoad.py {0} {1} {2} {3} >>{4}", _HotFixProjectPath + "/Root/" + hfs.dir_name, hfs.dir_cdn_setting, changeFileName, isThread, hfs.path_cdn_setting + "__HotFixLog/" + logName + ".log"); log.Add("UPLOAD COMMAND: " + command); ProcessUtil.ProcessCommand(toolsDir, command); - string flushCommand = string.Format("python Flush.py {0}>>{1}", hfs.cdn_version.resUrl, hfs.path_cdn_setting + "__HotFixLog/" + logName + ".log"); + string flushCommand = string.Format("python Flush.py {0} >>{1}", hfs.cdn_version.resUrl, hfs.path_cdn_setting + "__HotFixLog/" + logName + ".log"); log.Add("Flush COMMAND: " + flushCommand); ProcessUtil.ProcessCommand(toolsDir, flushCommand); // write log diff --git a/Assets/Scripts/Editor/Util/ProcessUtil.cs b/Assets/Scripts/Editor/Util/ProcessUtil.cs index 27c16c350d..1e52e6711a 100644 --- a/Assets/Scripts/Editor/Util/ProcessUtil.cs +++ b/Assets/Scripts/Editor/Util/ProcessUtil.cs @@ -56,37 +56,41 @@ namespace GameEditor.Util public static void ProcessCommand(string dir, string[] coms, bool isShowWindow = false) { #if UNITY_IOS - string shellPath = Path.Combine(dir, "coms.shell"); + string shellPath = Path.Combine(dir, "coms.sh"); if (!File.Exists(shellPath)) { File.Create(shellPath).Close(); } File.WriteAllLines(shellPath, coms); - System.Diagnostics.Process p = new System.Diagnostics.Process(); - //设置要启动的应用程序 - p.StartInfo.FileName = "/bin/bash"; - //是否使用操作系统shell启动 - p.StartInfo.UseShellExecute = false; - //接受来自调用程序的输入信息 - p.StartInfo.RedirectStandardInput = false; - //输出信息 - p.StartInfo.RedirectStandardOutput = false; - //输出错误 - p.StartInfo.RedirectStandardError = false; - //不显示程序窗口 - p.StartInfo.CreateNoWindow = !isShowWindow; - //设置文件夹 - p.StartInfo.WorkingDirectory = dir; - p.StartInfo.Arguments = shellPath; - //启动程序 - p.Start(); - //等待程序执行完退出进程 - p.WaitForExit(); - //关闭 - p.Close(); - //删除命令行文件 - File.Delete(shellPath); + using(System.Diagnostics.Process p = new System.Diagnostics.Process()) + { + + //设置要启动的应用程序 + p.StartInfo.FileName = "/bin/zsh"; + //是否使用操作系统shell启动 + p.StartInfo.UseShellExecute = false; + //接受来自调用程序的输入信息 + p.StartInfo.RedirectStandardInput = false; + //输出信息 + p.StartInfo.RedirectStandardOutput = false; + //输出错误 + p.StartInfo.RedirectStandardError = false; + //不显示程序窗口 + p.StartInfo.CreateNoWindow = !isShowWindow; + //设置文件夹 + p.StartInfo.WorkingDirectory = dir; + p.StartInfo.Arguments = shellPath; + //启动程序 + p.Start(); + //等待程序执行完退出进程 + p.WaitForExit(); + //关闭 + p.Close(); + //删除命令行文件 + File.Delete(shellPath); + + } #else System.Diagnostics.Process p = new System.Diagnostics.Process(); //设置要启动的应用程序