forked from microsoft/Win2D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Win2D.proj
345 lines (271 loc) · 17.4 KB
/
Win2D.proj
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<?xml version="1.0" encoding="utf-8"?>
<!--
Master script for building all permutations of project * platform * configuration.
For best performance, enable parallel builds:
msbuild Win2D.proj /maxcpucount /nr:false
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0" DefaultTargets="Build">
<!-- Parameters that can be configured by the caller, eg. "msbuild Win2D.proj /p:BuildTests=false" -->
<PropertyGroup>
<BuildPlatforms>Win32;x64;ARM;ARM64;AnyCPU</BuildPlatforms>
<BuildConfigurations>Debug;Release</BuildConfigurations>
<BuildTests>true</BuildTests>
<BuildTools>true</BuildTools>
<BuildDocs>true</BuildDocs>
<RunTests>true</RunTests>
</PropertyGroup>
<PropertyGroup>
<ShouldRunUAPTests>false</ShouldRunUAPTests>
<ShouldRunUAPTests Condition="'$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion@CurrentBuildNumber)' >= '10000'">true</ShouldRunUAPTests>
</PropertyGroup>
<!-- Set default platforms for each project type -->
<ItemDefinitionGroup>
<UAPProject>
<Platforms>Win32;x64;ARM;ARM64</Platforms>
<BinDir>UAP</BinDir>
</UAPProject>
<AnyCPUProject>
<Platforms>AnyCPU</Platforms>
<BinDir>Windows</BinDir>
</AnyCPUProject>
</ItemDefinitionGroup>
<!-- Projects implementing the Canvas API -->
<ItemGroup>
<UAPProject Include="winrt\lib\winrt.lib.uap.vcxproj" />
<UAPProject Include="winrt\dll\winrt.dll.uap.vcxproj" />
</ItemGroup>
<!-- Test projects -->
<ItemGroup Condition="$(BuildTests)">
<UAPProject Include="winrt\test.internal\winrt.test.internal.uap.vcxproj">
<Platforms>Win32;x64</Platforms>
<AutomatedTests Condition="$(ShouldRunUAPTests)">desktop</AutomatedTests>
</UAPProject>
<UAPProject Include="winrt\test.external\winrt.test.external.uap.vcxproj">
<Platforms>Win32;x64</Platforms>
<!--
Workaround https://github.com/Microsoft/vstest/issues/1534 by temporarily
disabling running winrt.test.external unit tests from the command line.
Note these tests can still be run inside the Visual Studio 2017 IDE.
<AutomatedTests Condition="$(ShouldRunUAPTests)">store</AutomatedTests>
-->
</UAPProject>
<UAPProject Include="winrt\test.nativecomponent\winrt.test.nativecomponent.uap.vcxproj" />
<UAPProject Include="winrt\test.managed\winrt.test.managed.uap.csproj">
<Platforms>Win32;x64;ARM</Platforms>
<AutomatedTests Condition="$(ShouldRunUAPTests)">store</AutomatedTests>
<BuildInParallel>false</BuildInParallel>
</UAPProject>
<UAPProject Include="samples\SimpleSample\SimpleSample.uap.csproj" />
<UAPProject Include="samples\CoreWindowExample\CoreWindowExample.uap.csproj" />
<UAPProject Include="samples\CompositionExample\CompositionExample.csproj" />
<UAPProject Include="samples\ExampleGallery\Direct3DInterop\ExampleGallery.Direct3DInterop.uap.vcxproj">
<BuildInParallel>false</BuildInParallel>
</UAPProject>
<UAPProject Include="samples\ExampleGallery\BackgroundTask\ExampleGallery.BackgroundTask.uap.csproj" />
<UAPProject Include="samples\ExampleGallery\ExampleGallery.uap.csproj" />
</ItemGroup>
<!-- Tools projects -->
<ItemGroup Condition="$(BuildTools)">
<AnyCPUProject Include="tools\checkcode\checkcode.csproj" />
<AnyCPUProject Include="tools\codegen\exe\codegen.exe.csproj" />
<AnyCPUProject Include="tools\codegen\test\codegen.test.csproj" Condition="$(BuildTests)">
<AutomatedTests>desktop</AutomatedTests>
</AnyCPUProject>
<AnyCPUProject Include="tools\mock\exe\mock.exe.csproj" />
<AnyCPUProject Include="tools\mock\test\mock.test.csproj" Condition="$(BuildTests)">
<AutomatedTests>desktop</AutomatedTests>
</AnyCPUProject>
<AnyCPUProject Include="tools\docs\DocDiff\DocDiff.csproj" />
<AnyCPUProject Include="tools\docs\DocPreprocess\DocPreprocess.csproj" />
<AnyCPUProject Include="tools\docs\ExtractAPISurface\ExtractAPISurface.csproj" />
<AnyCPUProject Include="tools\docs\MergeIntellisense\MergeIntellisense.csproj" />
<AnyCPUProject Include="tools\exportsample\exportsample.csproj" />
</ItemGroup>
<!-- Master target just chains to a bunch of workers -->
<Target Name="Build"
DependsOnTargets="BuildProjects; CheckCode; BuildDocs; RunTests" />
<!-- TargetPlatformMinVersion 10.0.16299.0 and 10.0.10240 Platforms must be build separately. -->
<Target Name="BuildProjects" DependsOnTargets="BuildProjects10240" />
<!-- Since ARM64 requires a TargetPlatformMinVersion of at least 10.0.16299.0,
its NuGet restore and subsequent build need to run separately from the other
(10240) platforms.
In order to minimize refactoring of the existing build, this is done just after
the existing Platform targets build. This is done by adding !='ARM64' Conditions
to RestoreNuGetPackages and BuildProjects, duplicating them with =='ARM64'
Conditions, then stitching them into the target graph just after BuildProjects.
-->
<Target Name="BuildProjectsPrelim" DependsOnTargets="PrepareVersionInfo; ChooseProjectsToBuild; ChooseConfigurationsToRestore" />
<!-- Duplicate BuildProjects for just ARM64 -->
<Target Name="BuildProjects16299"
DependsOnTargets="BuildProjectsPrelim; RestoreNuGetPackages16299"
Inputs="@(ProjectsToBuild)"
Outputs="%(PlatformIndependentName)">
<Message Text="Building TargetPlatformMinVersion 16299 variants of project %(ProjectsToBuild.PlatformIndependentName):"
Importance="High" />
<Message Text=" %(ProjectsToBuild.Filename) (%(ProjectsToBuild.Configuration)|%(ProjectsToBuild.Platform))"
Importance="High"
Condition="'%(ProjectsToBuild.Platform)'=='ARM64'" />
<MSBuild Projects="@(ProjectsToBuild)"
BuildInParallel="%(ProjectsToBuild.BuildInParallel)"
Properties="IncludeVersionInfo=true"
Condition="'%(ProjectsToBuild.Platform)'=='ARM64'" />
</Target>
<!-- Use batching to build each project in turn -->
<Target Name="BuildProjects10240"
DependsOnTargets="BuildProjectsPrelim; BuildProjects16299; RestoreNuGetPackages10240"
Inputs="@(ProjectsToBuild)"
Outputs="%(PlatformIndependentName)">
<Message Importance="High" Text="Building TargetPlatformMinVersion 10240 variants of project %(ProjectsToBuild.PlatformIndependentName):" />
<Message Importance="High" Text=" %(ProjectsToBuild.Filename) (%(ProjectsToBuild.Configuration)|%(ProjectsToBuild.Platform))" Condition="'%(ProjectsToBuild.Platform)'!='ARM64'" />
<!-- All the variants (platform and configuration) of most projects can be built in parallel -->
<MSBuild Projects="@(ProjectsToBuild)"
BuildInParallel="%(ProjectsToBuild.BuildInParallel)"
Properties="IncludeVersionInfo=true"
Condition="'%(ProjectsToBuild.Platform)'!='ARM64'" />
</Target>
<Target Name="ChooseProjectsToBuild">
<ItemGroup>
<!-- Expand parameter properties into item groups, so we can batch over them -->
<BuildPlatform Include="$(BuildPlatforms)" />
<BuildConfiguration Include="$(BuildConfigurations)" />
<!-- Generate the cartesian product of all projects * all platforms we are building -->
<CandidateProjects Include="@(UAPProject);@(AnyCPUProject)">
<Platform>%(BuildPlatform.Identity)</Platform>
</CandidateProjects>
<!-- Filter the list to include only project/platform pairs where the project actually supports that platform -->
<FilteredProjects Include="@(CandidateProjects)" Condition="$([System.String]::new('%(CandidateProjects.Platforms)').Contains('%(CandidateProjects.Platform)'))" />
<!-- Generate the cartesian product of our filtered project list * the configurations we are building -->
<ProjectsPerConfig Include="@(FilteredProjects)">
<Configuration>%(BuildConfiguration.Identity)</Configuration>
</ProjectsPerConfig>
<!-- Move platform and configuration into the AdditionalProperties metadata, and generate a
platform independent name that will be the same for Windows, Phone and UAP project variants -->
<ProjectsToBuild Include="@(ProjectsPerConfig)">
<AdditionalProperties>Platform=%(ProjectsPerConfig.Platform);Configuration=%(ProjectsPerConfig.Configuration)</AdditionalProperties>
<PlatformIndependentName>$([System.String]::new('%(ProjectsPerConfig.Filename)').Replace('Windows', '').Replace('Phone', '').Replace('uap', '').TrimEnd('.'))</PlatformIndependentName>
<BuildInParallel Condition="'%(ProjectsPerConfig.BuildInParallel)' == ''">true</BuildInParallel>
</ProjectsToBuild>
</ItemGroup>
</Target>
<Target Name="PrepareVersionInfo">
<MakeDir Directories="obj" />
<!-- Read the current Win2D version number -->
<ReadLinesFromFile File="build\nuget\VERSION">
<Output TaskParameter="Lines" PropertyName="Win2DVersion" />
</ReadLinesFromFile>
<!-- Read the SHA-1 hash for git HEAD, so we can later identify exactly what code went into this build -->
<Exec Command="git rev-parse --verify HEAD > obj\Win2D.githash.txt" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="GitExitCode" />
</Exec>
<WriteLinesToFile Condition="$(GitExitCode) != 0" File ="obj\Win2D.githash.txt" Lines="unknown git hash" />
<ReadLinesFromFile File="obj\Win2D.githash.txt">
<Output TaskParameter="Lines" PropertyName="GitHash" />
</ReadLinesFromFile>
<!-- Generate AssemblyVersion.cs, which adds the latest version info to managed assembly outputs -->
<ItemGroup>
<AssemblyVersionCode Include="[assembly: System.Reflection.AssemblyVersion("$(Win2DVersion)")]" />
<AssemblyVersionCode Include="[assembly: System.Reflection.AssemblyFileVersion("$(Win2DVersion)")]" />
<AssemblyVersionCode Include="[assembly: System.Reflection.AssemblyInformationalVersionAttribute("$(Win2DVersion) ($(GitHash))")]" />
</ItemGroup>
<ReadLinesFromFile File="obj\AssemblyVersion.cs">
<Output TaskParameter="Lines" ItemName="ExistingAssemblyVersion" />
</ReadLinesFromFile>
<WriteLinesToFile Condition="@(AssemblyVersionCode) != @(ExistingAssemblyVersion)" File="obj\AssemblyVersion.cs" Lines="@(AssemblyVersionCode)" Overwrite="true" />
<!-- Also generate DllVersion.h, which adds version info to native DLLs -->
<ItemGroup>
<DllVersionCode Include="#define DLL_VERSION $(Win2DVersion.Replace('.', ','))" />
<DllVersionCode Include="#define DLL_VERSION_STRING "$(Win2DVersion)"" />
<DllVersionCode Include="#define DLL_VERSION_STRING_LONG "$(Win2DVersion) ($(GitHash))"" />
</ItemGroup>
<ReadLinesFromFile File="obj\DllVersion.h">
<Output TaskParameter="Lines" ItemName="ExistingDllVersion" />
</ReadLinesFromFile>
<WriteLinesToFile Condition="@(DllVersionCode) != @(ExistingDllVersion)" File="obj\DllVersion.h" Lines="@(DllVersionCode)" Overwrite="true" />
</Target>
<!-- Make sure all our source files have the right copyright and formatting -->
<Target Name="CheckCode"
Condition="$(BuildTools) and $(BuildPlatforms.Contains('AnyCPU'))">
<Message Importance="High" Text="Checking copyright banners and source code formatting" />
<MSBuild Projects="tools\checkcode\RunCodeChecks.proj" />
</Target>
<!-- Build the reference documentation -->
<UsingTask TaskName="SetEnv" AssemblyFile="$(VCTargetsPath)Microsoft.Build.CppTasks.Common.dll"/>
<Target Name="BuildDocs"
Condition="$(BuildDocs) and
$(BuildTools) and
$(BuildPlatforms.Contains('AnyCPU')) and
$(BuildPlatforms.Contains('Win32')) and
$(BuildConfigurations.Contains('Release'))">
<Message Importance="High" Text="Building documentation" />
<!-- unset SHFBROOT, so that BuildDocs only picks up the version of
sandcastle installed via nuget -->
<SetEnv Name="SHFBROOT" Prefix="false" />
<!-- Use <Exec> rather than <MSBuild> here, since we want BuildDocs.proj to
be isolated from the environment that's formed around running
Win2D.proj up to this point, and to suppress the Sandcastle
false positive warning BHT0001 -->
<Exec Command=""$(MSBuildBinPath)\msbuild" $(MSBuildThisFileDirectory)tools\docs\BuildDocs.proj"
IgnoreStandardErrorWarningFormat="true"
CustomErrorRegularExpression=": error "
CustomWarningRegularExpression=": warning (?!BHT0001)" />
</Target>
<!-- Run the automated tests -->
<PropertyGroup>
<_VsTestPathUnderCommonTools>..\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe</_VsTestPathUnderCommonTools>
<_VsTest Condition="Exists('$(VS120COMNTOOLS)$(_VsTestPathUnderCommonTools)')">$(VS120COMNTOOLS)$(_VsTestPathUnderCommonTools)</_VsTest>
<_VsTest Condition="Exists('$(VS140COMNTOOLS)$(_VsTestPathUnderCommonTools)')">$(VS140COMNTOOLS)$(_VsTestPathUnderCommonTools)</_VsTest>
<_VsTest Condition="Exists('$(VS150COMNTOOLS)$(_VsTestPathUnderCommonTools)')">$(VS150COMNTOOLS)$(_VsTestPathUnderCommonTools)</_VsTest>
<_VsTest Condition="Exists('$(VS160COMNTOOLS)$(_VsTestPathUnderCommonTools)')">$(VS160COMNTOOLS)$(_VsTestPathUnderCommonTools)</_VsTest>
<VsTest Condition="'$(_VsTest)' != ''">"$([System.IO.Path]::GetFullPath('$(_VsTest)'))"</VsTest>
</PropertyGroup>
<Target Name="RunTests"
Condition="$(BuildTests) and $(RunTests)"
DependsOnTargets="ChooseProjectsToBuild; ChooseTestsToRun"
Inputs="@(TestProjects)"
Outputs="%(TestProjects.TestAppX)">
<PropertyGroup>
<PowerShellExe Condition=" '$(PowerShellExe)'=='' ">%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe</PowerShellExe>
</PropertyGroup>
<Error Text="vstest.console.exe not found, please specify using the VsTest property" Condition="'$(VsTest)' == ''" />
<Message Importance="High" Text="Running tests: %(TestProjects.Filename) (%(TestProjects.Configuration)|%(TestProjects.Platform))" />
<Exec Command="$(PowerShellExe) -NonInteractive -executionpolicy Unrestricted -command "& { get-appxpackage -name E2C40EB9-8CCE-48B1-9A5C-4C8CA4999631 | remove-appxpackage } "" ConsoleToMsBuild="true" ContinueOnError="ErrorAndContinue" IgnoreStandardErrorWarningFormat="true"/>
<Exec Command="$(VsTest) %(TestProjects.TestBinary)%(TestProjects.TestArgs)" ContinueOnError="ErrorAndContinue" IgnoreStandardErrorWarningFormat="true" />
</Target>
<Target Name="ChooseTestsToRun">
<ItemGroup>
<TestProjects Include="@(ProjectsToBuild)" Condition="%(ProjectsToBuild.AutomatedTests) != '' and %(ProjectsToBuild.Platform) != ARM and %(ProjectsToBuild.Platform) != ARM64">
<!-- Remap Win32 to x86 -->
<TestPlatform Condition="%(ProjectsToBuild.Platform) == Win32">x86</TestPlatform>
<TestPlatform Condition="%(ProjectsToBuild.Platform) != Win32">%(ProjectsToBuild.Platform)</TestPlatform>
<!-- Work out where the test binaries are located -->
<TestPath>bin\%(ProjectsToBuild.BinDir)%(TestProjects.TestPlatform)\%(ProjectsToBuild.Configuration)</TestPath>
<TestAppX Condition="%(ProjectsToBuild.Configuration) == Release">%(ProjectsToBuild.Filename)_1.0.0.0_%(ProjectsToBuild.Platform)</TestAppX>
<TestAppX Condition="%(ProjectsToBuild.Configuration) != Release">%(ProjectsToBuild.Filename)_1.0.0.0_%(ProjectsToBuild.Platform)_%(ProjectsToBuild.Configuration)</TestAppX>
<!-- Binaries can be either a .dll for desktop tests, or .appx for store app tests -->
<TestBinary Condition="%(ProjectsToBuild.AutomatedTests) == desktop">%(TestProjects.TestPath)\%(ProjectsToBuild.Filename)\%(ProjectsToBuild.Filename).dll</TestBinary>
<TestBinary Condition="%(ProjectsToBuild.AutomatedTests) == store">%(TestProjects.TestPath)\%(ProjectsToBuild.Filename)\AppPackages\%(TestProjects.TestAppX)_Test\%(TestProjects.TestAppX).appx</TestBinary>
<!-- Do we need the /Platform or /InIsolation arguments for this test project? -->
<TestArgs Condition="%(ProjectsToBuild.Platform) == x64">%(TestProjects.TestArgs) /Platform:x64</TestArgs>
<TestArgs Condition="%(ProjectsToBuild.Platform) == x64 or %(ProjectsToBuild.AutomatedTests) == store">%(TestProjects.TestArgs) /InIsolation</TestArgs>
</TestProjects>
</ItemGroup>
</Target>
<Target Name="ChooseConfigurationsToRestore">
<ItemGroup>
<ProjectToRestore Include="$(MSBuildThisFileDirectory)Win2D.uap.sln" />
<!-- Expand parameter properties into item groups, so we can batch over them -->
<BuildPlatform Include="$(BuildPlatforms)" />
<BuildConfiguration Include="$(BuildConfigurations)" />
<!-- Generate the cartesian product of all platforms * configurations that we are building -->
<ConfigToRestore Include="@(ProjectToRestore)">
<Configuration>%(BuildConfiguration.Identity)</Configuration>
</ConfigToRestore>
<NuGetRestore Include="@(ConfigToRestore)" Condition="%(BuildPlatform.Identity) != AnyCPU">
<Platform>%(BuildPlatform.Identity)</Platform>
</NuGetRestore>
<!-- Internal Microsoft builds can optionally consume the Windows SDK via NuGet -->
<NuGetRestore Include="build\pkges\packages.config" Condition="'$(UseNuGetSDK)' != ''" />
</ItemGroup>
</Target>
<Import Project="$(MsBuildThisFileDirectory)build\nuget-restore.targets" />
</Project>