示例#1
0
    private static bool StartManagedProgram(string exe, string arguments, CompilerOutputParserBase parser, ref IEnumerable <CompilerMessage> compilerMessages)
    {
        using (var p = ManagedProgramFor(exe, arguments))
        {
            p.LogProcessStartInfo();
            try
            {
                p.Start();
            }
            catch
            {
                throw new Exception("Could not start " + exe);
            }

            p.WaitForExit();

            if (p.ExitCode == 0)
            {
                return(true);
            }

            compilerMessages = parser.Parse(p.GetErrorOutput(), p.GetStandardOutput(), true);
        }

        return(false);
    }
            private static void RunManagedProgram(
                string exe,
                string args,
                string workingDirectory,
                CompilerOutputParserBase parser,
                BuildReport report)
            {
                Program p;

                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    ProcessStartInfo si = new ProcessStartInfo()
                    {
                        Arguments      = args,
                        CreateNoWindow = true,
                        FileName       = exe
                    };
                    p = new Program(si);
                }
                else
                {
                    p = (Program) new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), (string)null, exe, args, false, null);
                }

                RunProgram(p, exe, args, workingDirectory, parser, report);
            }
示例#3
0
        private void RunIl2CppWithArguments(List <string> arguments, Action <ProcessStartInfo> setupStartInfo, string workingDirectory)
        {
            var args = arguments.Aggregate(String.Empty, (current, arg) => current + arg + " ");

            var    useNetCore = ShouldUseIl2CppCore();
            string il2CppPath = useNetCore ? GetIl2CppCoreExe() : GetIl2CppExe();

            Console.WriteLine("Invoking il2cpp with arguments: " + args);

            CompilerOutputParserBase il2cppOutputParser = m_PlatformProvider.CreateIl2CppOutputParser();

            if (il2cppOutputParser == null)
            {
                il2cppOutputParser = new Il2CppOutputParser();
            }

            if (useNetCore)
            {
                Runner.RunNetCoreProgram(il2CppPath, args, workingDirectory, il2cppOutputParser, setupStartInfo);
            }
            else
            {
                Runner.RunManagedProgram(il2CppPath, args, workingDirectory, il2cppOutputParser, setupStartInfo);
            }
        }
    private static bool StartManagedProgram(string exe, string arguments, CompilerOutputParserBase parser, ref IEnumerable <CompilerMessage> compilerMessages)
    {
        bool result;

        using (ManagedProgram managedProgram = GendarmeValidationRule.ManagedProgramFor(exe, arguments))
        {
            managedProgram.LogProcessStartInfo();
            try
            {
                managedProgram.Start();
            }
            catch
            {
                throw new Exception("Could not start " + exe);
            }
            managedProgram.WaitForExit();
            if (managedProgram.ExitCode == 0)
            {
                result = true;
                return(result);
            }
            compilerMessages = parser.Parse(managedProgram.GetErrorOutput(), managedProgram.GetStandardOutput(), true);
        }
        result = false;
        return(result);
    }
