blob: c3603ec06d566e2c97647c2261b95f611b97a253 (
plain)
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="_CheckConfigurationProperty" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<ConfFile ParameterType="System.String" Required="true" />
<ConfRegEx ParameterType="System.String" Required="true" />
<ConfPropertyName ParameterType="System.String" Output="true" />
<ConfPropertyValue ParameterType="System.String" Output="true" />
<ConfPropertyFoundMatch ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.Text.RegularExpressions" />
<Using Namespace="System.IO" />
<Code Type="Fragment" Language="cs">
<![CDATA[
ConfPropertyName = "";
ConfPropertyValue = "";
ConfPropertyFoundMatch = "false";
if (File.Exists (ConfFile))
{
var regex = new Regex (ConfRegEx);
using (StreamReader reader = new StreamReader (ConfFile))
{
string line;
while ((line = reader.ReadLine ()) != null)
{
var match = regex.Match (line);
if (match != null && match.Success)
{
if (match.Groups != null && match.Groups.Count == 1)
{
var propertyLine = match.Groups[0].ToString ();
if (!String.IsNullOrEmpty (propertyLine))
{
var propertyLineItems = propertyLine.Split ('=');
if (propertyLineItems != null && propertyLineItems.Length == 2)
{
ConfPropertyName = propertyLineItems[0].Trim ();
ConfPropertyValue = propertyLineItems[1].Trim ();
}
}
}
ConfPropertyFoundMatch = "true";
break;
}
}
}
}
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="_GetLLVMConfiguration" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<LLVMConfTool ParameterType="System.String" Required="true" />
<LLVMConfToolArg ParameterType="System.String" Required="true" />
<LLVMConfToolOut ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.Text" />
<Using Namespace="System.Diagnostics" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var process = new Process ();
process.StartInfo.FileName = LLVMConfTool;
process.StartInfo.Arguments = LLVMConfToolArg;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start ();
LLVMConfToolOut = process.StandardOutput.ReadToEnd ().Trim ();
process.WaitForExit ();
if (LLVMConfToolArg.StartsWith ("--libnames"))
{
var libs = LLVMConfToolOut.Split (' ');
StringBuilder libNames = new StringBuilder ();
foreach (var lib in libs)
{
var libPrefixEnd = lib.StartsWith ("lib") ? 3 : 0;
var libExtensionStart = lib.LastIndexOf (".");
if (libNames.Length != 0)
libNames.Append (" ");
libNames.Append (lib.Substring (libPrefixEnd, libExtensionStart - libPrefixEnd) + ".lib");
}
LLVMConfToolOut = libNames.ToString ();
}
if (process.ExitCode != 0)
LLVMConfToolOut = "";
]]>
</Code>
</Task>
</UsingTask>
<PropertyGroup>
<_MonoSourceDir>$([System.IO.Path]::GetFullPath('$(MONO_DIR)').TrimEnd('\'))</_MonoSourceDir>
<_MonoOutputDir>$([System.IO.Path]::GetFullPath('$(OutDir)'))</_MonoOutputDir>
<_MonoExternalBuildForceMSBuild Condition="'$(MONO_EXTERNAL_BUILD_FORCE_MSBUILD)' == 'true'">true</_MonoExternalBuildForceMSBuild>
<_MonoExternalBuildForceMSBuild Condition="'$(MONO_EXTERNAL_BUILD_FORCE_MSBUILD)' != 'true'">false</_MonoExternalBuildForceMSBuild>
</PropertyGroup>
<PropertyGroup>
<_LLVMSourceDir Condition="'$(_LLVMSourceDir)' == ''">$(MONO_INTERNAL_LLVM_SOURCE_DIR)</_LLVMSourceDir>
<_LLVMSourceDir Condition="'$(_LLVMSourceDir)' == ''">$(_MonoSourceDir)\external\llvm</_LLVMSourceDir>
<_LLVMBuildDir Condition="'$(_LLVMBuildDir)' == ''">$([System.IO.Path]::GetFullPath('$(MONO_BUILD_DIR_PREFIX)$(Platform)\obj\external\llvm-build\$(Configuration)'))</_LLVMBuildDir>
<_LLVMInstallDir Condition="'$(_LLVMInstallDir)' == ''">$(_LLVMBuildDir)\install</_LLVMInstallDir>
<_MonoLLVMConfig>$(_LLVMInstallDir)\bin\llvm-config.exe</_MonoLLVMConfig>
</PropertyGroup>
<PropertyGroup>
<_BtlsSourceDir Condition="'$(_BtlsSourceDir)' == ''">$(_MonoSourceDir)\external\boringssl</_BtlsSourceDir>
<_MonoBtlsSourceDir>$(_MonoSourceDir)\mono\btls</_MonoBtlsSourceDir>
<_BtlsBuildDir>$([System.IO.Path]::GetFullPath('$(MONO_BUILD_DIR_PREFIX)$(Platform)\obj\external\btls-build-shared\$(Configuration)'))</_BtlsBuildDir>
</PropertyGroup>
<Target Name="_CheckEnableBtls" Condition="'$(MONO_ENABLE_BTLS)' != 'true'">
<_CheckConfigurationProperty ConfFile="$(MONO_DIR)/cygconfig.h" ConfRegEx=".*#define.*HAVE_BTLS.*1">
<Output TaskParameter="ConfPropertyFoundMatch" PropertyName="MONO_ENABLE_BTLS" />
</_CheckConfigurationProperty>
</Target>
<Target Name="_CheckEnableLLVM" Condition="'$(MONO_ENABLE_LLVM)' != 'true'">
<_CheckConfigurationProperty ConfFile="$(MONO_DIR)/cygconfig.h" ConfRegEx=".*#define.*ENABLE_LLVM.*1">
<Output TaskParameter="ConfPropertyFoundMatch" PropertyName="MONO_ENABLE_LLVM" />
</_CheckConfigurationProperty>
</Target>
<Target Name="_CheckInternalLLVM" Condition="'$(_MonoEnableInternalLLVM)' != 'true' and '$(_MonoEnableExternalLLVM)' != 'true' and '$(MONO_ENABLE_LLVM)' == 'true'" DependsOnTargets="_CheckEnableLLVM">
<_CheckConfigurationProperty ConfFile="$(MONO_DIR)/cygconfig.h" ConfRegEx=".*#define.*INTERNAL_LLVM.*1">
<Output TaskParameter="ConfPropertyFoundMatch" PropertyName="_MonoEnableInternalLLVM" />
</_CheckConfigurationProperty>
</Target>
<Target Name="_CheckExternalLLVM" Condition="'$(_MonoEnableExternalLLVM)' != 'true' and '$(_MonoEnableInternalLLVM)' != 'true' and '$(MONO_ENABLE_LLVM)' == 'true'" DependsOnTargets="_CheckEnableLLVM">
<_CheckConfigurationProperty ConfFile="$(MONO_DIR)\Makefile" ConfRegEx=".*EXTERNAL_LLVM_CONFIG_WIN32.*llvm-config.exe">
<Output TaskParameter="ConfPropertyFoundMatch" PropertyName="_MonoEnableExternalLLVM" />
<Output TaskParameter="ConfPropertyValue" PropertyName="_CheckExternalLLVMOutput" />
</_CheckConfigurationProperty>
<PropertyGroup>
<_MonoLLVMConfig Condition="'$(_MonoEnableExternalLLVM)' == 'true'">$(_CheckExternalLLVMOutput)</_MonoLLVMConfig>
</PropertyGroup>
</Target>
<Target Name="_SetDefaultLLVMProperties" Condition="'$(MONO_ENABLE_LLVM)' == 'true'">
<PropertyGroup Condition="'$(MONO_EXTERNAL_LLVM_CONFIG)' != ''">
<_MonoEnableExternalLLVM>true</_MonoEnableExternalLLVM>
<_MonoEnableInternalLLVM>false</_MonoEnableInternalLLVM>
<_MonoLLVMConfig>$(MONO_EXTERNAL_LLVM_CONFIG)</_MonoLLVMConfig>
</PropertyGroup>
<PropertyGroup Condition="'$(MONO_EXTERNAL_LLVM_CONFIG)' == ''">
<_MonoEnableExternalLLVM>false</_MonoEnableExternalLLVM>
<_MonoEnableInternalLLVM>true</_MonoEnableInternalLLVM>
</PropertyGroup>
</Target>
<Target Name="_CheckLLVMPlatformSupport" Condition="'$(MONO_ENABLE_LLVM)' == 'true'">
<warning Text="LLVM only supported on x64 builds, disabling LLVM support." Condition="'$(Platform)' != 'x64'" />
<PropertyGroup Condition="'$(Platform)' != 'x64'">
<MONO_ENABLE_LLVM>false</MONO_ENABLE_LLVM>
</PropertyGroup>
</Target>
<Target Name="_SetupMonoLLVMBuildProperties" Condition="$(MONO_ENABLE_LLVM) == 'true'">
<_CheckConfigurationProperty ConfFile="$(MONO_DIR)/cygconfig.h" ConfRegEx=".*#define.*INTERNAL_LLVM_ASSERTS.*1" Condition="'$(MONO_ENABLE_LLVM_ASSERTS)' != 'true'">
<Output TaskParameter="ConfPropertyFoundMatch" PropertyName="MONO_ENABLE_LLVM_ASSERTS" />
</_CheckConfigurationProperty>
<Error Text="LLVM config executable $(_MonoLLVMConfig) not found." Condition="!Exists($(_MonoLLVMConfig))" />
<_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--version">
<Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_VERSION" />
</_GetLLVMConfiguration>
<Error Text="Compiling with stock LLVM is not supported, please use the Mono LLVM repo at https://github.com/mono/llvm." Condition="!$(MONO_LLVM_VERSION.Contains('mono'))" />
<Error Text="Expected llvm version 3.6 or 6.0, but llvm-config --version returned $(MONO_LLVM_VERSION)." Condition="!$(MONO_LLVM_VERSION.StartsWith('3.6')) and !$(MONO_LLVM_VERSION.StartsWith('6.0'))" />
<_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--mono-api-version">
<Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_API_VERSION" />
</_GetLLVMConfiguration>
<PropertyGroup>
<_MonoLLVMConfigComponents>analysis core bitwriter x86codegen</_MonoLLVMConfigComponents>
<!-- Currently LLVM JIT is only supported on OSX and including the libraries will get some duplicated symbols during linking.
<_MonoLLVMConfigComponents Condition="$(MONO_LLVM_API_VERSION) < 600">$(_MonoLLVMConfigComponents)mcjit jit</_MonoLLVMConfigComponents>
<_MonoLLVMConfigComponents Condition="$(MONO_LLVM_API_VERSION) >= 600">$(_MonoLLVMConfigComponents)mcjit orcjit</_MonoLLVMConfigComponents>
-->
</PropertyGroup>
<_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--libnames $(_MonoLLVMConfigComponents)">
<Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_LIBS" />
</_GetLLVMConfiguration>
<PropertyGroup>
<MONO_LLVM_LIBS>$(MONO_LLVM_LIBS.Split(' '))</MONO_LLVM_LIBS>
</PropertyGroup>
<_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--includedir">
<Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_INCLUDE_DIR" />
</_GetLLVMConfiguration>
<_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--bindir">
<Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_BIN_DIR" />
</_GetLLVMConfiguration>
<_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--libdir">
<Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_LIB_DIR" />
</_GetLLVMConfiguration>
<Message Importance="normal" Text="LLVM build properties:" />
<Message Importance="normal" Text="MONO_LLVM_VERSION = $(MONO_LLVM_VERSION)" />
<Message Importance="normal" Text="MONO_LLVM_API_VERSION = $(MONO_LLVM_API_VERSION)" />
<Message Importance="normal" Text="MONO_LLVM_LIBS = $(MONO_LLVM_LIBS)" />
<Message Importance="normal" Text="MONO_LLVM_INCLUDE_DIR = $(MONO_LLVM_INCLUDE_DIR)" />
<Message Importance="normal" Text="MONO_LLVM_BIN_DIR = $(MONO_LLVM_BIN_DIR)" />
<Message Importance="normal" Text="MONO_LLVM_LIB_DIR = $(MONO_LLVM_LIB_DIR)" />
</Target>
<Target Name="_ConfigureExternalMonoLLVMBuildEnvironment" DependsOnTargets="_SetDefaultLLVMProperties;_CheckEnableLLVM;_CheckInternalLLVM;_CheckExternalLLVM;_CheckLLVMPlatformSupport" />
<Target Name="_ConfigureExternalMonoBTLSBuildEnvironment" DependsOnTargets="_CheckEnableBtls" />
<Target Name="_ConfigureExternalMonoBuildEnvironment" DependsOnTargets="_ConfigureExternalMonoLLVMBuildEnvironment;_ConfigureExternalMonoBTLSBuildEnvironment" />
<PropertyGroup>
<PrepareForBuildDependsOn>
_ConfigureExternalMonoBuildEnvironment;
$(PrepareForBuildDependsOn);
</PrepareForBuildDependsOn>
</PropertyGroup>
</Project>
|