Exemplo n.º 1
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));
				}
			}
		}
Exemplo n.º 2
0
 internal static void RunManagedProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser)
 {
     using (ManagedProgram program = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.0", exe, args))
     {
         program.GetProcessStartInfo().WorkingDirectory = workingDirectory;
         program.Start();
         program.WaitForExit();
         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));
         }
     }
 }
Exemplo n.º 3
0
        private static int RunUpdatingProgram(string executable, string arguments, out string stdOut, out string stdErr)
        {
            ManagedProgram managedProgram = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.0", EditorApplication.applicationContentsPath + "/Tools/ScriptUpdater/" + executable, arguments);

            managedProgram.LogProcessStartInfo();
            managedProgram.Start();
            managedProgram.WaitForExit();
            stdOut = managedProgram.GetStandardOutputAsString();
            stdErr = string.Join("\r\n", managedProgram.GetErrorOutput());
            return(managedProgram.ExitCode);
        }
Exemplo n.º 4
0
 protected ManagedProgram StartCompiler(BuildTarget target, string compiler, List<string> arguments, bool setMonoEnvironmentVariables)
 {
     base.AddCustomResponseFileIfPresent(arguments, Path.GetFileNameWithoutExtension(compiler) + ".rsp");
     string responseFile = CommandLineFormatter.GenerateResponseFile(arguments);
     if (this.runUpdater)
     {
         UnityEditor.Scripting.Compilers.APIUpdaterHelper.UpdateScripts(responseFile, this._island.GetExtensionOfSourceFiles());
     }
     ManagedProgram program = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation(), this._island._classlib_profile, compiler, " @" + responseFile, setMonoEnvironmentVariables);
     program.Start();
     return program;
 }
Exemplo n.º 5
0
        public ManagedProgram(string monodistribution, string profile, string executable, string arguments, bool setMonoEnvironmentVariables, Action <ProcessStartInfo> setupStartInfo)
        {
            string text = ManagedProgram.PathCombine(new string[]
            {
                monodistribution,
                "bin",
                "mono"
            });
            string value = ManagedProgram.PathCombine(new string[]
            {
                monodistribution,
                "lib",
                "mono",
                profile
            });

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                text = CommandLineFormatter.PrepareFileName(text + ".exe");
            }
            ProcessStartInfo processStartInfo = new ProcessStartInfo
            {
                Arguments              = CommandLineFormatter.PrepareFileName(executable) + " " + arguments,
                CreateNoWindow         = true,
                FileName               = text,
                RedirectStandardError  = true,
                RedirectStandardOutput = true,
                WorkingDirectory       = Application.dataPath + "/..",
                UseShellExecute        = false
            };

            if (setMonoEnvironmentVariables)
            {
                processStartInfo.EnvironmentVariables["MONO_PATH"]    = value;
                processStartInfo.EnvironmentVariables["MONO_CFG_DIR"] = ManagedProgram.PathCombine(new string[]
                {
                    monodistribution,
                    "etc"
                });
            }
            if (setupStartInfo != null)
            {
                setupStartInfo(processStartInfo);
            }
            this._process.StartInfo = processStartInfo;
        }
Exemplo n.º 6
0
 internal static void RunManagedProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser, Action<ProcessStartInfo> setupStartInfo)
 {
     Program program;
     Stopwatch stopwatch = new Stopwatch();
     stopwatch.Start();
     if (Application.platform == RuntimePlatform.WindowsEditor)
     {
         ProcessStartInfo info = new ProcessStartInfo {
             Arguments = args,
             CreateNoWindow = true,
             FileName = exe
         };
         if (setupStartInfo != null)
         {
             setupStartInfo(info);
         }
         program = new Program(info);
     }
     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 message in enumerable)
                 {
                     Debug.LogPlayerBuildError(message.message, message.file, message.line, message.column);
                 }
             }
             Debug.LogError("Failed running " + exe + " " + args + "\n\n" + program.GetAllOutput());
             throw new Exception(string.Format("{0} did not run properly!", exe));
         }
     }
 }
Exemplo n.º 7
0
 private static void RunUpdatingProgram(string executable, string arguments)
 {
     string str = EditorApplication.applicationContentsPath + "/Tools/ScriptUpdater/" + executable;
     ManagedProgram program = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.5", str, arguments);
     program.LogProcessStartInfo();
     program.Start();
     program.WaitForExit();
     Console.WriteLine(string.Join(Environment.NewLine, program.GetStandardOutput()));
     if (program.ExitCode == 0)
     {
         UpdateFilesInVCIfNeeded();
     }
     else
     {
         ReportAPIUpdaterFailure(program.GetErrorOutput());
     }
 }
Exemplo n.º 8
0
 private static void HandleUpdaterReturnValue(ManagedProgram program)
 {
     if (program.ExitCode == 0)
     {
         Console.WriteLine(string.Join(Environment.NewLine, program.GetErrorOutput()));
         UpdateFilesInVCIfNeeded();
     }
     else
     {
         ScriptUpdatingManager.ReportExpectedUpdateFailure();
         if (program.ExitCode > 0)
         {
             ReportAPIUpdaterFailure(program.GetErrorOutput());
         }
         else
         {
             ReportAPIUpdaterCrash(program.GetErrorOutput());
         }
     }
 }
Exemplo n.º 9
0
        public ManagedProgram(string monodistribution, string profile, string executable, string arguments, bool setMonoEnvironmentVariables)
        {
            string str1 = ManagedProgram.PathCombine(monodistribution, "bin", "mono");
            string str2 = ManagedProgram.PathCombine(monodistribution, "lib", "mono", profile);

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                str1 = CommandLineFormatter.PrepareFileName(str1 + ".exe");
            }
            ProcessStartInfo processStartInfo = new ProcessStartInfo()
            {
                Arguments = CommandLineFormatter.PrepareFileName(executable) + " " + arguments, CreateNoWindow = true, FileName = str1, RedirectStandardError = true, RedirectStandardOutput = true, WorkingDirectory = Application.dataPath + "/..", UseShellExecute = false
            };

            if (setMonoEnvironmentVariables)
            {
                processStartInfo.EnvironmentVariables["MONO_PATH"]    = str2;
                processStartInfo.EnvironmentVariables["MONO_CFG_DIR"] = ManagedProgram.PathCombine(monodistribution, "etc");
            }
            this._process.StartInfo = processStartInfo;
        }
 private static int RunUpdatingProgram(string executable, string arguments, out string stdOut, out string stdErr)
 {
   ManagedProgram managedProgram = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.0", EditorApplication.applicationContentsPath + "/Tools/ScriptUpdater/" + executable, arguments);
   managedProgram.LogProcessStartInfo();
   managedProgram.Start();
   managedProgram.WaitForExit();
   stdOut = managedProgram.GetStandardOutputAsString();
   stdErr = string.Join("\r\n", managedProgram.GetErrorOutput());
   return managedProgram.ExitCode;
 }