Add back whitespace at end of sre-save.c
[mono-project.git] / msvc / mono.external.targets
bloba91c9db30f81f208f8a934c87de2b909904e651c
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">
5 <ParameterGroup>
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" />
11 </ParameterGroup>
12 <Task>
13 <Using Namespace="System" />
14 <Using Namespace="System.Text.RegularExpressions" />
15 <Using Namespace="System.IO" />
16 <Code Type="Fragment" Language="cs">
17 <![CDATA[
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))
28 string line;
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";
48 break;
53 ]]>
54 </Code>
55 </Task>
56 </UsingTask>
58 <UsingTask TaskName="_GetLLVMConfiguration" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
59 <ParameterGroup>
60 <LLVMConfTool ParameterType="System.String" Required="true" />
61 <LLVMConfToolArg ParameterType="System.String" Required="true" />
62 <LLVMConfToolOut ParameterType="System.String" Output="true" />
63 </ParameterGroup>
64 <Task>
65 <Using Namespace="System" />
66 <Using Namespace="System.Text" />
67 <Using Namespace="System.Diagnostics" />
68 <Code Type="Fragment" Language="cs">
69 <![CDATA[
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;
76 process.Start ();
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 = "";
102 </Code>
103 </Task>
104 </UsingTask>
106 <PropertyGroup>
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>
111 </PropertyGroup>
113 <PropertyGroup>
114 <_LLVMSourceDir Condition="'$(_LLVMSourceDir)' == ''">$(MONO_INTERNAL_LLVM_SOURCE_DIR)</_LLVMSourceDir>
115 <_LLVMSourceDir Condition="'$(_LLVMSourceDir)' == ''">$(_MonoSourceDir)\external\llvm-project</_LLVMSourceDir>
116 <_LLVMBuildDir Condition="'$(_LLVMBuildDir)' == ''">$([System.IO.Path]::GetFullPath('$(MONO_BUILD_DIR_PREFIX)$(Platform)\obj\external\llvm-build\$(Configuration)'))</_LLVMBuildDir>
117 <_LLVMInstallDir Condition="'$(_LLVMInstallDir)' == ''">$(_LLVMBuildDir)\install</_LLVMInstallDir>
118 <_MonoLLVMConfig>$(_LLVMInstallDir)\bin\llvm-config.exe</_MonoLLVMConfig>
119 </PropertyGroup>
121 <PropertyGroup>
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>
125 </PropertyGroup>
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>
131 </Target>
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>
137 </Target>
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>
143 </Target>
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>
150 <PropertyGroup>
151 <_MonoLLVMConfig Condition="'$(_MonoEnableExternalLLVM)' == 'true'">$(_CheckExternalLLVMOutput)</_MonoLLVMConfig>
152 </PropertyGroup>
153 </Target>
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>
160 </PropertyGroup>
162 <PropertyGroup Condition="'$(MONO_EXTERNAL_LLVM_CONFIG)' == ''">
163 <_MonoEnableExternalLLVM>false</_MonoEnableExternalLLVM>
164 <_MonoEnableInternalLLVM>true</_MonoEnableInternalLLVM>
165 </PropertyGroup>
166 </Target>
168 <Target Name="_CheckLLVMPlatformSupport" Condition="'$(MONO_ENABLE_LLVM)' == 'true'">
169 <Message Importance="high" 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>
172 </PropertyGroup>
173 </Target>
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 <_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--build-mode">
188 <Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_BUILD_MODE" />
189 </_GetLLVMConfiguration>
191 <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'))" />
192 <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'))" />
193 <Error Text="LLVM build Configuration=$(MONO_LLVM_BUILD_MODE) doesn't match current build Configuration=$(Configuration)." Condition="'$(Configuration.ToUpper())'!='$(MONO_LLVM_BUILD_MODE.ToUpper())'" />
195 <_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--mono-api-version">
196 <Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_API_VERSION" />
197 </_GetLLVMConfiguration>
199 <PropertyGroup>
200 <_MonoLLVMConfigComponents>analysis core bitwriter x86codegen</_MonoLLVMConfigComponents>
201 <!-- Currently LLVM JIT is only supported on OSX and including the libraries will get some duplicated symbols during linking.
202 <_MonoLLVMConfigComponents Condition="$(MONO_LLVM_API_VERSION) &lt; 600">$(_MonoLLVMConfigComponents)mcjit jit</_MonoLLVMConfigComponents>
203 <_MonoLLVMConfigComponents Condition="$(MONO_LLVM_API_VERSION) &gt;= 600">$(_MonoLLVMConfigComponents)mcjit orcjit</_MonoLLVMConfigComponents>
205 </PropertyGroup>
207 <_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--libnames $(_MonoLLVMConfigComponents)">
208 <Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_LIBS" />
209 </_GetLLVMConfiguration>
211 <PropertyGroup>
212 <MONO_LLVM_LIBS>$(MONO_LLVM_LIBS.Split(' '))</MONO_LLVM_LIBS>
213 </PropertyGroup>
215 <_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--includedir">
216 <Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_INCLUDE_DIR" />
217 </_GetLLVMConfiguration>
219 <_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--bindir">
220 <Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_BIN_DIR" />
221 </_GetLLVMConfiguration>
223 <_GetLLVMConfiguration LLVMConfTool="$(_MonoLLVMConfig)" LLVMConfToolArg="--libdir">
224 <Output TaskParameter="LLVMConfToolOut" PropertyName="MONO_LLVM_LIB_DIR" />
225 </_GetLLVMConfiguration>
227 <Message Importance="normal" Text="LLVM build properties:" />
228 <Message Importance="normal" Text="MONO_LLVM_VERSION = $(MONO_LLVM_VERSION)" />
229 <Message Importance="normal" Text="MONO_LLVM_API_VERSION = $(MONO_LLVM_API_VERSION)" />
230 <Message Importance="normal" Text="MONO_LLVM_LIBS = $(MONO_LLVM_LIBS)" />
231 <Message Importance="normal" Text="MONO_LLVM_INCLUDE_DIR = $(MONO_LLVM_INCLUDE_DIR)" />
232 <Message Importance="normal" Text="MONO_LLVM_BIN_DIR = $(MONO_LLVM_BIN_DIR)" />
233 <Message Importance="normal" Text="MONO_LLVM_LIB_DIR = $(MONO_LLVM_LIB_DIR)" />
235 </Target>
237 <Target Name="_ConfigureExternalMonoLLVMBuildEnvironment" DependsOnTargets="_SetDefaultLLVMProperties;_CheckEnableLLVM;_CheckInternalLLVM;_CheckExternalLLVM;_CheckLLVMPlatformSupport" />
238 <Target Name="_ConfigureExternalMonoBTLSBuildEnvironment" DependsOnTargets="_CheckEnableBtls" />
239 <Target Name="_ConfigureExternalMonoBuildEnvironment" DependsOnTargets="_ConfigureExternalMonoLLVMBuildEnvironment;_ConfigureExternalMonoBTLSBuildEnvironment" />
241 <PropertyGroup>
242 <PrepareForBuildDependsOn>
243 _ConfigureExternalMonoBuildEnvironment;
244 $(PrepareForBuildDependsOn);
245 </PrepareForBuildDependsOn>
246 </PropertyGroup>
248 </Project>