1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <Project DefaultTargets=
"Build" ToolsVersion=
"4.0" xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003">
4 <UsingTask TaskName=
"_CheckConfigurationProperty" TaskFactory=
"CodeTaskFactory" AssemblyFile=
"$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
6 <ConfFile ParameterType=
"System.String" Required=
"true" />
7 <ConfRegEx ParameterType=
"System.String" Required=
"true" />
8 <ConfPropertyName ParameterType=
"System.String" Output=
"true" />
9 <ConfPropertyValue ParameterType=
"System.String" Output=
"true" />
10 <ConfPropertyFoundMatch ParameterType=
"System.String" Output=
"true" />
13 <Using Namespace=
"System" />
14 <Using Namespace=
"System.Text.RegularExpressions" />
15 <Using Namespace=
"System.IO" />
16 <Code Type=
"Fragment" Language=
"cs">
19 ConfPropertyName =
"";
20 ConfPropertyValue =
"";
21 ConfPropertyFoundMatch =
"false";
23 if (File.Exists (ConfFile))
25 var regex = new Regex (ConfRegEx);
26 using (StreamReader reader = new StreamReader (ConfFile))
29 while ((line = reader.ReadLine ()) != null)
31 var match = regex.Match (line);
32 if (match != null && match.Success)
34 if (match.Groups != null && match.Groups.Count ==
1)
36 var propertyLine = match.Groups[
0].ToString ();
37 if (!String.IsNullOrEmpty (propertyLine))
39 var propertyLineItems = propertyLine.Split ('=');
40 if (propertyLineItems != null && propertyLineItems.Length ==
2)
42 ConfPropertyName = propertyLineItems[
0].Trim ();
43 ConfPropertyValue = propertyLineItems[
1].Trim ();
47 ConfPropertyFoundMatch =
"true";
58 <UsingTask TaskName=
"_GetLLVMConfiguration" TaskFactory=
"CodeTaskFactory" AssemblyFile=
"$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
60 <LLVMConfTool ParameterType=
"System.String" Required=
"true" />
61 <LLVMConfToolArg ParameterType=
"System.String" Required=
"true" />
62 <LLVMConfToolOut ParameterType=
"System.String" Output=
"true" />
65 <Using Namespace=
"System" />
66 <Using Namespace=
"System.Text" />
67 <Using Namespace=
"System.Diagnostics" />
68 <Code Type=
"Fragment" Language=
"cs">
70 var process = new Process ();
72 process.StartInfo.FileName = LLVMConfTool;
73 process.StartInfo.Arguments = LLVMConfToolArg;
74 process.StartInfo.UseShellExecute = false;
75 process.StartInfo.RedirectStandardOutput = true;
78 LLVMConfToolOut = process.StandardOutput.ReadToEnd ().Trim ();
79 process.WaitForExit ();
81 if (LLVMConfToolArg.StartsWith (
"--libnames"))
83 var libs = LLVMConfToolOut.Split (' ');
84 StringBuilder libNames = new StringBuilder ();
85 foreach (var lib in libs)
87 var libPrefixEnd = lib.StartsWith (
"lib") ?
3 :
0;
88 var libExtensionStart = lib.LastIndexOf (
".");
90 if (libNames.Length !=
0)
91 libNames.Append (
" ");
93 libNames.Append (lib.Substring (libPrefixEnd, libExtensionStart - libPrefixEnd) +
".lib");
96 LLVMConfToolOut = libNames.ToString ();
99 if (process.ExitCode !=
0)
100 LLVMConfToolOut =
"";
107 <_MonoSourceDir>$([System.IO.Path]::GetFullPath('$(MONO_DIR)').TrimEnd('\'))
</_MonoSourceDir>
108 <_MonoOutputDir>$([System.IO.Path]::GetFullPath('$(OutDir)'))
</_MonoOutputDir>
109 <_MonoExternalBuildForceMSBuild Condition=
"'$(MONO_EXTERNAL_BUILD_FORCE_MSBUILD)' == 'true'">true
</_MonoExternalBuildForceMSBuild>
110 <_MonoExternalBuildForceMSBuild Condition=
"'$(MONO_EXTERNAL_BUILD_FORCE_MSBUILD)' != 'true'">false
</_MonoExternalBuildForceMSBuild>
114 <_LLVMSourceDir Condition=
"'$(_LLVMSourceDir)' == ''">$(MONO_INTERNAL_LLVM_SOURCE_DIR)
</_LLVMSourceDir>
115 <_LLVMSourceDir Condition=
"'$(_LLVMSourceDir)' == ''">$(_MonoSourceDir)\external\llvm
</_LLVMSourceDir>
116 <_LLVMBuildDir>$([System.IO.Path]::GetFullPath('$(MONO_BUILD_DIR_PREFIX)$(Platform)\obj\external\llvm-build\$(Configuration)'))
</_LLVMBuildDir>
117 <_LLVMInstallDir>$(_LLVMBuildDir)\install
</_LLVMInstallDir>
118 <_MonoLLVMConfig>$(_LLVMInstallDir)\bin\llvm-config.exe
</_MonoLLVMConfig>
122 <_BtlsSourceDir Condition=
"'$(_BtlsSourceDir)' == ''">$(_MonoSourceDir)\external\boringssl
</_BtlsSourceDir>
123 <_MonoBtlsSourceDir>$(_MonoSourceDir)\mono\btls
</_MonoBtlsSourceDir>
124 <_BtlsBuildDir>$([System.IO.Path]::GetFullPath('$(MONO_BUILD_DIR_PREFIX)$(Platform)\obj\external\btls-build-shared\$(Configuration)'))
</_BtlsBuildDir>
127 <Target Name=
"_CheckEnableBtls" Condition=
"'$(MONO_ENABLE_BTLS)' != 'true'">
128 <_CheckConfigurationProperty ConfFile=
"$(MONO_DIR)/cygconfig.h" ConfRegEx=
".*#define.*HAVE_BTLS.*1">
129 <Output TaskParameter=
"ConfPropertyFoundMatch" PropertyName=
"MONO_ENABLE_BTLS" />
130 </_CheckConfigurationProperty>
133 <Target Name=
"_CheckEnableLLVM" Condition=
"'$(MONO_ENABLE_LLVM)' != 'true'">
134 <_CheckConfigurationProperty ConfFile=
"$(MONO_DIR)/cygconfig.h" ConfRegEx=
".*#define.*ENABLE_LLVM.*1">
135 <Output TaskParameter=
"ConfPropertyFoundMatch" PropertyName=
"MONO_ENABLE_LLVM" />
136 </_CheckConfigurationProperty>
139 <Target Name=
"_CheckInternalLLVM" Condition=
"'$(_MonoEnableInternalLLVM)' != 'true' and '$(_MonoEnableExternalLLVM)' != 'true' and '$(MONO_ENABLE_LLVM)' == 'true'" DependsOnTargets=
"_CheckEnableLLVM">
140 <_CheckConfigurationProperty ConfFile=
"$(MONO_DIR)/cygconfig.h" ConfRegEx=
".*#define.*INTERNAL_LLVM.*1">
141 <Output TaskParameter=
"ConfPropertyFoundMatch" PropertyName=
"_MonoEnableInternalLLVM" />
142 </_CheckConfigurationProperty>
145 <Target Name=
"_CheckExternalLLVM" Condition=
"'$(_MonoEnableExternalLLVM)' != 'true' and '$(_MonoEnableInternalLLVM)' != 'true' and '$(MONO_ENABLE_LLVM)' == 'true'" DependsOnTargets=
"_CheckEnableLLVM">
146 <_CheckConfigurationProperty ConfFile=
"$(MONO_DIR)\Makefile" ConfRegEx=
".*EXTERNAL_LLVM_CONFIG_WIN32.*llvm-config.exe">
147 <Output TaskParameter=
"ConfPropertyFoundMatch" PropertyName=
"_MonoEnableExternalLLVM" />
148 <Output TaskParameter=
"ConfPropertyValue" PropertyName=
"_CheckExternalLLVMOutput" />
149 </_CheckConfigurationProperty>
151 <_MonoLLVMConfig Condition=
"'$(_MonoEnableExternalLLVM)' == 'true'">$(_CheckExternalLLVMOutput)
</_MonoLLVMConfig>
155 <Target Name=
"_SetDefaultLLVMProperties" Condition=
"'$(MONO_ENABLE_LLVM)' == 'true'">
156 <PropertyGroup Condition=
"'$(MONO_EXTERNAL_LLVM_CONFIG)' != ''">
157 <_MonoEnableExternalLLVM>true
</_MonoEnableExternalLLVM>
158 <_MonoEnableInternalLLVM>false
</_MonoEnableInternalLLVM>
159 <_MonoLLVMConfig>$(MONO_EXTERNAL_LLVM_CONFIG)
</_MonoLLVMConfig>
162 <PropertyGroup Condition=
"'$(MONO_EXTERNAL_LLVM_CONFIG)' == ''">
163 <_MonoEnableExternalLLVM>false
</_MonoEnableExternalLLVM>
164 <_MonoEnableInternalLLVM>true
</_MonoEnableInternalLLVM>
168 <Target Name=
"_CheckLLVMPlatformSupport" Condition=
"'$(MONO_ENABLE_LLVM)' == 'true'">
169 <warning Text=
"LLVM only supported on x64 builds, disabling LLVM support." Condition=
"'$(Platform)' != 'x64'" />
170 <PropertyGroup Condition=
"'$(Platform)' != 'x64'">
171 <MONO_ENABLE_LLVM>false
</MONO_ENABLE_LLVM>
175 <Target Name=
"_SetupMonoLLVMBuildProperties" Condition=
"$(MONO_ENABLE_LLVM) == 'true'">
177 <_CheckConfigurationProperty ConfFile=
"$(MONO_DIR)/cygconfig.h" ConfRegEx=
".*#define.*INTERNAL_LLVM_ASSERTS.*1" Condition=
"'$(MONO_ENABLE_LLVM_ASSERTS)' != 'true'">
178 <Output TaskParameter=
"ConfPropertyFoundMatch" PropertyName=
"MONO_ENABLE_LLVM_ASSERTS" />
179 </_CheckConfigurationProperty>
181 <Error Text=
"LLVM config executable $(_MonoLLVMConfig) not found." Condition=
"!Exists($(_MonoLLVMConfig))" />
183 <_GetLLVMConfiguration LLVMConfTool=
"$(_MonoLLVMConfig)" LLVMConfToolArg=
"--version">
184 <Output TaskParameter=
"LLVMConfToolOut" PropertyName=
"MONO_LLVM_VERSION" />
185 </_GetLLVMConfiguration>
187 <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'))" />
188 <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'))" />
190 <_GetLLVMConfiguration LLVMConfTool=
"$(_MonoLLVMConfig)" LLVMConfToolArg=
"--mono-api-version">
191 <Output TaskParameter=
"LLVMConfToolOut" PropertyName=
"MONO_LLVM_API_VERSION" />
192 </_GetLLVMConfiguration>
195 <_MonoLLVMConfigComponents>analysis core bitwriter x86codegen
</_MonoLLVMConfigComponents>
196 <!-- Currently LLVM JIT is only supported on OSX and including the libraries will get some duplicated symbols during linking.
197 <_MonoLLVMConfigComponents Condition="$(MONO_LLVM_API_VERSION) < 600">$(_MonoLLVMConfigComponents)mcjit jit</_MonoLLVMConfigComponents>
198 <_MonoLLVMConfigComponents Condition="$(MONO_LLVM_API_VERSION) >= 600">$(_MonoLLVMConfigComponents)mcjit orcjit</_MonoLLVMConfigComponents>
202 <_GetLLVMConfiguration LLVMConfTool=
"$(_MonoLLVMConfig)" LLVMConfToolArg=
"--libnames $(_MonoLLVMConfigComponents)">
203 <Output TaskParameter=
"LLVMConfToolOut" PropertyName=
"MONO_LLVM_LIBS" />
204 </_GetLLVMConfiguration>
207 <MONO_LLVM_LIBS>$(MONO_LLVM_LIBS.Split(' '))
</MONO_LLVM_LIBS>
210 <_GetLLVMConfiguration LLVMConfTool=
"$(_MonoLLVMConfig)" LLVMConfToolArg=
"--includedir">
211 <Output TaskParameter=
"LLVMConfToolOut" PropertyName=
"MONO_LLVM_INCLUDE_DIR" />
212 </_GetLLVMConfiguration>
214 <_GetLLVMConfiguration LLVMConfTool=
"$(_MonoLLVMConfig)" LLVMConfToolArg=
"--bindir">
215 <Output TaskParameter=
"LLVMConfToolOut" PropertyName=
"MONO_LLVM_BIN_DIR" />
216 </_GetLLVMConfiguration>
218 <_GetLLVMConfiguration LLVMConfTool=
"$(_MonoLLVMConfig)" LLVMConfToolArg=
"--libdir">
219 <Output TaskParameter=
"LLVMConfToolOut" PropertyName=
"MONO_LLVM_LIB_DIR" />
220 </_GetLLVMConfiguration>
222 <Message Importance=
"normal" Text=
"LLVM build properties:" />
223 <Message Importance=
"normal" Text=
"MONO_LLVM_VERSION = $(MONO_LLVM_VERSION)" />
224 <Message Importance=
"normal" Text=
"MONO_LLVM_API_VERSION = $(MONO_LLVM_API_VERSION)" />
225 <Message Importance=
"normal" Text=
"MONO_LLVM_LIBS = $(MONO_LLVM_LIBS)" />
226 <Message Importance=
"normal" Text=
"MONO_LLVM_INCLUDE_DIR = $(MONO_LLVM_INCLUDE_DIR)" />
227 <Message Importance=
"normal" Text=
"MONO_LLVM_BIN_DIR = $(MONO_LLVM_BIN_DIR)" />
228 <Message Importance=
"normal" Text=
"MONO_LLVM_LIB_DIR = $(MONO_LLVM_LIB_DIR)" />
232 <Target Name=
"_ConfigureExternalMonoLLVMBuildEnvironment" DependsOnTargets=
"_SetDefaultLLVMProperties;_CheckEnableLLVM;_CheckInternalLLVM;_CheckExternalLLVM;_CheckLLVMPlatformSupport" />
233 <Target Name=
"_ConfigureExternalMonoBTLSBuildEnvironment" DependsOnTargets=
"_CheckEnableBtls" />
234 <Target Name=
"_ConfigureExternalMonoBuildEnvironment" DependsOnTargets=
"_ConfigureExternalMonoLLVMBuildEnvironment;_ConfigureExternalMonoBTLSBuildEnvironment" />
237 <PrepareForBuildDependsOn>
238 _ConfigureExternalMonoBuildEnvironment;
239 $(PrepareForBuildDependsOn);
240 </PrepareForBuildDependsOn>