Merge pull request #19344 from adityamandaleeka/aa64_vm_callconv_changes
[platform/upstream/coreclr.git] / tests / src / dir.targets
1 <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2   <!-- Default priority building values. -->
3   <PropertyGroup>
4     <CLRTestKind Condition="'$(CLRTestKind)' == '' and '$(OutputType)' == 'Library'">SharedLibrary</CLRTestKind>
5     <CLRTestKind Condition="'$(CLRTestKind)' == ''">BuildAndRun</CLRTestKind>
6     <CLRTestPriority Condition="'$(CLRTestPriority)' == ''">0</CLRTestPriority>
7   </PropertyGroup>
8   
9   <PropertyGroup Condition="'$(UsingMicrosoftNETSdk)' == 'true'">
10     <!-- Many parts of the tests expect the output file to be an exe. We override the extension to match here, but in future we should probably update the infrastructure to look for dlls -->
11     <TargetExt Condition="'$(OutputType)' == 'Exe' and '$(TargetExt)' == '.dll'">.exe</TargetExt>
12   </PropertyGroup>
13
14   <!-- All CLRTests need to be of a certain "kind". These kinds are enumerated below.
15   By default all tests are BuildAndRun. This means that the build system will Build them
16   and construct a run-batch-script for them. -->
17   <Choose>
18     <When Condition=" '$(CLRTestKind)'=='SharedLibrary'">
19       <PropertyGroup>
20         <_CLRTestCompilesSource>true</_CLRTestCompilesSource>
21         <_CLRTestNeedsToRun>false</_CLRTestNeedsToRun>
22         <GenerateRunScript>false</GenerateRunScript>
23         <_CLRTestBuildsExecutable>false</_CLRTestBuildsExecutable>
24       </PropertyGroup>
25     </When>
26     <When Condition=" '$(CLRTestKind)'=='BuildAndRun' ">
27       <PropertyGroup>
28         <GenerateRunScript>true</GenerateRunScript>
29         <_CLRTestNeedsToRun>true</_CLRTestNeedsToRun>
30         <_CLRTestCompilesSource>true</_CLRTestCompilesSource>
31         <_CLRTestBuildsExecutable>true</_CLRTestBuildsExecutable>
32       </PropertyGroup>
33     </When>
34     <When Condition=" '$(CLRTestKind)'=='BuildOnly'">
35       <PropertyGroup>
36         <_CLRTestNeedsToRun>false</_CLRTestNeedsToRun>
37         <GenerateRunScript>false</GenerateRunScript>
38         <_CLRTestCompilesSource>true</_CLRTestCompilesSource>
39         <_CLRTestBuildsExecutable>true</_CLRTestBuildsExecutable>
40       </PropertyGroup>
41     </When>
42     <When Condition=" '$(CLRTestKind)'=='RunOnly' ">
43       <PropertyGroup>
44         <GenerateRunScript>true</GenerateRunScript>
45         <SkipSigning>true</SkipSigning>
46         <_CLRTestBuildsExecutable>false</_CLRTestBuildsExecutable>
47         <_CLRTestNeedsToRun>true</_CLRTestNeedsToRun>
48         <_CLRTestCompilesSource>false</_CLRTestCompilesSource>
49       </PropertyGroup>
50     </When>
51   </Choose>
52   
53   <PropertyGroup> 
54     <_CLRTestNeedsProjectToRun>false</_CLRTestNeedsProjectToRun>
55     <_CLRTestNeedsProjectToRun Condition=" '$(_CLRTestNeedsToRun)' and '!$(_CLRTestBuildsExecutable)' ">true</_CLRTestNeedsProjectToRun>
56   </PropertyGroup>
57
58   <PropertyGroup>
59     <!-- Since bug in Roslyn for Linux empty DebugType property leads to build failure. See issue Roslyn@20343 -->
60     <DebugType Condition=" '$(DebugType)' == '' and '$(RunningOnUnix)' == 'true' ">None</DebugType>
61   </PropertyGroup>
62
63   <!--
64   If it needs ProjectToRun, turn the project into a ProjectReference so it gets built
65   -->
66   <ItemGroup Condition=" $(_CLRTestNeedsProjectToRun) ">
67     <ProjectReference Include="$(CLRTestProjectToRun)">
68       <Private>false</Private>
69     </ProjectReference>
70   </ItemGroup>
71         
72   <PropertyGroup>
73     <ErrorIfBuildToolsRestoredFromIndividualProject Condition="!Exists('$(ToolsDir)')">true</ErrorIfBuildToolsRestoredFromIndividualProject>
74   </PropertyGroup>
75   
76   <Import Project="..\dir.targets" />
77
78   <!-- Determine if this project should be built or not -->
79   <PropertyGroup> 
80     <BuildAllProjects Condition=" '$(BuildAllProjects)' == ''">false</BuildAllProjects>
81     <_WillCLRTestProjectBuild Condition="'$(_WillCLRTestProjectBuild)' == ''">false</_WillCLRTestProjectBuild>
82     <_WillCLRTestProjectBuild Condition="'$(BuildAllProjects)' != true">true</_WillCLRTestProjectBuild>
83     <_WillCLRTestProjectBuild Condition="'$(DisableProjectBuild)' != true And '$(BuildAllProjects)' == true And '$(CLRTestPriority)' &lt;= '$(CLRTestPriorityToBuild)'">true</_WillCLRTestProjectBuild>
84   </PropertyGroup>
85     
86   <!-- if we have determined that there is nothing to build, overwrite the build targets so that nothing happens -->
87   <Import Project="nobuild.targets" Condition="'$(_WillCLRTestProjectBuild)' == 'false'" />
88  
89   <!-- RunOnly projects have a special build for dependent projects -->
90   <Import Project="runonly.targets" Condition="'$(CLRTestKind)' == 'RunOnly'" />
91   
92   <!-- We will use an imported build here in the instance that we're a non-sdk style project, have source that we need to build, and we are the correct priority...OR if we are being asked to build for
93   a test with a higher priority. -->
94   <Import Project="$(ToolsDir)Build.Common.targets" Condition="('$(UsingMicrosoftNETSdk)' != 'true') And ('$(CLRTestKind)'!='RunOnly') And $(_CLRTestCompilesSource) And ('$(_WillCLRTestProjectBuild)')"/>
95
96
97   <Import Project="..\override.targets" Condition="Exists('..\override.targets')"/>
98
99   <!-- We enable auto-unification of assembly references after importing the common targets.  Binding redirects are not needed
100        for coreclr since it auto-unifies, so the warnings we get without this setting are just noise -->
101   <PropertyGroup>
102     <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
103   </PropertyGroup>
104
105   <!-- Project language -->
106   <!-- TODO: This might just be the Language property -->
107   <PropertyGroup Condition="'$(ProjectLanguage)' == ''">
108     <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.ilproj' OR '$(Language)' == 'IL'">IL</ProjectLanguage>
109     <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.csproj' OR '$(Language)' == 'C#' OR '$(ProjectLanguage)'==''">CSharp</ProjectLanguage>
110
111     <SkipImportILTargets Condition="'$(CLRTestPriority)' &gt; '$(CLRTestPriorityToBuild)'">true</SkipImportILTargets>
112   </PropertyGroup>
113
114   <Import Project="CLRTest.Execute.targets" />
115   <Target Name="CreateExecuteScript" 
116           AfterTargets="Build"
117           Condition="'$(GenerateRunScript)' != 'false' And ('$(_WillCLRTestProjectBuild)')"
118           DependsOnTargets="GenerateExecutionScriptsInternal" />
119
120   <Target Name="CopyNativeProjectBinaries">
121      <ItemGroup>
122         <NativeProjectBinaries Include="$(NativeProjectOutputFolder)\**\*.*" />
123      </ItemGroup>
124
125      <Error  Text="The native project files are missing in $(NativeProjectOutputFolder) please run build from the root of the repo at least once"
126              Condition="'@(NativeProjectBinaries)' == ''" />
127
128      <Copy
129         SourceFiles="@(NativeProjectBinaries)"
130         DestinationFiles="@(NativeProjectBinaries -> '$(OutDir)%(RecursiveDir)%(Filename)%(Extension)')"
131         SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
132         OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
133         Retries="$(CopyRetryCount)"
134         RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
135         UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)">
136         <Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
137      </Copy>
138   </Target>
139
140   <Target Name="ResolveCmakeNativeProjectReference"
141           Condition="'@(ProjectReference)' != ''"
142           BeforeTargets="BeforeResolveReferences;BeforeClean" >
143      <ItemGroup>
144         <NativeProjectReference Include="%(ProjectReference.Identity)" Condition="$([System.String]::Copy(%(ProjectReference.FileName)).ToUpper()) == 'CMAKELISTS'" />
145         <ProjectReference Remove="%(NativeProjectReference.Identity)" />
146         <NativeProjectReferenceNormalized Include="@(NativeProjectReference -> '%(FullPath)')" />
147      </ItemGroup>
148   </Target>
149
150   <Target Name="ConsolidateNativeProjectReference"
151           Condition="'@(NativeProjectReferenceNormalized)' != ''"
152           BeforeTargets="Build" >
153      <ItemGroup>
154         <NativeProjectOutputFoldersToCopy Include="$([System.String]::Copy('%(NativeProjectReferenceNormalized.RelativeDir)').Replace($(SourceDir),$(__NativeTestIntermediatesDir)\src\))" Condition="'$(RunningOnUnix)' == 'true'" />
155         <NativeProjectOutputFoldersToCopy Include="$([System.String]::Copy('%(NativeProjectReferenceNormalized.RelativeDir)').Replace($(SourceDir),$(__NativeTestIntermediatesDir)\src\))$(Configuration)\" Condition="'$(RunningOnUnix)' != 'true'" />
156      </ItemGroup>
157
158     <Message Text= "Full native project references are :%(NativeProjectReferenceNormalized.Identity)" />
159     <Message Text= "Native binaries will be copied from :%(NativeProjectOutputFoldersToCopy.Identity)" />
160    <MSBuild Projects="$(MSBuildProjectFile)" Targets="CopyNativeProjectBinaries" Properties="NativeProjectOutputFolder=%(NativeProjectOutputFoldersToCopy.Identity)" Condition="'@(NativeProjectReference)' != '' And '$(RunningOnUnix)' != 'true'" />
161
162   </Target>
163
164   <PropertyGroup>
165      <PrepareForRunDependsOn>$(PrepareForRunDependsOn);ResetReferenceCopyLocalPaths</PrepareForRunDependsOn>
166   </PropertyGroup>
167
168   <Target Name="ResetReferenceCopyLocalPaths"
169           Condition="'@(ReferenceCopyLocalPaths)' != ''"
170           BeforeTargets="_CopyFilesMarkedCopyLocal">
171     <ItemGroup>
172        <ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.CopyLocal)' != 'true'"/>
173     </ItemGroup>
174   </Target>
175
176   <Target Name="UpdateReferenceItems"
177           BeforeTargets="BeforeResolveReferences"
178   >
179     <ItemGroup>
180       <Reference Include="$(TargetingPackPath)/*.dll" >
181         <Private>false</Private>
182       </Reference>
183     </ItemGroup>
184
185   </Target>
186
187   <Target Name="AfterBuild">
188      <Copy SourceFiles="$(AssemblyName).reflect.xml"
189            DestinationFolder="$(OutputPath)"
190        Condition="Exists('$(AssemblyName).reflect.xml')"/>
191   </Target>
192
193   <PropertyGroup>
194     <ProjectAssetsFile>$(SourceDir)Common\test_dependencies\obj\project.assets.json</ProjectAssetsFile>
195   </PropertyGroup>
196
197   <PropertyGroup Condition="'$(ReferenceSystemPrivateCoreLib)' == 'true' and '$(UsingMicrosoftNETSdk)' != 'true'">
198     <ProjectAssetsFile></ProjectAssetsFile>
199   </PropertyGroup>
200
201 </Project>