forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptCompilerBase.cs
More file actions
157 lines (138 loc) · 3.65 KB
/
Copy pathScriptCompilerBase.cs
File metadata and controls
157 lines (138 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor.Utils;
using UnityEngine;
namespace UnityEditor.Scripting.Compilers
{
internal abstract class ScriptCompilerBase : IDisposable
{
private Program process;
private string _responseFile = null;
protected MonoIsland _island;
protected ScriptCompilerBase(MonoIsland island)
{
this._island = island;
}
protected abstract Program StartCompiler();
protected abstract CompilerOutputParserBase CreateOutputParser();
protected string[] GetErrorOutput()
{
return this.process.GetErrorOutput();
}
protected string[] GetStandardOutput()
{
return this.process.GetStandardOutput();
}
protected bool CompilingForWSA()
{
return this._island._target == BuildTarget.WSAPlayer;
}
public void BeginCompiling()
{
if (this.process != null)
{
throw new InvalidOperationException("Compilation has already begun!");
}
this.process = this.StartCompiler();
}
public virtual void Dispose()
{
if (this.process != null)
{
this.process.Dispose();
this.process = null;
}
if (this._responseFile != null)
{
File.Delete(this._responseFile);
this._responseFile = null;
}
}
public virtual bool Poll()
{
return this.process == null || this.process.HasExited;
}
protected bool AddCustomResponseFileIfPresent(List<string> arguments, string responseFileName)
{
string text = Path.Combine("Assets", responseFileName);
bool result;
if (!File.Exists(text))
{
result = false;
}
else
{
arguments.Add("@" + text);
result = true;
}
return result;
}
protected string GenerateResponseFile(List<string> arguments)
{
this._responseFile = CommandLineFormatter.GenerateResponseFile(arguments);
return this._responseFile;
}
protected static string PrepareFileName(string fileName)
{
return CommandLineFormatter.PrepareFileName(fileName);
}
public virtual CompilerMessage[] GetCompilerMessages()
{
if (!this.Poll())
{
Debug.LogWarning("Compile process is not finished yet. This should not happen.");
}
this.DumpStreamOutputToLog();
return this.CreateOutputParser().Parse(this.GetStreamContainingCompilerMessages(), this.CompilationHadFailure()).ToArray<CompilerMessage>();
}
protected bool CompilationHadFailure()
{
return this.process.ExitCode != 0;
}
protected virtual string[] GetStreamContainingCompilerMessages()
{
List<string> list = new List<string>();
list.AddRange(this.GetErrorOutput());
list.Add(string.Empty);
list.AddRange(this.GetStandardOutput());
return list.ToArray();
}
private void DumpStreamOutputToLog()
{
bool flag = this.CompilationHadFailure();
string[] errorOutput = this.GetErrorOutput();
if (flag || errorOutput.Length != 0)
{
Console.WriteLine("");
Console.WriteLine("-----Compiler Commandline Arguments:");
this.process.LogProcessStartInfo();
string[] standardOutput = this.GetStandardOutput();
Console.WriteLine(string.Concat(new object[]
{
"-----CompilerOutput:-stdout--exitcode: ",
this.process.ExitCode,
"--compilationhadfailure: ",
flag,
"--outfile: ",
this._island._output
}));
string[] array = standardOutput;
for (int i = 0; i < array.Length; i++)
{
string value = array[i];
Console.WriteLine(value);
}
Console.WriteLine("-----CompilerOutput:-stderr----------");
string[] array2 = errorOutput;
for (int j = 0; j < array2.Length; j++)
{
string value2 = array2[j];
Console.WriteLine(value2);
}
Console.WriteLine("-----EndCompilerOutput---------------");
}
}
}
}