示例#5
0
        private void RunIl2CppWithArguments(List <string> arguments, Action <ProcessStartInfo> setupStartInfo, string workingDirectory)
        {
            string text = arguments.Aggregate(string.Empty, (string current, string arg) => current + arg + " ");
            bool   flag = this.ShouldUseIl2CppCore();
            string exe  = (!flag) ? this.GetIl2CppExe() : this.GetIl2CppCoreExe();

            Console.WriteLine("Invoking il2cpp with arguments: " + text);
            CompilerOutputParserBase compilerOutputParserBase = this.m_PlatformProvider.CreateIl2CppOutputParser();

            if (compilerOutputParserBase == null)
            {
                compilerOutputParserBase = new Il2CppOutputParser();
            }
            if (flag)
            {
                Runner.RunNetCoreProgram(exe, text, workingDirectory, compilerOutputParserBase, setupStartInfo);
            }
            else
            {
                Runner.RunManagedProgram(exe, text, workingDirectory, compilerOutputParserBase, setupStartInfo);
            }
        }
            private static void RunProgram(
                Program p,
                string exe,
                string args,
                string workingDirectory,
                CompilerOutputParserBase parser,
                BuildReport report)
            {
                Stopwatch stopwatch = new Stopwatch();

                stopwatch.Start();
                using (p)
                {
                    p.GetProcessStartInfo().WorkingDirectory = workingDirectory;
                    p.Start();
                    p.WaitForExit();
                    stopwatch.Stop();

                    Console.WriteLine("{0} exited after {1} ms.", (object)exe, (object)stopwatch.ElapsedMilliseconds);
                    IEnumerable <UnityEditor.Scripting.Compilers.CompilerMessage> compilerMessages = null;
                    string[] errorOutput    = p.GetErrorOutput();
                    string[] standardOutput = p.GetStandardOutput();
                    if (parser != null)
                    {
                        compilerMessages = parser.Parse(errorOutput, standardOutput, true, "n/a (burst)");
                    }

                    var errorMessageBuilder = new StringBuilder();
                    if (p.ExitCode != 0)
                    {
                        if (compilerMessages != null)
                        {
                            foreach (UnityEditor.Scripting.Compilers.CompilerMessage compilerMessage in compilerMessages)
                            {
                                Debug.LogPlayerBuildError(compilerMessage.message, compilerMessage.file, compilerMessage.line, compilerMessage.column);
                            }
                        }

                        // We try to output the version in the heading error if we can
                        var matchVersion = MatchVersion.Match(exe);
                        errorMessageBuilder.Append(matchVersion.Success ?
                                                   "Burst compiler (" + matchVersion.Groups[1].Value + ") failed running" :
                                                   "Burst compiler failed running");
                        errorMessageBuilder.AppendLine();
                        errorMessageBuilder.AppendLine();
                        // Don't output the path if we are not burst-debugging or the exe exist
                        if (BurstLoader.IsDebugging || !File.Exists(exe))
                        {
                            errorMessageBuilder.Append(exe).Append(" ").Append(args);
                            errorMessageBuilder.AppendLine();
                            errorMessageBuilder.AppendLine();
                        }

                        errorMessageBuilder.AppendLine("stdout:");
                        foreach (string str in standardOutput)
                        {
                            errorMessageBuilder.AppendLine(str);
                        }
                        errorMessageBuilder.AppendLine("stderr:");
                        foreach (string str in errorOutput)
                        {
                            errorMessageBuilder.AppendLine(str);
                        }

                        throw new BuildFailedException(errorMessageBuilder.ToString());
                    }
                    Console.WriteLine(p.GetAllOutput());
                }
            }
 public static void RunManagedProgram(string exe, string args, CompilerOutputParserBase parser, BuildReport report)
 {
     RunManagedProgram(exe, args, Application.dataPath + "/..", parser, report);
 }
示例#8
0
            private static void RunProgram(
                Program p,
                string exe,
                string args,
                string workingDirectory,
                CompilerOutputParserBase parser,
                BuildReport report)
            {
                Stopwatch stopwatch = new Stopwatch();

                stopwatch.Start();
                using (p)
                {
                    p.GetProcessStartInfo().WorkingDirectory = workingDirectory;
                    p.Start();
                    p.WaitForExit();
                    stopwatch.Stop();

                    Console.WriteLine("{0} exited after {1} ms.", (object)exe, (object)stopwatch.ElapsedMilliseconds);
                    IEnumerable <UnityEditor.Scripting.Compilers.CompilerMessage> compilerMessages = null;
                    string[] errorOutput    = p.GetErrorOutput();
                    string[] standardOutput = p.GetStandardOutput();
                    if (parser != null)
                    {
                        compilerMessages = parser.Parse(errorOutput, standardOutput, true, "n/a (burst)");
                    }

                    var errorMessageBuilder = new StringBuilder();
                    if (p.ExitCode != 0)
                    {
                        if (compilerMessages != null)
                        {
                            foreach (UnityEditor.Scripting.Compilers.CompilerMessage compilerMessage in compilerMessages)
                            {
                                Debug.LogPlayerBuildError(compilerMessage.message, compilerMessage.file, compilerMessage.line, compilerMessage.column);
                            }
                        }

                        // We try to output the version in the heading error if we can
                        var matchVersion = MatchVersion.Match(exe);
                        errorMessageBuilder.Append(matchVersion.Success ?
                                                   "Burst compiler (" + matchVersion.Groups[1].Value + ") failed running" :
                                                   "Burst compiler failed running");
                        errorMessageBuilder.AppendLine();
                        errorMessageBuilder.AppendLine();
                        // Don't output the path if we are not burst-debugging or the exe exist
                        if (BurstLoader.IsDebugging || !File.Exists(exe))
                        {
                            errorMessageBuilder.Append(exe).Append(" ").Append(args);
                            errorMessageBuilder.AppendLine();
                            errorMessageBuilder.AppendLine();
                        }

                        errorMessageBuilder.AppendLine("stdout:");
                        foreach (string str in standardOutput)
                        {
                            errorMessageBuilder.AppendLine(str);
                        }
                        errorMessageBuilder.AppendLine("stderr:");
                        foreach (string str in errorOutput)
                        {
                            errorMessageBuilder.AppendLine(str);
                        }

                        // We don't use Debug.LogError as it displays a stacktrace that we really don't want to pollute our message output
                        //report.AddMessage(LogType.Error, errorMessageBuilder.ToString());
                        Debug.LogPlayerBuildError(errorMessageBuilder.ToString(), "unknown", 0, 0);

                        // We report the error to the build player but it seems that it is not correctly reported.
                        // In Editor\Src\BuildPipeline\BuildPlayer.cpp
                        //    if (report.GetSuccess())
                        //    {
                        //        DisplayProgressNotification("Build Successful", "");
                        //    }
                        //
                        //    report.UnregisterForLogMessages();
                        //    report.EndBuildStep(buildStepToken);
                        //    report.UpdateSummary();
                        //
                        // Actually report.GetSuccess() should go after the last UpdateSummary()
                        //
                        // We should probably have a method report.SetBuildStatus(error)
                        report.AddMessage(LogType.Error, errorMessageBuilder.ToString());
                    }
                    Console.WriteLine(p.GetAllOutput());
                }
            }
