forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathILPostProcessing.cs
More file actions
100 lines (81 loc) · 3.54 KB
/
Copy pathILPostProcessing.cs
File metadata and controls
100 lines (81 loc) · 3.54 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
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using System.Collections.Generic;
using System.Linq;
using Unity.CompilationPipeline.Common.ILPostProcessing;
using UnityEditorInternal;
namespace UnityEditor.Scripting.ScriptCompilation
{
internal interface IILPostProcessing
{
bool HasPostProcessors { get; }
string[] PostProcessorAssemblyPaths { get; }
string[] AssemblySearchPaths { get; }
}
internal class ILPostProcessing : IILPostProcessing
{
EditorCompilation editorCompilation;
TargetAssembly[] codeGenAssemblies;
string[] postProcessorAssemblyPaths;
string[] assemblySearchPaths;
public ILPostProcessing(EditorCompilation editorCompilation)
{
this.editorCompilation = editorCompilation;
}
TargetAssembly[] CodeGenAssemblies
{
get
{
if (codeGenAssemblies == null)
{
codeGenAssemblies = editorCompilation.CustomTargetAssemblies.Where(e => UnityCodeGenHelpers.IsCodeGen(e.Value.Filename)).Select(e => e.Value).ToArray();
}
return codeGenAssemblies;
}
}
public bool HasPostProcessors
{
get
{
return CodeGenAssemblies != null && CodeGenAssemblies.Length > 0;
}
}
public string[] PostProcessorAssemblyPaths
{
get
{
if (postProcessorAssemblyPaths == null)
{
postProcessorAssemblyPaths = CodeGenAssemblies.Select(a => AssetPath.GetFullPath(a.FullPath(editorCompilation.GetEditorAssembliesOutputDirectory()))).ToArray();
}
return postProcessorAssemblyPaths;
}
}
public string[] AssemblySearchPaths
{
get
{
if (assemblySearchPaths == null)
{
var assemblyReferences = CodeGenAssemblies.SelectMany(a => a.References);
var precompiledReferences = CodeGenAssemblies.SelectMany(a => a.ExplicitPrecompiledReferences);
var assemblyOutputFullPath = AssetPath.GetFullPath(editorCompilation.GetEditorAssembliesOutputDirectory());
var assemblyReferencesPaths = assemblyReferences.Select(a => AssetPath.GetFullPath(a.FullPath(assemblyOutputFullPath)));
var precompiledAssembliesDictionary = editorCompilation.PrecompiledAssemblyProvider.GetPrecompiledAssembliesDictionary(true, BuildTargetGroup.Unknown, BuildTarget.Android);
var precompiledReferencesPaths = precompiledReferences
.Where(x => precompiledAssembliesDictionary.ContainsKey(x))
.Select(x => precompiledAssembliesDictionary[x].Path);
List<string> paths = new List<string>();
paths.Add(InternalEditorUtility.GetEngineCoreModuleAssemblyPath());
paths.Add(InternalEditorUtility.GetEditorAssemblyPath());
paths.Add(assemblyOutputFullPath);
var allPaths = assemblyReferencesPaths.Concat(precompiledReferencesPaths).Concat(paths);
assemblySearchPaths = allPaths.Select(AssetPath.GetDirectoryName).Distinct().ToArray();
}
return assemblySearchPaths;
}
}
}
}