Skip to content

Commit

Permalink
Add ARM64 support (#722)
Browse files Browse the repository at this point in the history
* Add ARM64 entries where ARM entries are

This change adds ARM64 entries where ARM(32) entries already exist.

In the case of certain test configurations, ARM is set to use the x86
configuration so ARM64 imitates this.

Since winrt.test.managed.uap.csproj is not compatible with .NET Native
and the ARM64 UWP does not support .NET other than Native, it is
omitted.

* Upgrade DirectXTK_UWP dep to 2019.4.26.1

This takes care of unresolved externals in the Direct3DInterop library
by updating to a version of directxtk_uwp that has ARM64 support.

* Bump UniversalWindowsPlatform to 6.2.8

This change fixes the Nuget Restore error
The local source 'C:\Users\jkunkee\source\repos\Win2D\bin' doesn't exist.

Incidentally, it also pulls in a version with official ARM64 support:
https://github.com/Microsoft/dotnet/blob/master/releases/UWP/net-native2.2/README.md#uwp-627-march-12th-2019

* Set TargetPlatformMinVersion to 10.0.16299.0 for ARM64

This change fixes errors about ARM64 not being supported before 16299.

* Work around NuGet TargetPlatformMinVersion limits

This change accomodates Visual Studio's lack of support for multiple
TargetPlatformMinVersion values in one project by separating the NuGet
restore and the build operations that depend on it.

UWAs that intend to support ARM64 must have a TargetPlatformMinVersion
of at least 10.0.16299.0, while UWAs that intend to support all past
versions of Windows 10 must set it to 10.0.10240.0. The Win2D sample
and test UWAs need to do both, but NuGet restore only takes one. This
this change copies the restore and build operations into two such that
the 16299 restore runs, the 16299 (ARM64) builds run, then the 10240
restore runs, and finally the 10240 builds run. This builds
everything, including tests, for all architectures. One side effect is
that the NuGet package state is left in a state that supports building
the most common Platforms from Visual Studio.

A corrolary to this is that exported sample projects will require
similar arrangements to build for both full Windows 10 backwards
compatibility and for ARM64.

Since BuildDocs.proj also uses NuGet Restore, it specifically uses the
more general 10240 restore target.

* Drop WorkAroundNuGetRestoreBug

As of Visual Studio 2017 and this point in the commit history, this
workaround is no longer necessary.
  • Loading branch information
azchohfi authored and shawnhar committed Sep 6, 2019
1 parent e7c0040 commit 52f7a0b
Show file tree
Hide file tree
Showing 18 changed files with 278 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -105,7 +105,7 @@ appropriate test suites.
To validate your changes, run "msbuild /m /nr:false Win2D.proj" from a
Visual Studio Developer Command Prompt. This will:

- Build all flavors of all projects (debug, release, x86, x64, and ARM)
- Build all flavors of all projects (debug, release, x86, x64, ARM, and ARM64)
- Run all automated tests
- Generate updated reference documentation
- Make sure all source files include the correct MIT copyright header
Expand Down
66 changes: 45 additions & 21 deletions Win2D.proj
Expand Up @@ -12,7 +12,7 @@

<!-- Parameters that can be configured by the caller, eg. "msbuild Win2D.proj /p:BuildTests=false" -->
<PropertyGroup>
<BuildPlatforms>Win32;x64;ARM;AnyCPU</BuildPlatforms>
<BuildPlatforms>Win32;x64;ARM;ARM64;AnyCPU</BuildPlatforms>
<BuildConfigurations>Debug;Release</BuildConfigurations>
<BuildTests>true</BuildTests>
<BuildTools>true</BuildTools>
Expand All @@ -28,7 +28,7 @@
<!-- Set default platforms for each project type -->
<ItemDefinitionGroup>
<UAPProject>
<Platforms>Win32;x64;ARM</Platforms>
<Platforms>Win32;x64;ARM;ARM64</Platforms>
<BinDir>UAP</BinDir>
</UAPProject>
<AnyCPUProject>
Expand Down Expand Up @@ -61,6 +61,7 @@
</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>
Expand Down Expand Up @@ -98,17 +99,53 @@
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="BuildProjects"
DependsOnTargets="PrepareVersionInfo; ChooseProjectsToBuild; ChooseConfigurationsToRestore; RestoreNuGetPackages; WorkAroundNuGetRestoreBug"
<Target Name="BuildProjects10240"
DependsOnTargets="BuildProjectsPrelim; BuildProjects16299; RestoreNuGetPackages10240"
Inputs="@(ProjectsToBuild)"
Outputs="%(PlatformIndependentName)">

<Message Importance="High" Text="Building all variants of project %(ProjectsToBuild.PlatformIndependentName):" />
<Message Importance="High" Text=" %(ProjectsToBuild.Filename) (%(ProjectsToBuild.Configuration)|%(ProjectsToBuild.Platform))" />
<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" />
<MSBuild Projects="@(ProjectsToBuild)"
BuildInParallel="%(ProjectsToBuild.BuildInParallel)"
Properties="IncludeVersionInfo=true"
Condition="'%(ProjectsToBuild.Platform)'!='ARM64'" />
</Target>


Expand Down Expand Up @@ -257,7 +294,7 @@

<Target Name="ChooseTestsToRun">
<ItemGroup>
<TestProjects Include="@(ProjectsToBuild)" Condition="%(ProjectsToBuild.AutomatedTests) != '' and %(ProjectsToBuild.Platform) != ARM">
<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>
Expand Down Expand Up @@ -303,19 +340,6 @@
</Target>


<!--
Workaround https://github.com/Microsoft/vstest/issues/1533 by deleting the
unnecessary assets.json file after running nuget restore on winrt.test.external.
-->
<Target Name="WorkAroundNuGetRestoreBug">
<ItemGroup>
<FileToDelete Include="obj\winrt.test.external.uap\**\project.assets.json" />
</ItemGroup>

<Delete Files="@(FileToDelete)" />
</Target>


<Import Project="$(MsBuildThisFileDirectory)build\nuget-restore.targets" />

</Project>

0 comments on commit 52f7a0b

Please sign in to comment.