示例#9
0
        internal static void RunManagedProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Program program;

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                program = new Program(new ProcessStartInfo()
                {
                    Arguments      = args,
                    CreateNoWindow = true,
                    FileName       = exe
                });
            }
            else
            {
                program = (Program) new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.0", exe, args);
            }
            using (program)
            {
                program.GetProcessStartInfo().WorkingDirectory = workingDirectory;
                program.Start();
                program.WaitForExit();
                stopwatch.Stop();
                Console.WriteLine("{0} exited after {1} ms.", (object)exe, (object)stopwatch.ElapsedMilliseconds);
                if (program.ExitCode != 0)
                {
                    if (parser != null)
                    {
                        string[] errorOutput    = program.GetErrorOutput();
                        string[] standardOutput = program.GetStandardOutput();
                        foreach (CompilerMessage compilerMessage in parser.Parse(errorOutput, standardOutput, true))
                        {
                            UnityEngine.Debug.LogPlayerBuildError(compilerMessage.message, compilerMessage.file, compilerMessage.line, compilerMessage.column);
                        }
                    }
                    UnityEngine.Debug.LogError((object)("Failed running " + exe + " " + args + "\n\n" + program.GetAllOutput()));
                    throw new Exception(string.Format("{0} did not run properly!", (object)exe));
                }
            }
        }
示例#10
0
        internal static void RunManagedProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser)
        {
            Program   program;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                ProcessStartInfo si = new ProcessStartInfo {
                    Arguments      = args,
                    CreateNoWindow = true,
                    FileName       = exe
                };
                program = new Program(si);
            }
            else
            {
                program = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.0", exe, args);
            }
            using (program)
            {
                program.GetProcessStartInfo().WorkingDirectory = workingDirectory;
                program.Start();
                program.WaitForExit();
                stopwatch.Stop();
                Console.WriteLine("{0} exited after {1} ms.", exe, stopwatch.ElapsedMilliseconds);
                if (program.ExitCode != 0)
                {
                    if (parser != null)
                    {
                        string[] errorOutput    = program.GetErrorOutput();
                        string[] standardOutput = program.GetStandardOutput();
                        IEnumerator <CompilerMessage> enumerator = parser.Parse(errorOutput, standardOutput, true).GetEnumerator();
                        try
                        {
                            while (enumerator.MoveNext())
                            {
                                CompilerMessage current = enumerator.Current;
                                Debug.LogPlayerBuildError(current.message, current.file, current.line, current.column);
                            }
                        }
                        finally
                        {
                            if (enumerator == null)
                            {
                            }
                            enumerator.Dispose();
                        }
                    }
                    Debug.LogError("Failed running " + exe + " " + args + "\n\n" + program.GetAllOutput());
                    throw new Exception(string.Format("{0} did not run properly!", exe));
                }
            }
        }
示例#11
0
        internal static void RunNetCoreProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser, Action <ProcessStartInfo> setupStartInfo)
        {
            var p = new NetCoreProgram(exe, args, setupStartInfo);

            RunProgram(p, exe, args, workingDirectory, parser);
        }
