-
Notifications
You must be signed in to change notification settings - Fork 697
/
MidlShared.targets
50 lines (45 loc) · 2.83 KB
/
MidlShared.targets
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
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectMergedIdl>$(IntermediateOutputPath)Microsoft.UI.Xaml.Controls.g.idl</ProjectMergedIdl>
<ProjectUnmergedWinmd>$(IntermediateOutputPath)Unmerged\Microsoft.UI.Xaml.Controls.g.winmd</ProjectUnmergedWinmd>
</PropertyGroup>
<Target Name="MergeIDLFiles" Inputs="@(Midl)" Outputs="$(ProjectMergedIdl)" BeforeTargets="SetMidlOutputFiles;Midl">
<PropertyGroup>
<MidlLines>@(Midl->'#include <%(FullPath)>', '
')</MidlLines>
</PropertyGroup>
<WriteLinesToFile File="$(ProjectMergedIdl)" Lines="$(MidlLines)" WriteOnlyWhenDifferent="true" Overwrite="true" />
<ItemGroup>
<OriginalMidl Include="@(Midl)" />
<Midl Remove="@(OriginalMidl)" />
<Midl Include="$(ProjectMergedIdl)">
<MetadataFileName>$(ProjectUnmergedWinmd)</MetadataFileName>
<AdditionalOptions>%(AdditionalOptions) /nomidl</AdditionalOptions>
</Midl>
</ItemGroup>
<MakeDir Directories="$(IntermediateOutputPath)Unmerged" Condition="!Exists('$(IntermediateOutputPath)Unmerged')" />
</Target>
<!-- We don't want to report that we produce any WinMD files - we'll pick up the one from the idl project. -->
<ItemGroup>
<WinMDFullPath Remove="@(WinMDFullPath)" />
</ItemGroup>
<!-- We need to ensure that we've built MIDL for our project references before we attempt to use them in this project.
So we'll do that manually to guarantee that ordering. -->
<Target Name="BuildMidlProjectReferences" DependsOnTargets="BuildGenerateSourcesTraverse" AfterTargets="Rebuild" BeforeTargets="_Midl;ResolveAssemblyReferences;GetCppWinRTDirectWinMDReferences" />
<!-- The target above causes BuildGenerateSources to be called on dependencies, so declare this for the graph. -->
<ItemGroup Condition="'$(IsGraphBuild)' == 'true'">
<ProjectReferenceTargets Include="Build" Targets="BuildGenerateSources" />
</ItemGroup>
<!-- This target adds an extra WinMDFullPath entry corresponding to the project name, which we don't want, since we're building
our IDL to a different directory. We'll replace it with an empty target. -->
<Target Name="GetResolvedWinMD" DependsOnTargets="CppWinRTGetResolvedWinMD" Returns="@(WinMDFullPath)" />
<!-- We do have a WinMD file called "Microsoft.UI.Xaml.Controls.winmd", but that will later be merged into Microsoft.UI.Xaml.winmd,
so we don't want to binplace it. -->
<Target Name="RemoveUnmergedWinMD" AfterTargets="AddBinplaceItems" BeforeTargets="Binplace">
<ItemGroup>
<BinplaceItem Remove="$(MergedWinmdOutputLocation)\$(TargetName).winmd" />
</ItemGroup>
</Target>
</Project>