示例#1
0
        //----- 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);
        }
示例#2
0
        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);
        }
示例#3
0
        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();
        }