-
Notifications
You must be signed in to change notification settings - Fork 52
/
Build.proj
213 lines (169 loc) · 14.2 KB
/
Build.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
<?xml version="1.0" encoding="utf-8"?>
<!--
用于编译VC-LTL
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" -t:Build -m "I:\Visual Studio 2015\VC-LTL\src\Build.proj"
-->
<Project InitialTargets="ValidateSolutionConfiguration" DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(_GetProjectAllConfiguration)' != 'true'">
<SolutionDir>$(MSBuildThisFileDirectory)</SolutionDir>
<SolutionExt>.sln</SolutionExt>
<SolutionFileName>YY.Windows.CRT.sln</SolutionFileName>
<SolutionName>YY.Windows.CRT</SolutionName>
<SolutionPath>$(SolutionDir)$(SolutionFileName)</SolutionPath>
<WindowsTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</WindowsTargetPlatformVersion>
<GlobalProperties>PreferredToolArchitecture=x64;BuildingSolutionFile=true;SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)</GlobalProperties>
<UniversalCRTSdkDir Condition="'$(UniversalCRTSdkDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots@KitsRoot10)</UniversalCRTSdkDir>
<UniversalCRTSdkDir Condition="'$(UniversalCRTSdkDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots@KitsRoot10)</UniversalCRTSdkDir>
<VCInstallDir>$(VCTargetsPath)..\..\..\..\VC</VCInstallDir>
</PropertyGroup>
<ItemGroup>
<ProjectReferenceWork Include="$(MSBuildThisFileDirectory)vcruntime.msvcrt\vcruntime.msvcrt.vcxproj" OutItemName="ProjectReference"/>
<ProjectReferenceWork Include="$(MSBuildThisFileDirectory)ucrtbase.msvcrt\ucrtbase.msvcrt.vcxproj" OutItemName="ProjectReference"/>
<ProjectReferenceWork Include="$(MSBuildThisFileDirectory)vcruntime.ucrtbase\vcruntime.ucrtbase.vcxproj" OutItemName="ProjectReference"/>
<ProjectReferenceWork Include="$(MSBuildThisFileDirectory)ucrtbase.ucrtbase\ucrtbase.ucrtbase.vcxproj" OutItemName="ProjectReference"/>
<ProjectReferenceWork Include="$(MSBuildThisFileDirectory)vccorlib.wincorlib\vccorlib.wincorlib.vcxproj" OutItemName="ProjectReference"/>
</ItemGroup>
<Target Name="ValidateSolutionConfiguration">
<Message Text="正在生成解决方案配置“$(Configuration)|$(Platform)”。" />
</Target>
<Import Project="$(VCInstallDir)\Auxiliary\Build\Microsoft.VCToolsVersion.default.props" />
<Target Name="DownloadTools" BeforeTargets="Build;PackRedist">
<!--下载LibMaker-->
<DownloadFile
Condition="!Exists('$(MSBuildThisFileDirectory)Tools\LibMaker.exe')"
SourceUrl="https://github.com/Chuyu-Team/LibMaker/releases/download/v1.0.2/LibMaker.exe"
DestinationFolder="$(MSBuildThisFileDirectory)Tools" DestinationFileName="LibMaker.exe"/>
</Target>
<Target Name="Build">
<!--提取所有需要编译的配置-->
<MSBuild Projects="%(ProjectReferenceWork.Identity)" StopOnFirstFailure="True" Properties="_GetProjectAllConfiguration=true;ForceImportAfterCppTargets=$(MSBuildThisFileFullPath)" Targets="_GetProjectAllConfiguration">
<Output TaskParameter="TargetOutputs" ItemName="%(ProjectReferenceWork.OutItemName)" />
</MSBuild>
<ItemGroup>
<WindowsTargetPlatformMinVersionItem
Include="$(MSBuildThisFileFullPath)"
KeepDuplicates="false"
Condition="Exists('$(MSBuildThisFileDirectory)Tools\%(ProjectReference.WindowsTargetPlatformMinVersion)\%(ProjectReference.Platform)\Build_libucrt_shared.cmd') and !Exists('$(MSBuildThisFileDirectory)Tools\%(ProjectReference.WindowsTargetPlatformMinVersion)\%(ProjectReference.Platform)\libucrt_shared.lib')"
AdditionalProperties="WindowsTargetPlatformMinVersion=%(ProjectReference.WindowsTargetPlatformMinVersion);Platform=%(ProjectReference.Platform)"
/>
</ItemGroup>
<Message Text="%(WindowsTargetPlatformMinVersionItem.AdditionalProperties)" Importance="high"/>
<!--前置环境准备-->
<MSBuild Projects="@(WindowsTargetPlatformMinVersionItem)" StopOnFirstFailure="True" Targets="Build_libucrt_shared" BuildInParallel="True" Properties="$(GlobalProperties)"/>
<!--启动实际编译-->
<MSBuild Projects="@(ProjectReference)" StopOnFirstFailure="True" BuildInParallel="True" Properties="$(GlobalProperties)"/>
</Target>
<!-- VC-LTL Rust crate 编译准备 -->
<Target Name="PrepareToCompileRustLanguageSupport">
<ItemGroup>
<RustTargetPlatform_x86 Include="$(SolutionDir)TargetPlatform\6.0.6000.0\lib\Win32\*ucrt.lib;$(SolutionDir)TargetPlatform\6.0.6000.0\lib\Win32\*vcruntime.lib;" />
<RustTargetPlatform_x64 Include="$(SolutionDir)TargetPlatform\6.0.6000.0\lib\x64\*ucrt.lib;$(SolutionDir)TargetPlatform\6.0.6000.0\lib\x64\*vcruntime.lib;" />
<RustTargetPlatform_arm64 Include="$(SolutionDir)TargetPlatform\10.0.10240.0\lib\ARM64\*ucrt.lib;$(SolutionDir)TargetPlatform\10.0.10240.0\lib\ARM64\*vcruntime.lib;" />
<RustTargetPlatform_Common Include="$(SolutionDir)Readme.md;$(SolutionDir)LICENSE;" />
</ItemGroup>
<Copy SourceFiles="@(RustTargetPlatform_x86)" DestinationFolder="$(SolutionDir)Rust\TargetPlatform\6.0.6000.0\lib\Win32" />
<Copy SourceFiles="@(RustTargetPlatform_x64)" DestinationFolder="$(SolutionDir)Rust\TargetPlatform\6.0.6000.0\lib\x64" />
<Copy SourceFiles="@(RustTargetPlatform_arm64)" DestinationFolder="$(SolutionDir)Rust\TargetPlatform\10.0.10240.0\lib\ARM64" />
<Copy SourceFiles="@(RustTargetPlatform_Common)" DestinationFolder="$(SolutionDir)Rust" />
</Target>
<Target Name="Pack">
<PropertyGroup>
<ZipFileName Condition="'$(TagVersion)' == ''">VC-LTL-Binary.7z</ZipFileName>
<ZipFileName Condition="'$(TagVersion)' != ''">VC-LTL-$(TagVersion)-Binary.7z</ZipFileName>
</PropertyGroup>
<Delete Files="$(MSBuildThisFileDirectory)$(ZipFileName)"/>
<Exec Command="7z.exe a $(ZipFileName) config _msvcrt.h %22VC-LTL helper for *%22 TargetPlatform Readme.md Readme.osc.md Install.cmd -xr!*.objs.lib -xr!*.idb" WorkingDirectory="$(MSBuildThisFileDirectory)"/>
</Target>
<Target Name="PackRedist">
<PropertyGroup>
<ZipFileName Condition="'$(TagVersion)' == ''">VC-LTL-Redist.7z</ZipFileName>
<ZipFileName Condition="'$(TagVersion)' != ''">VC-LTL-$(TagVersion)-Redist.7z</ZipFileName>
</PropertyGroup>
<!--生成Redist相关文件-->
<PropertyGroup>
<ExcludeCRT2>**\vccorlib140.dll;**\vcruntime140.dll</ExcludeCRT2>
</PropertyGroup>
<!--生成移除了API Set的CRT DLL-->
<RemoveDir Directories="$(SolutionDir)Redist" Condition="Exists('$(SolutionDir)Redist')"/>
<MakeDir Directories="$(SolutionDir)Redist" />
<Copy SourceFiles="$(UniversalCRTSdkDir)Redist\$(WindowsTargetPlatformVersion)\ucrt\DLLs\x86\ucrtbase.dll" DestinationFiles="$(SolutionDir)Redist\x86\CRT\ucrtbase.dll" />
<Copy SourceFiles="$(UniversalCRTSdkDir)Redist\$(WindowsTargetPlatformVersion)\ucrt\DLLs\x64\ucrtbase.dll" DestinationFiles="$(SolutionDir)Redist\x64\CRT\ucrtbase.dll" />
<!--<Copy SourceFiles="$(UniversalCRTSdkDir)Redist\$(WindowsTargetPlatformVersion)\ucrt\DLLs\arm\ucrtbase.dll" DestinationFiles="$(SolutionDir)Redist\arm\CRT\ucrtbase.dll" Condition="Exists('$(UniversalCRTSdkDir)Redist\$(WindowsTargetPlatformVersion)\ucrt\DLLs\arm\ucrtbase.dll')"/>-->
<Copy SourceFiles="$(UniversalCRTSdkDir)Redist\$(WindowsTargetPlatformVersion)\ucrt\DLLs\arm64\ucrtbase.dll" DestinationFiles="$(SolutionDir)Redist\arm64\CRT\ucrtbase.dll" Condition="Exists('$(UniversalCRTSdkDir)Redist\$(WindowsTargetPlatformVersion)\ucrt\DLLs\arm64\ucrtbase.dll')"/>
<ItemGroup>
<CRTExcludeList Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\*\Microsoft.VC*.CRT\vcruntime*.dll"/>
<CRTExcludeList Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\*\Microsoft.VC*.CRT\vccorlib*.dll"/>
<CRTx86 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\x86\Microsoft.VC*.CRT\*.dll" Exclude="@(CRTExcludeList)"/>
<CRTx64 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\x64\Microsoft.VC*.CRT\*.dll" Exclude="@(CRTExcludeList)"/>
<CRTarm Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\arm\Microsoft.VC*.CRT\*.dll" Exclude="@(CRTExcludeList)"/>
<CRTarm64 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\arm64\Microsoft.VC*.CRT\*.dll" Exclude="@(CRTExcludeList)"/>
</ItemGroup>
<Copy SourceFiles="@(CRTx86)" DestinationFolder="$(SolutionDir)Redist\x86\CRT"/>
<Copy SourceFiles="@(CRTx64)" DestinationFolder="$(SolutionDir)Redist\x64\CRT"/>
<!--<Copy SourceFiles="@(CRTarm)" DestinationFolder="$(SolutionDir)Redist\arm\CRT"/>-->
<Copy SourceFiles="@(CRTarm64)" DestinationFolder="$(SolutionDir)Redist\arm64\CRT"/>
<ItemGroup>
<CXXAMPx86 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\x86\Microsoft.VC*.CXXAMP\*.dll" />
<CXXAMPx64 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\x64\Microsoft.VC*.CXXAMP\*.dll" />
<CXXAMParm Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\arm\Microsoft.VC*.CXXAMP\*.dll" />
<CXXAMParm64 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\arm64\Microsoft.VC*.CXXAMP\*.dll" />
</ItemGroup>
<Copy SourceFiles="@(CXXAMPx86)" DestinationFolder="$(SolutionDir)Redist\x86\CXXAMP" />
<Copy SourceFiles="@(CXXAMPx64)" DestinationFolder="$(SolutionDir)Redist\x64\CXXAMP" />
<!--<Copy SourceFiles="@(CXXAMParm)" DestinationFolder="$(SolutionDir)Redist\arm\CXXAMP" />-->
<Copy SourceFiles="@(CXXAMParm64)" DestinationFolder="$(SolutionDir)Redist\arm64\CXXAMP" />
<ItemGroup>
<OPENMPx86 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\x86\Microsoft.VC*.OPENMP\*.dll" />
<OPENMPx64 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\x64\Microsoft.VC*.OPENMP\*.dll" />
<OPENMParm Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\arm\Microsoft.VC*.OPENMP\*.dll" />
<OPENMParm64 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\arm64\Microsoft.VC*.OPENMP\*.dll" />
</ItemGroup>
<Copy SourceFiles="@(OPENMPx86)" DestinationFolder="$(SolutionDir)Redist\x86\OPENMP" />
<Copy SourceFiles="@(OPENMPx64)" DestinationFolder="$(SolutionDir)Redist\x64\OPENMP" />
<!--<Copy SourceFiles="@(OPENMParm)" DestinationFolder="$(SolutionDir)Redist\arm\OPENMP" />-->
<Copy SourceFiles="@(OPENMParm64)" DestinationFolder="$(SolutionDir)Redist\arm64\OPENMP" />
<ItemGroup>
<MFCx86 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\x86\Microsoft.VC*.MFC\*.dll" />
<MFCx64 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\x64\Microsoft.VC*.MFC\*.dll" />
<MFCarm Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\arm\Microsoft.VC*.MFC\*.dll" />
<MFCarm64 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\arm64\Microsoft.VC*.MFC\*.dll" />
</ItemGroup>
<Copy SourceFiles="@(MFCx86)" DestinationFolder="$(SolutionDir)Redist\x86\MFC" />
<Copy SourceFiles="@(MFCx64)" DestinationFolder="$(SolutionDir)Redist\x64\MFC" />
<!--<Copy SourceFiles="@(MFCarm)" DestinationFolder="$(SolutionDir)Redist\arm\MFC" />-->
<Copy SourceFiles="@(MFCarm64)" DestinationFolder="$(SolutionDir)Redist\arm64\MFC" />
<ItemGroup>
<MFCLOCx86 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\x86\Microsoft.VC*.MFCLOC\*.dll" />
<MFCLOCx64 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\x64\Microsoft.VC*.MFCLOC\*.dll" />
<MFCLOCarm Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\arm\Microsoft.VC*.MFCLOC\*.dll" />
<MFCLOCarm64 Include="$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\arm64\Microsoft.VC*.MFCLOC\*.dll" />
</ItemGroup>
<Copy SourceFiles="@(MFCLOCx86)" DestinationFolder="$(SolutionDir)Redist\x86\MFCLOC" />
<Copy SourceFiles="@(MFCLOCx64)" DestinationFolder="$(SolutionDir)Redist\x64\MFCLOC" />
<!--<Copy SourceFiles="@(MFCLOCarm)" DestinationFolder="$(SolutionDir)Redist\arm\MFCLOC" />-->
<Copy SourceFiles="@(MFCLOCarm64)" DestinationFolder="$(SolutionDir)Redist\arm64\MFCLOC" />
<!--移除APISet-->
<ItemGroup>
<RedistFiles Include="$(SolutionDir)Redist\**\*.dll"/>
</ItemGroup>
<Exec Command="%22$(MSBuildThisFileDirectory)Tools\LibMaker.exe%22 RemoveAPISet %22%(RedistFiles.identity)%22 %22$(MSBuildThisFileDirectory)Tools\ApiSetMap.txt%22" WorkingDirectory="$(MSBuildThisFileDirectory)"/>
<Delete Files="$(MSBuildThisFileDirectory)$(ZipFileName)"/>
<Exec Command="7z.exe a $(ZipFileName) Redist" WorkingDirectory="$(MSBuildThisFileDirectory)"/>
</Target>
<Target Name="_GetProjectAllConfiguration" Returns="@(AllProjectReferenceConfigurations)">
<!--故意过滤Debug配置 与 ARM配置,因为ARM的人实在是太少了。-->
<CreateItem
Condition="'%(ProjectConfiguration.Configuration)' != 'Debug' and '%(ProjectConfiguration.Platform)' != 'ARM'"
Include="$(MSBuildProjectFullPath)"
AdditionalMetadata="Configuration=%(ProjectConfiguration.Configuration);Platform=%(ProjectConfiguration.Platform);WindowsTargetPlatformMinVersion=%(ProjectConfiguration.WindowsTargetPlatformMinVersion);AdditionalProperties=Configuration=%(ProjectConfiguration.Configuration)%3BPlatform=%(ProjectConfiguration.Platform)%3BWindowsTargetPlatformMinVersion=%(ProjectConfiguration.WindowsTargetPlatformMinVersion)">
<Output TaskParameter="Include" ItemName="AllProjectReferenceConfigurations"/>
</CreateItem>
</Target>
<Target Name="Build_libucrt_shared" Inputs="$(MSBuildThisFileDirectory)Tools\$(WindowsTargetPlatformMinVersion)\$(Platform)\Build_libucrt_shared.cmd" Outputs="$(MSBuildThisFileDirectory)Tools\$(WindowsTargetPlatformMinVersion)\$(Platform)\libucrt_shared.lib">
<Message Text="$(WindowsTargetPlatformMinVersion)\$(Platform) 进入" Importance="high"/>
<Exec
Command="cmd /c %22$(MSBuildThisFileDirectory)Tools\$(WindowsTargetPlatformMinVersion)\$(Platform)\Build_libucrt_shared.cmd%22"
WorkingDirectory="$(MSBuildThisFileDirectory)Tools\$(WindowsTargetPlatformMinVersion)\$(Platform)"
Condition="Exists('$(MSBuildThisFileDirectory)Tools\$(WindowsTargetPlatformMinVersion)\$(Platform)\Build_libucrt_shared.cmd')"/>
</Target>
</Project>