示例#12
0
        internal static void RunManagedProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser, Action <ProcessStartInfo> setupStartInfo)
        {
            Program p;

            // Run on .NET if running on windows
            // It's twice as fast as Mono for IL2CPP.exe
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                var startInfo = new ProcessStartInfo()
                {
                    Arguments      = args,
                    CreateNoWindow = true,
                    FileName       = exe
                };

                if (setupStartInfo != null)
                {
                    setupStartInfo(startInfo);
                }

                p = new Program(startInfo);
            }
            else
            {
                p = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), null, exe, args, false, setupStartInfo);
            }

            RunProgram(p, exe, args, workingDirectory, parser);
        }
示例#13
0
        private static void RunProgram(Program p, string exe, string args, string workingDirectory, CompilerOutputParserBase parser)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            using (p)
            {
                p.GetProcessStartInfo().WorkingDirectory = workingDirectory;
                p.Start();
                p.WaitForExit();

                stopwatch.Stop();
                Console.WriteLine("{0} exited after {1} ms.", exe, stopwatch.ElapsedMilliseconds);

                IEnumerable <CompilerMessage> messages = null;
                if (parser != null)
                {
                    var errorOutput    = p.GetErrorOutput();
                    var standardOutput = p.GetStandardOutput();
                    messages = parser.Parse(errorOutput, standardOutput, true);
                }

                if (p.ExitCode != 0)
                {
                    if (messages != null)
                    {
                        foreach (var message in messages)
                        {
                            Debug.LogPlayerBuildError(message.message, message.file, message.line, message.column);
                        }
                    }

                    Debug.LogError("Failed running " + exe + " " + args + "\n\n" + p.GetAllOutput());

                    throw new Exception(string.Format("{0} did not run properly!", exe));
                }
                else
                {
                    if (messages != null)
                    {
                        foreach (var message in messages)
                        {
                            Console.WriteLine(message.message + " - " + message.file + " - " + message.line + " - " + message.column);
                        }
                    }
                }
            }
        }
示例#14
0
        private static void RunProgram(Program p, string exe, string args, string workingDirectory, CompilerOutputParserBase parser)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            try
            {
                p.GetProcessStartInfo().WorkingDirectory = workingDirectory;
                p.Start();
                p.WaitForExit();
                stopwatch.Stop();
                Console.WriteLine("{0} exited after {1} ms.", exe, stopwatch.ElapsedMilliseconds);
                IEnumerable <CompilerMessage> enumerable = null;
                if (parser != null)
                {
                    string[] errorOutput    = p.GetErrorOutput();
                    string[] standardOutput = p.GetStandardOutput();
                    enumerable = parser.Parse(errorOutput, standardOutput, true);
                }
                if (p.ExitCode != 0)
                {
                    if (enumerable != null)
                    {
                        foreach (CompilerMessage current in enumerable)
                        {
                            UnityEngine.Debug.LogPlayerBuildError(current.message, current.file, current.line, current.column);
                        }
                    }
                    UnityEngine.Debug.LogError(string.Concat(new string[]
                    {
                        "Failed running ",
                        exe,
                        " ",
                        args,
                        "\n\n",
                        p.GetAllOutput()
                    }));
                    throw new Exception(string.Format("{0} did not run properly!", exe));
                }
                if (enumerable != null)
                {
                    foreach (CompilerMessage current2 in enumerable)
                    {
                        Console.WriteLine(string.Concat(new object[]
                        {
                            current2.message,
                            " - ",
                            current2.file,
                            " - ",
                            current2.line,
                            " - ",
                            current2.column
                        }));
                    }
                }
            }
            finally
            {
                if (p != null)
                {
                    ((IDisposable)p).Dispose();
                }
            }
        }
示例#15
0
        internal static void RunNetCoreProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser, Action <ProcessStartInfo> setupStartInfo)
        {
            Program p;

            if (Path.GetExtension(exe).Equals(".dll", StringComparison.OrdinalIgnoreCase))
            {
                p = new NetCoreProgram(exe, args, setupStartInfo);
            }
            else
            {
                var startInfo = new ProcessStartInfo()
                {
                    Arguments      = args,
                    CreateNoWindow = true,
                    FileName       = exe
                };

                if (setupStartInfo != null)
                {
                    setupStartInfo(startInfo);
                }

                p = new Program(startInfo);
            }

            RunProgram(p, exe, args, workingDirectory, parser);
        }
