Пример #1
0
        public override ShellProcessOutput RunTestMode(string exeName, string workingDirPath, int timeout)
        {
            var shellArgs = new ShellProcessArgs
            {
                Executable = $"{workingDirPath}/{exeName}{ExecutableExtension}",
                Arguments = new string [] {},
                WorkingDirectory = new DirectoryInfo(workingDirPath),
                ThrowOnError = false
            };

            // samples should be killed on timeout
            if (timeout > 0)
            {
                shellArgs.MaxIdleTimeInMilliseconds = timeout;
                shellArgs.MaxIdleKillIsAnError = false;
            }

            return Shell.Run(shellArgs);
        }
Пример #2
0
        public override ShellProcessOutput RunTestMode(string exeName, string workingDirPath, int timeout)
        {
            var shellArgs = new ShellProcessArgs
            {
                Executable = Path.GetFullPath(Path.Combine(UnityEditor.EditorApplication.applicationContentsPath, "MonoBleedingEdge", "bin", "mono")),
                Arguments = new [] { $"\"{workingDirPath}/{exeName}{ExecutableExtension}\"" },
                WorkingDirectory = new DirectoryInfo(workingDirPath),
                ThrowOnError = false
            };

            // samples should be killed on timeout
            if (timeout > 0)
            {
                shellArgs.MaxIdleTimeInMilliseconds = timeout;
                shellArgs.MaxIdleKillIsAnError = false;
            }

            return Shell.Run(shellArgs);
        }
Пример #3
0
        static IEnumerator <BeeProgressInfo> Run(string arguments, StringBuilder command, StringBuilder output, DirectoryInfo workingDirectory = null)
        {
            var beeExe     = Path.GetFullPath($"{Constants.DotsRuntimePackagePath}/bee~/bee.exe");
            var executable = beeExe;

            arguments = "--no-colors " + arguments;

#if !UNITY_EDITOR_WIN
            arguments  = "\"" + executable + "\" " + arguments;
            executable = Path.Combine(UnityEditor.EditorApplication.applicationContentsPath,
                                      "MonoBleedingEdge/bin/mono");
#endif

            command.Append(executable);
            command.Append(" ");
            command.Append(arguments);

            var progressInfo = new BeeProgressInfo()
            {
                Progress = 0.0f,
                Info     = null
            };

            void ProgressHandler(object sender, DataReceivedEventArgs args)
            {
                if (args.Data != null)
                {
                    lock (output)
                    {
                        output.AppendLine(args.Data);
                    }
                }

                var msg = args.Data;

                if (string.IsNullOrWhiteSpace(msg))
                {
                    return;
                }

                progressInfo.FullInfo = msg;

                var match = BeeProgressRegex.Match(msg);

                if (match.Success)
                {
                    var num = match.Groups[1].Value;
                    var den = match.Groups[2].Value;
                    if (int.TryParse(num, out var numInt) && int.TryParse(den, out var denInt))
                    {
                        progressInfo.Progress = (float)numInt / denInt;
                    }
                    progressInfo.Info = match.Groups[3].Value;
                }
                else
                {
                    progressInfo.Progress = float.MinValue;
                    progressInfo.Info     = null;
                }
            }

            var config = new ShellProcessArgs()
            {
                Executable       = executable,
                Arguments        = new[] { arguments },
                WorkingDirectory = workingDirectory,
#if !UNITY_EDITOR_WIN
                // bee requires external programs to perform build actions
                EnvironmentVariables = new Dictionary <string, string>()
                {
                    { "PATH", string.Join(":",
                                          Path.Combine(UnityEditor.EditorApplication.applicationContentsPath,
                                                       "MonoBleedingEdge/bin"),
                                          "/bin",
                                          "/usr/bin",
                                          "/usr/local/bin") }
                },
#else
                EnvironmentVariables = null,
#endif
                OutputDataReceived = ProgressHandler,
                ErrorDataReceived  = ProgressHandler
            };

            var bee = Shell.RunAsync(config);
            progressInfo.Process = bee;

            yield return(progressInfo);

            const int maxBuildTimeInMs = 30 * 60 * 1000; // 30 minutes

            var statusEnum = Shell.WaitForProcess(bee, maxBuildTimeInMs, config.MaxIdleKillIsAnError);
            while (statusEnum.MoveNext())
            {
                yield return(progressInfo);
            }

            progressInfo.Progress = 1.0f;
            progressInfo.IsDone   = true;
            progressInfo.ExitCode = bee.ExitCode;
            progressInfo.Info     = "Build completed";
            yield return(progressInfo);
        }