private static Process StartPosixSocketBridgeProcess()
        {
            var shellArgs = new ShellProcessArguments
            {
                Executable = SocketBridgeExecutable,
                Arguments  = new [] { "6690" },
            };

            var posixSocketBridgeProcess = ShellProcess.Start(shellArgs);

            return(posixSocketBridgeProcess.Process);
        }
示例#2
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 (string.IsNullOrWhiteSpace(args.Data))
                {
                    return;
                }

                var match = BeeProgressRegex.Match(args.Data);

                if (match.Success)
                {
                    var num = match.Groups["nominator"].Value;
                    var den = match.Groups["denominator"].Value;
                    if (int.TryParse(num, out var numInt) && int.TryParse(den, out var denInt))
                    {
                        progressInfo.Progress = (float)numInt / denInt;
                    }
                    progressInfo.Info = ShortenAnnotation(match.Groups["annotation"].Value);
                }

                var busyMatch = BeeBusyRegex.Match(args.Data);

                if (busyMatch.Success)
                {
                    progressInfo.Info = ShortenAnnotation(busyMatch.Groups["annotation"].Value);
                }

                progressInfo.FullInfo = args.Data;
                lock (output)
                {
                    output.AppendLine(args.Data);
                }
            }

            var config = new ShellProcessArguments()
            {
                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 = ShellProcess.Start(config);
            progressInfo.Process = bee;

            yield return(progressInfo);

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

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

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