forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTargetAssembly.cs
More file actions
128 lines (113 loc) · 4.5 KB
/
Copy pathTargetAssembly.cs
File metadata and controls
128 lines (113 loc) · 4.5 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
// 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.Diagnostics;
using System.Linq;
using UnityEditor.Scripting.Compilers;
using UnityEditor.Compilation;
namespace UnityEditor.Scripting.ScriptCompilation
{
[Flags]
internal enum TargetAssemblyType
{
Undefined = 0,
Predefined = 1,
Custom = 2
}
internal enum EditorCompatibility
{
NotCompatibleWithEditor = 0,
CompatibleWithEditor = 1
}
[DebuggerDisplay("{Filename}")]
internal class TargetAssembly
{
public string Filename { get; private set; }
public AssemblyFlags Flags { get; private set; }
public string PathPrefix { get; private set; }
public string[] AdditionalPrefixes { get; set; }
public Func<string, int> PathFilter { get; private set; }
public Func<ScriptAssemblySettings, string[], bool> IsCompatibleFunc { get; private set; }
public List<TargetAssembly> References { get; set; }
public List<string> ExplicitPrecompiledReferences { get; set; }
public TargetAssemblyType Type { get; private set; }
public string[] Defines { get; set; }
public string[] ResponseFileDefines { get; set; }
public string RootNamespace { get; set; }
public ScriptCompilerOptions CompilerOptions { get; set; }
public List<VersionDefine> VersionDefines { get; set; }
public string AsmDefPath { get; set; }
public int MaxPathLength { get; private set; }
public TargetAssembly()
{
References = new List<TargetAssembly>();
Defines = null;
}
public TargetAssembly(string name,
AssemblyFlags flags,
TargetAssemblyType type,
string pathPrefix,
string[] additionalPrefixes,
Func<string, int> pathFilter,
Func<ScriptAssemblySettings, string[], bool> compatFunc,
ScriptCompilerOptions compilerOptions) : this()
{
Filename = name;
Flags = flags;
PathPrefix = pathPrefix;
AdditionalPrefixes = additionalPrefixes;
PathFilter = pathFilter;
IsCompatibleFunc = compatFunc;
Type = type;
CompilerOptions = compilerOptions;
ExplicitPrecompiledReferences = new List<string>();
VersionDefines = new List<VersionDefine>();
if (PathPrefix != null)
MaxPathLength = PathPrefix.Length;
if (AdditionalPrefixes != null)
MaxPathLength = UnityEngine.Mathf.Max(MaxPathLength, AdditionalPrefixes.Max(am => am.Length));
}
public string FullPath(string outputDirectory)
{
return AssetPath.Combine(outputDirectory, Filename);
}
public EditorCompatibility editorCompatibility
{
get
{
bool isCompatibleWithEditor = IsCompatibleFunc == null ||
IsCompatibleFunc(new ScriptAssemblySettings { BuildTarget = BuildTarget.NoTarget, CompilationOptions = EditorScriptCompilationOptions.BuildingForEditor }, null);
return isCompatibleWithEditor
? EditorCompatibility.CompatibleWithEditor
: EditorCompatibility.NotCompatibleWithEditor;
}
}
public override string ToString()
{
return string.Format("{0} ({1})", Filename, Type);
}
protected bool Equals(TargetAssembly other)
{
return string.Equals(Filename, other.Filename) && Flags == other.Flags && Type == other.Type;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((TargetAssembly)obj);
}
public override int GetHashCode()
{
unchecked
{
var hashCode = (Filename != null ? Filename.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (int)Flags;
hashCode = (hashCode * 397) ^ (int)Type;
return hashCode;
}
}
}
}