示例#16
0
        private static void RunProgram(Program p, string exe, string args, string workingDirectory, CompilerOutputParserBase parser)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            using (p)
            {
                p.GetProcessStartInfo().WorkingDirectory = workingDirectory;
                p.Start();
                p.WaitForExit();

                stopwatch.Stop();
                UnityLogWriter.WriteStringToUnityLog($"{exe} exited after {stopwatch.ElapsedMilliseconds} ms.\n");

                var messages = new List <CompilerMessage>();
                if (parser != null)
                {
                    var errorOutput    = p.GetErrorOutput();
                    var standardOutput = p.GetStandardOutput();
                    messages.AddRange(parser.Parse(errorOutput, standardOutput, true));
                }

                foreach (var message in NonerrorMessages(messages))
                {
                    Debug.LogWarning(message.message);
                }

                var errorMessages = ErrorMessages(messages).ToArray();
                if (p.ExitCode != 0)
                {
                    if (errorMessages.Any())
                    {
                        // Use the last error as the exception message to cause the build to fail. But
                        // log any other errors that might exist.
                        var lastError = messages.Last();
                        foreach (var message in errorMessages.Take(errorMessages.Length - 1))
                        {
                            Debug.LogPlayerBuildError(message.message, message.file, message.line, message.column);
                        }
                        throw new Exception(lastError.message);
                    }

                    // No messages were parsed, so just put all of the output in the error.
                    throw new Exception("Failed running " + exe + " " + args + "\n\n" + p.GetAllOutput());
                }

                // The exit code was zero, but there are error messages. Don't fail the build by throwing an exception,
                // but log the messages to the editor log.
                foreach (var message in errorMessages)
                {
                    Console.WriteLine(message.message + " - " + message.file + " - " + message.line + " - " + message.column);
                }
            }
        }
示例#17
0
        internal static void RunManagedProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser, Action <ProcessStartInfo> setupStartInfo)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Program program;

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                ProcessStartInfo processStartInfo = new ProcessStartInfo
                {
                    Arguments      = args,
                    CreateNoWindow = true,
                    FileName       = exe
                };
                if (setupStartInfo != null)
                {
                    setupStartInfo(processStartInfo);
                }
                program = new Program(processStartInfo);
            }
            else
            {
                program = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), null, exe, args, false, setupStartInfo);
            }
            using (program)
            {
                program.GetProcessStartInfo().WorkingDirectory = workingDirectory;
                program.Start();
                program.WaitForExit();
                stopwatch.Stop();
                Console.WriteLine("{0} exited after {1} ms.", exe, stopwatch.ElapsedMilliseconds);
                if (program.ExitCode != 0)
                {
                    if (parser != null)
                    {
                        string[] errorOutput    = program.GetErrorOutput();
                        string[] standardOutput = program.GetStandardOutput();
                        IEnumerable <CompilerMessage> enumerable = parser.Parse(errorOutput, standardOutput, true);
                        foreach (CompilerMessage current in enumerable)
                        {
                            UnityEngine.Debug.LogPlayerBuildError(current.message, current.file, current.line, current.column);
                        }
                    }
                    UnityEngine.Debug.LogError(string.Concat(new string[]
                    {
                        "Failed running ",
                        exe,
                        " ",
                        args,
                        "\n\n",
                        program.GetAllOutput()
                    }));
                    throw new Exception(string.Format("{0} did not run properly!", exe));
                }
            }
        }
示例#18
0
 internal static void RunManagedProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser)
 {
     using (ManagedProgram managedProgram = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.0", exe, args))
     {
         managedProgram.GetProcessStartInfo().WorkingDirectory = workingDirectory;
         managedProgram.Start();
         managedProgram.WaitForExit();
         if (managedProgram.ExitCode != 0)
         {
             if (parser != null)
             {
                 string[] errorOutput    = managedProgram.GetErrorOutput();
                 string[] standardOutput = managedProgram.GetStandardOutput();
                 IEnumerable <CompilerMessage> enumerable = parser.Parse(errorOutput, standardOutput, true);
                 foreach (CompilerMessage current in enumerable)
                 {
                     Debug.LogPlayerBuildError(current.message, current.file, current.line, current.column);
                 }
             }
             Debug.LogError(string.Concat(new string[]
             {
                 "Failed running ",
                 exe,
                 " ",
                 args,
                 "\n\n",
                 managedProgram.GetAllOutput()
             }));
             throw new Exception(string.Format("{0} did not run properly!", exe));
         }
     }
 }