//----- params ----- //----- field ----- //----- property ----- //----- method ----- public static bool Generate() { var generateInfo = new MessagePackCodeGenerateInfo(); var csFilePath = generateInfo.CsFilePath; var csFileHash = GetCsFileHash(csFilePath); var processExecute = CreateMpcProcess(generateInfo); var codeGenerateResult = processExecute.Start(); var isSuccess = codeGenerateResult.ExitCode == 0; OutputGenerateLog(isSuccess, csFilePath, processExecute); if (isSuccess) { ImportGeneratedCsFile(csFilePath, csFileHash); } else { using (new DisableStackTraceScope()) { Debug.LogError(codeGenerateResult.Output); } } return(isSuccess); }
private static ProcessExecute CreateMpcProcess(MessagePackCodeGenerateInfo generateInfo) { var messagePackConfig = MessagePackConfig.Instance; var mpc = messagePackConfig.MpcRelativePath; if (string.IsNullOrEmpty(mpc)) { mpc = "mpc"; } var processExecute = new ProcessExecute(mpc, generateInfo.MpcArgument) { Encoding = Encoding.GetEncoding("Shift_JIS"), }; return(processExecute); }
private static IEnumerator GenerateInternalAsync(IObserver <bool> observer) { var generateInfo = new MessagePackCodeGenerateInfo(); var csFilePath = generateInfo.CsFilePath; var csFileHash = GetCsFileHash(csFilePath); var processExecute = CreateMpcProcess(generateInfo); var codeGenerateTask = processExecute.StartAsync(); while (!codeGenerateTask.IsCompleted) { yield return(null); } var isSuccess = codeGenerateTask.Result.ExitCode == 0; OutputGenerateLog(isSuccess, csFilePath, processExecute); if (isSuccess) { ImportGeneratedCsFile(csFilePath, csFileHash); } else { using (new DisableStackTraceScope()) { var message = codeGenerateTask.Result.Error; if (string.IsNullOrEmpty(message)) { message = codeGenerateTask.Result.Output; } Debug.LogError(message); } } observer.OnNext(isSuccess); observer.OnCompleted(); }