blob: 834b27c86d42c852f60f520f84971b5c08b84a67 [file] [log] [blame]
Steve Dower21a92f82019-06-14 08:29:20 -07001<?xml version="1.0" encoding="utf-8"?>
2<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="Py_IntDir">
3 <Import Project="python.props" Condition="$(__Python_Props_Imported) != 'true'" />
Steve Dower65e4cb12014-11-22 12:54:57 -08004 <PropertyGroup Label="Globals">
Steve Dower21a92f82019-06-14 08:29:20 -07005 <__PyProject_Props_Imported>true</__PyProject_Props_Imported>
Stefan Krah318c56c2012-06-24 19:04:35 +02006 <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
Steve Dower65e4cb12014-11-22 12:54:57 -08007 <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
8 <OutDir>$(BuildPath)</OutDir>
Steve Dowerde9fb282015-07-27 14:56:58 -07009 <OutDir Condition="!HasTrailingSlash($(OutDir))">$(OutDir)\</OutDir>
Steve Dower6ed63f32016-07-24 18:03:22 -070010 <Py_IntDir Condition="'$(Py_IntDir)' == ''">$(MSBuildThisFileDirectory)obj\</Py_IntDir>
Steve Dower2084b302017-10-05 13:35:36 -070011 <IntDir>$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\$(ProjectName)\</IntDir>
Steve Dower0d2a9082017-11-04 16:28:47 -070012 <IntDir>$(IntDir.Replace(`\\`, `\`))</IntDir>
Steve Dower65e4cb12014-11-22 12:54:57 -080013 <TargetName Condition="'$(TargetName)' == ''">$(ProjectName)</TargetName>
14 <TargetName>$(TargetName)$(PyDebugExt)</TargetName>
15 <GenerateManifest>false</GenerateManifest>
16 <EmbedManifest>false</EmbedManifest>
17 <SupportPGO Condition="'$(SupportPGO)' == ''">true</SupportPGO>
Steve Dowerbb240872015-02-05 22:08:48 -080018 <SupportSigning Condition="'$(SupportSigning)' == ''">true</SupportSigning>
19 <SupportSigning Condition="'$(Configuration)' == 'Debug'">false</SupportSigning>
20 <SupportSigning Condition="'$(ConfigurationType)' == 'StaticLibrary'">false</SupportSigning>
Zachary Ware6373ba52014-03-17 15:57:38 -050021 </PropertyGroup>
Steve Dower65e4cb12014-11-22 12:54:57 -080022
23 <PropertyGroup>
24 <_DebugPreprocessorDefinition>NDEBUG;</_DebugPreprocessorDefinition>
25 <_DebugPreprocessorDefinition Condition="$(Configuration) == 'Debug'">_DEBUG;</_DebugPreprocessorDefinition>
26 <_PlatformPreprocessorDefinition>_WIN32;</_PlatformPreprocessorDefinition>
27 <_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64'">_WIN64;_M_X64;</_PlatformPreprocessorDefinition>
28 <_PydPreprocessorDefinition Condition="$(TargetExt) == '.pyd'">Py_BUILD_CORE_MODULE;</_PydPreprocessorDefinition>
Steve Dowerdcbaa1b2020-07-06 17:32:00 +010029 <_Py3NamePreprocessorDefinition>PY3_DLLNAME=L"$(Py3DllName)";</_Py3NamePreprocessorDefinition>
Brian Curtin401f9f32012-05-13 11:19:23 -050030 </PropertyGroup>
Brian Curtin401f9f32012-05-13 11:19:23 -050031 <ItemDefinitionGroup>
32 <ClCompile>
Victor Stinner27e2d1f2018-11-01 00:52:28 +010033 <AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)PC;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Steve Dowerdcbaa1b2020-07-06 17:32:00 +010034 <PreprocessorDefinitions>WIN32;$(_Py3NamePreprocessorDefinition);$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PydPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
Steve Dower21a92f82019-06-14 08:29:20 -070035
Brian Curtin401f9f32012-05-13 11:19:23 -050036 <Optimization>MaxSpeed</Optimization>
Brian Curtin401f9f32012-05-13 11:19:23 -050037 <IntrinsicFunctions>true</IntrinsicFunctions>
Brian Curtin401f9f32012-05-13 11:19:23 -050038 <StringPooling>true</StringPooling>
Steve Dower65e4cb12014-11-22 12:54:57 -080039 <ExceptionHandling></ExceptionHandling>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070040 <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
Brian Curtin401f9f32012-05-13 11:19:23 -050041 <FunctionLevelLinking>true</FunctionLevelLinking>
42 <WarningLevel>Level3</WarningLevel>
43 <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
44 <CompileAs>Default</CompileAs>
Steve Dower65e4cb12014-11-22 12:54:57 -080045 <SuppressStartupBanner>true</SuppressStartupBanner>
46 <WholeProgramOptimization>true</WholeProgramOptimization>
Victor Stinnera05bef42018-10-26 15:10:29 +020047 <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OnlyExplicitInline</InlineFunctionExpansion>
48 <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OnlyExplicitInline</InlineFunctionExpansion>
Inada Naokifedd86d2021-02-12 09:06:47 +090049 <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
Steve Dower65e4cb12014-11-22 12:54:57 -080050 </ClCompile>
51 <ClCompile Condition="$(Configuration) == 'Debug'">
52 <Optimization>Disabled</Optimization>
53 <WholeProgramOptimization>false</WholeProgramOptimization>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070054 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
Brian Curtin401f9f32012-05-13 11:19:23 -050055 </ClCompile>
Zachary Ware4c5ad942016-01-29 19:08:55 -060056 <ClCompile Condition="$(ICCBuild) == 'true'">
57 <FloatingPointModel>Strict</FloatingPointModel>
58 </ClCompile>
Brian Curtin401f9f32012-05-13 11:19:23 -050059 <Link>
60 <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
61 <GenerateDebugInformation>true</GenerateDebugInformation>
62 <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
63 <SubSystem>Windows</SubSystem>
Christian Heimesf3bf35e2013-11-20 17:43:23 +010064 <RandomizedBaseAddress>true</RandomizedBaseAddress>
65 <DataExecutionPrevention>true</DataExecutionPrevention>
Steve Dower65e4cb12014-11-22 12:54:57 -080066 <SuppressStartupBanner>true</SuppressStartupBanner>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070067 <IgnoreSpecificDefaultLibraries>LIBC;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
Brian Curtin401f9f32012-05-13 11:19:23 -050068 <TargetMachine>MachineX86</TargetMachine>
Steve Dower65e4cb12014-11-22 12:54:57 -080069 <TargetMachine Condition="'$(Platform)' == 'x64'">MachineX64</TargetMachine>
Paul Monson8a1657b2019-02-14 08:31:30 -080070 <TargetMachine Condition="'$(Platform)'=='ARM'">MachineARM</TargetMachine>
Paul Monsonf96e7fd2019-05-17 10:07:24 -070071 <TargetMachine Condition="'$(Platform)'=='ARM64'">MachineARM64</TargetMachine>
Steve Dower65e4cb12014-11-22 12:54:57 -080072 <ProfileGuidedDatabase Condition="$(SupportPGO)">$(OutDir)$(TargetName).pgd</ProfileGuidedDatabase>
73 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
74 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">PGInstrument</LinkTimeCodeGeneration>
75 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">PGUpdate</LinkTimeCodeGeneration>
Paul Monson8a1657b2019-02-14 08:31:30 -080076 <AdditionalDependencies>advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
Austin Lambb4af6292021-02-19 15:27:01 -080077 <AdditionalOptions Condition="$(Configuration) != 'Debug'">/OPT:REF,NOICF %(AdditionalOptions)</AdditionalOptions>
Brian Curtin401f9f32012-05-13 11:19:23 -050078 </Link>
Steve Dower65e4cb12014-11-22 12:54:57 -080079 <Lib>
80 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">true</LinkTimeCodeGeneration>
81 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">true</LinkTimeCodeGeneration>
82 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">true</LinkTimeCodeGeneration>
83 </Lib>
Brian Curtin401f9f32012-05-13 11:19:23 -050084 <ResourceCompile>
Steve Dowerb0660582016-04-06 12:35:24 -070085 <AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Nikita Nemkin4efc3362020-06-24 00:05:57 +050086 <PreprocessorDefinitions>ORIGINAL_FILENAME=\"$(TargetName)$(TargetExt)\";FIELD3=$(Field3Value);$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
Steve Dower65e4cb12014-11-22 12:54:57 -080087 <Culture>0x0409</Culture>
Brian Curtin401f9f32012-05-13 11:19:23 -050088 </ResourceCompile>
Steve Dower65e4cb12014-11-22 12:54:57 -080089 <Midl>
90 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
91 <MkTypLibCompatible>true</MkTypLibCompatible>
92 <SuppressStartupBanner>true</SuppressStartupBanner>
93 <TargetEnvironment>Win32</TargetEnvironment>
94 <TargetEnvironment Condition="'$(Platform)' == 'x64'">X64</TargetEnvironment>
Steve Dowerdf450d12016-07-16 16:17:33 -070095 <OutputDirectory>$(IntDir)</OutputDirectory>
96 <InterfaceIdentifierFileName>$(MSBuildProjectName)_i.c</InterfaceIdentifierFileName>
97 <ProxyFileName>$(MSBuildProjectName)_p.c</ProxyFileName>
Steve Dower65e4cb12014-11-22 12:54:57 -080098 </Midl>
Brian Curtin401f9f32012-05-13 11:19:23 -050099 </ItemDefinitionGroup>
Steve Dower65e4cb12014-11-22 12:54:57 -0800100
Steve Dower65e4cb12014-11-22 12:54:57 -0800101 <UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
102 <ParameterGroup>
103 <FileName Required="true" />
104 </ParameterGroup>
105 <Task>
Jeremy Klothfa532942018-10-23 05:41:48 -0600106 <Using Namespace="System.Diagnostics"/>
107 <Using Namespace="System.IO"/>
108 <Using Namespace="System.Runtime.InteropServices"/>
109 <Using Namespace="System.Text"/>
110 <Code Type="Method" Language="cs">
Steve Dower65e4cb12014-11-22 12:54:57 -0800111<![CDATA[
Jeremy Klothfa532942018-10-23 05:41:48 -0600112[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
113public static extern bool QueryFullProcessImageName([In]IntPtr hProcess, [In]int dwFlags,
114 [Out]StringBuilder lpExeName, ref int lpdwSize);
115public override bool Execute() {
116 string fullPath = Path.GetFullPath(FileName);
117 Log.LogMessage("Looking for " + fullPath, MessageImportance.Normal);
118 foreach (Process p in Process.GetProcesses()) {
119 try {
120 int pathLength = 32768;
121 StringBuilder pathBuilder = new StringBuilder(pathLength);
122 if (QueryFullProcessImageName(p.Handle, 0, pathBuilder, ref pathLength)) {
123 string exeName = Path.GetFullPath(pathBuilder.ToString());
124 Log.LogMessage("Found running process: " + exeName, MessageImportance.Low);
125 if (fullPath.Equals(exeName, StringComparison.OrdinalIgnoreCase)) {
126 Log.LogMessage("Terminating " + exeName, MessageImportance.High);
127 p.Kill();
128 }
129 }
130 } catch {
Steve Dower65e4cb12014-11-22 12:54:57 -0800131 }
Steve Dower65e4cb12014-11-22 12:54:57 -0800132 }
Jeremy Klothfa532942018-10-23 05:41:48 -0600133 return true;
Steve Dower65e4cb12014-11-22 12:54:57 -0800134}
135]]>
136 </Code>
137 </Task>
138 </UsingTask>
Steve Dower21a92f82019-06-14 08:29:20 -0700139
Steve Dowerf4f10802014-12-12 13:45:25 -0800140 <Target Name="KillPython" BeforeTargets="PrepareForBuild" Condition="'$(KillPython)' == 'true'">
Steve Dower940f6a82015-10-31 12:17:11 -0700141 <Message Text="Killing any running python$(PyDebugExt)$(PyTestExt).exe instances..." Importance="high" />
142 <KillPython FileName="$(OutDir)python$(PyDebugExt)$(PyTestExt).exe" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800143 </Target>
Steve Dower21a92f82019-06-14 08:29:20 -0700144
Steve Dower65e4cb12014-11-22 12:54:57 -0800145 <!--
146 A default target to handle msbuild pcbuild.proj /t:CleanAll.
Steve Dower21a92f82019-06-14 08:29:20 -0700147
Steve Dower65e4cb12014-11-22 12:54:57 -0800148 Some externals projects don't respond to /t:Clean, so we invoke
149 CleanAll on them when we really want to clean up.
150 -->
151 <Target Name="CleanAll" DependsOnTargets="Clean">
152 <MSBuild Projects="@(ProjectReference->'%(FullPath)')"
153 Properties="Configuration=$(Configuration);Platform=$(Platform)"
154 BuildInParallel="true"
155 StopOnFirstFailure="false"
156 Condition="Exists(%(FullPath))"
157 Targets="CleanAll" />
158 </Target>
Steve Dowerbb240872015-02-05 22:08:48 -0800159
Steve Dower5fcd5e62017-09-06 10:01:38 -0700160 <Target Name="CopyPGCFiles" BeforeTargets="PrepareForBuild" Condition="$(Configuration) == 'PGUpdate'">
161 <ItemGroup>
162 <_PGCFiles Include="$(OutDir)instrumented\$(TargetName)!*.pgc" />
163 <_PGDFile Include="$(OutDir)instrumented\$(TargetName).pgd" />
164 <_CopyFiles Include="@(_PGCFiles);@(_PGDFile)" Condition="Exists(%(FullPath))" />
165 </ItemGroup>
166 <Delete Files="@(_CopyFiles->'$(OutDir)%(Filename)%(Extension)')" />
167 <Error Text="PGO run did not succeed (no $(TargetName)!*.pgc files) and there is no data to merge"
168 Condition="$(RequirePGCFiles) == 'true' and @(_PGCFiles) == ''" />
169 <Copy SourceFiles="@(_CopyFiles)"
170 DestinationFolder="$(OutDir)"
171 UseHardLinksIfPossible="true"
172 OverwriteReadOnlyFiles="true" />
173 </Target>
174
Steve Dower425ec152016-10-09 20:18:52 -0700175 <PropertyGroup>
Steve Dower5fcd5e62017-09-06 10:01:38 -0700176 <SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\$(DefaultWindowsSDKVersion)\x86</SdkBinPath>
177 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\x86</SdkBinPath>
Steve Dower425ec152016-10-09 20:18:52 -0700178 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
179 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
180 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\</SdkBinPath>
Steve Dowerdb6434c2020-11-03 22:31:49 +0000181 <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificate)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /a /n "$(SigningCertificate)" /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d "Python $(PythonVersion)"</_SignCommand>
182 <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificateSha1)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /a /sha1 "$(SigningCertificateSha1)" /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d "Python $(PythonVersion)"</_SignCommand>
Steve Dower425ec152016-10-09 20:18:52 -0700183 <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
Steve Dowerbb240872015-02-05 22:08:48 -0800184 </PropertyGroup>
Steve Dowerd3bbc522018-12-21 13:48:18 -0800185
186 <Target Name="_SignBuild" AfterTargets="AfterBuild" Condition="'$(_SignCommand)' != '' and $(SupportSigning)">
Steve Dowerbb240872015-02-05 22:08:48 -0800187 <Error Text="Unable to locate signtool.exe. Set /p:SignToolPath and rebuild" Condition="'$(_SignCommand)' == ''" />
188 <Exec Command='$(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)"' ContinueOnError="false" />
189 </Target>
Steve Dower2dd41742020-03-11 11:18:12 +0000190
191
Steve Dower894adc12020-03-11 23:24:30 +0000192 <Target Name="FindVCRedistDir">
193 <!-- Hard coded path for VS 2015 -->
Steve Dower2dd41742020-03-11 11:18:12 +0000194 <PropertyGroup Condition="$(PlatformToolset) == 'v140'">
195 <VCRedistDir>$(VCInstallDir)\redist\</VCRedistDir>
Steve Dower894adc12020-03-11 23:24:30 +0000196 </PropertyGroup>
197
198 <!-- Search for version number in some broken Build Tools installs -->
199 <ItemGroup Condition="$(VCRedistDir) == '' and $(VCToolsRedistVersion) == ''">
200 <_RedistFiles Include="$(VCInstallDir)\Redist\MSVC\*\*.*" />
201 </ItemGroup>
202 <PropertyGroup Condition="$(VCRedistDir) == '' and $(VCToolsRedistVersion) == ''">
203 <_RedistDir>%(_RedistFiles.Directory)</_RedistDir>
204 <VCToolsRedistVersion>$([System.IO.Path]::GetFileName($(_RedistDir.Trim(`\`))))</VCToolsRedistVersion>
205 </PropertyGroup>
206
207 <!-- Use correct path for VS 2017 and later -->
208 <PropertyGroup Condition="$(VCRedistDir) == ''">
209 <VCRedistDir>$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\</VCRedistDir>
210 </PropertyGroup>
211
212 <PropertyGroup>
Steve Dower2dd41742020-03-11 11:18:12 +0000213 <VCRedistDir Condition="$(Platform) == 'Win32'">$(VCRedistDir)x86\</VCRedistDir>
214 <VCRedistDir Condition="$(Platform) != 'Win32'">$(VCRedistDir)$(Platform)\</VCRedistDir>
215 </PropertyGroup>
216
Steve Dower894adc12020-03-11 23:24:30 +0000217 <Message Text="VC Redist Directory: $(VCRedistDir)" />
218 <Message Text="VC Redist Version: $(VCToolsRedistVersion)" />
219 </Target>
220
221 <Target Name="FindVCRuntime" Returns="VCRuntimeDLL" DependsOnTargets="FindVCRedistDir">
Steve Dower2dd41742020-03-11 11:18:12 +0000222 <ItemGroup Condition="$(VCInstallDir) != ''">
223 <VCRuntimeDLL Include="$(VCRedistDir)\Microsoft.VC*.CRT\vcruntime*.dll" />
224 </ItemGroup>
225
Steve Dower894adc12020-03-11 23:24:30 +0000226 <Warning Text="vcruntime*.dll not found under $(VCRedistDir)." Condition="@(VCRuntimeDLL) == ''" />
227 <Message Text="VC Runtime DLL(s):%0A- @(VCRuntimeDLL,'%0A- ')" />
Steve Dower2dd41742020-03-11 11:18:12 +0000228 </Target>
Victor Stinner27e2d1f2018-11-01 00:52:28 +0100229</Project>