blob: 94a01ff5ca8a083c89e53266ea17b3ab9b60dc17 [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>
Brian Curtin401f9f32012-05-13 11:19:23 -050029 </PropertyGroup>
Brian Curtin401f9f32012-05-13 11:19:23 -050030 <ItemDefinitionGroup>
31 <ClCompile>
Victor Stinner27e2d1f2018-11-01 00:52:28 +010032 <AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)PC;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Steve Dower65e4cb12014-11-22 12:54:57 -080033 <PreprocessorDefinitions>WIN32;$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PydPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
Steve Dower21a92f82019-06-14 08:29:20 -070034
Brian Curtin401f9f32012-05-13 11:19:23 -050035 <Optimization>MaxSpeed</Optimization>
Brian Curtin401f9f32012-05-13 11:19:23 -050036 <IntrinsicFunctions>true</IntrinsicFunctions>
Brian Curtin401f9f32012-05-13 11:19:23 -050037 <StringPooling>true</StringPooling>
Steve Dower65e4cb12014-11-22 12:54:57 -080038 <ExceptionHandling></ExceptionHandling>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070039 <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
Brian Curtin401f9f32012-05-13 11:19:23 -050040 <FunctionLevelLinking>true</FunctionLevelLinking>
41 <WarningLevel>Level3</WarningLevel>
42 <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
43 <CompileAs>Default</CompileAs>
Steve Dower65e4cb12014-11-22 12:54:57 -080044 <SuppressStartupBanner>true</SuppressStartupBanner>
45 <WholeProgramOptimization>true</WholeProgramOptimization>
Victor Stinnera05bef42018-10-26 15:10:29 +020046 <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OnlyExplicitInline</InlineFunctionExpansion>
47 <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OnlyExplicitInline</InlineFunctionExpansion>
Steve Dower65e4cb12014-11-22 12:54:57 -080048 </ClCompile>
49 <ClCompile Condition="$(Configuration) == 'Debug'">
50 <Optimization>Disabled</Optimization>
51 <WholeProgramOptimization>false</WholeProgramOptimization>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070052 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
Brian Curtin401f9f32012-05-13 11:19:23 -050053 </ClCompile>
Zachary Ware4c5ad942016-01-29 19:08:55 -060054 <ClCompile Condition="$(ICCBuild) == 'true'">
55 <FloatingPointModel>Strict</FloatingPointModel>
56 </ClCompile>
Brian Curtin401f9f32012-05-13 11:19:23 -050057 <Link>
58 <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
59 <GenerateDebugInformation>true</GenerateDebugInformation>
60 <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
61 <SubSystem>Windows</SubSystem>
Christian Heimesf3bf35e2013-11-20 17:43:23 +010062 <RandomizedBaseAddress>true</RandomizedBaseAddress>
63 <DataExecutionPrevention>true</DataExecutionPrevention>
Steve Dower65e4cb12014-11-22 12:54:57 -080064 <SuppressStartupBanner>true</SuppressStartupBanner>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070065 <IgnoreSpecificDefaultLibraries>LIBC;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
Brian Curtin401f9f32012-05-13 11:19:23 -050066 <TargetMachine>MachineX86</TargetMachine>
Steve Dower65e4cb12014-11-22 12:54:57 -080067 <TargetMachine Condition="'$(Platform)' == 'x64'">MachineX64</TargetMachine>
Paul Monson8a1657b2019-02-14 08:31:30 -080068 <TargetMachine Condition="'$(Platform)'=='ARM'">MachineARM</TargetMachine>
Paul Monsonf96e7fd2019-05-17 10:07:24 -070069 <TargetMachine Condition="'$(Platform)'=='ARM64'">MachineARM64</TargetMachine>
Steve Dower65e4cb12014-11-22 12:54:57 -080070 <ProfileGuidedDatabase Condition="$(SupportPGO)">$(OutDir)$(TargetName).pgd</ProfileGuidedDatabase>
71 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
72 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">PGInstrument</LinkTimeCodeGeneration>
73 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">PGUpdate</LinkTimeCodeGeneration>
Paul Monson8a1657b2019-02-14 08:31:30 -080074 <AdditionalDependencies>advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
Brian Curtin401f9f32012-05-13 11:19:23 -050075 </Link>
Steve Dower65e4cb12014-11-22 12:54:57 -080076 <Lib>
77 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">true</LinkTimeCodeGeneration>
78 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">true</LinkTimeCodeGeneration>
79 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">true</LinkTimeCodeGeneration>
80 </Lib>
Brian Curtin401f9f32012-05-13 11:19:23 -050081 <ResourceCompile>
Steve Dowerb0660582016-04-06 12:35:24 -070082 <AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Nikita Nemkin4efc3362020-06-24 00:05:57 +050083 <PreprocessorDefinitions>ORIGINAL_FILENAME=\"$(TargetName)$(TargetExt)\";FIELD3=$(Field3Value);$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
Steve Dower65e4cb12014-11-22 12:54:57 -080084 <Culture>0x0409</Culture>
Brian Curtin401f9f32012-05-13 11:19:23 -050085 </ResourceCompile>
Steve Dower65e4cb12014-11-22 12:54:57 -080086 <Midl>
87 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
88 <MkTypLibCompatible>true</MkTypLibCompatible>
89 <SuppressStartupBanner>true</SuppressStartupBanner>
90 <TargetEnvironment>Win32</TargetEnvironment>
91 <TargetEnvironment Condition="'$(Platform)' == 'x64'">X64</TargetEnvironment>
Steve Dowerdf450d12016-07-16 16:17:33 -070092 <OutputDirectory>$(IntDir)</OutputDirectory>
93 <InterfaceIdentifierFileName>$(MSBuildProjectName)_i.c</InterfaceIdentifierFileName>
94 <ProxyFileName>$(MSBuildProjectName)_p.c</ProxyFileName>
Steve Dower65e4cb12014-11-22 12:54:57 -080095 </Midl>
Brian Curtin401f9f32012-05-13 11:19:23 -050096 </ItemDefinitionGroup>
Steve Dower65e4cb12014-11-22 12:54:57 -080097
Steve Dower65e4cb12014-11-22 12:54:57 -080098 <UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
99 <ParameterGroup>
100 <FileName Required="true" />
101 </ParameterGroup>
102 <Task>
Jeremy Klothfa532942018-10-23 05:41:48 -0600103 <Using Namespace="System.Diagnostics"/>
104 <Using Namespace="System.IO"/>
105 <Using Namespace="System.Runtime.InteropServices"/>
106 <Using Namespace="System.Text"/>
107 <Code Type="Method" Language="cs">
Steve Dower65e4cb12014-11-22 12:54:57 -0800108<![CDATA[
Jeremy Klothfa532942018-10-23 05:41:48 -0600109[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
110public static extern bool QueryFullProcessImageName([In]IntPtr hProcess, [In]int dwFlags,
111 [Out]StringBuilder lpExeName, ref int lpdwSize);
112public override bool Execute() {
113 string fullPath = Path.GetFullPath(FileName);
114 Log.LogMessage("Looking for " + fullPath, MessageImportance.Normal);
115 foreach (Process p in Process.GetProcesses()) {
116 try {
117 int pathLength = 32768;
118 StringBuilder pathBuilder = new StringBuilder(pathLength);
119 if (QueryFullProcessImageName(p.Handle, 0, pathBuilder, ref pathLength)) {
120 string exeName = Path.GetFullPath(pathBuilder.ToString());
121 Log.LogMessage("Found running process: " + exeName, MessageImportance.Low);
122 if (fullPath.Equals(exeName, StringComparison.OrdinalIgnoreCase)) {
123 Log.LogMessage("Terminating " + exeName, MessageImportance.High);
124 p.Kill();
125 }
126 }
127 } catch {
Steve Dower65e4cb12014-11-22 12:54:57 -0800128 }
Steve Dower65e4cb12014-11-22 12:54:57 -0800129 }
Jeremy Klothfa532942018-10-23 05:41:48 -0600130 return true;
Steve Dower65e4cb12014-11-22 12:54:57 -0800131}
132]]>
133 </Code>
134 </Task>
135 </UsingTask>
Steve Dower21a92f82019-06-14 08:29:20 -0700136
Steve Dowerf4f10802014-12-12 13:45:25 -0800137 <Target Name="KillPython" BeforeTargets="PrepareForBuild" Condition="'$(KillPython)' == 'true'">
Steve Dower940f6a82015-10-31 12:17:11 -0700138 <Message Text="Killing any running python$(PyDebugExt)$(PyTestExt).exe instances..." Importance="high" />
139 <KillPython FileName="$(OutDir)python$(PyDebugExt)$(PyTestExt).exe" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800140 </Target>
Steve Dower21a92f82019-06-14 08:29:20 -0700141
Steve Dower65e4cb12014-11-22 12:54:57 -0800142 <!--
143 A default target to handle msbuild pcbuild.proj /t:CleanAll.
Steve Dower21a92f82019-06-14 08:29:20 -0700144
Steve Dower65e4cb12014-11-22 12:54:57 -0800145 Some externals projects don't respond to /t:Clean, so we invoke
146 CleanAll on them when we really want to clean up.
147 -->
148 <Target Name="CleanAll" DependsOnTargets="Clean">
149 <MSBuild Projects="@(ProjectReference->'%(FullPath)')"
150 Properties="Configuration=$(Configuration);Platform=$(Platform)"
151 BuildInParallel="true"
152 StopOnFirstFailure="false"
153 Condition="Exists(%(FullPath))"
154 Targets="CleanAll" />
155 </Target>
Steve Dowerbb240872015-02-05 22:08:48 -0800156
Steve Dower5fcd5e62017-09-06 10:01:38 -0700157 <Target Name="CopyPGCFiles" BeforeTargets="PrepareForBuild" Condition="$(Configuration) == 'PGUpdate'">
158 <ItemGroup>
159 <_PGCFiles Include="$(OutDir)instrumented\$(TargetName)!*.pgc" />
160 <_PGDFile Include="$(OutDir)instrumented\$(TargetName).pgd" />
161 <_CopyFiles Include="@(_PGCFiles);@(_PGDFile)" Condition="Exists(%(FullPath))" />
162 </ItemGroup>
163 <Delete Files="@(_CopyFiles->'$(OutDir)%(Filename)%(Extension)')" />
164 <Error Text="PGO run did not succeed (no $(TargetName)!*.pgc files) and there is no data to merge"
165 Condition="$(RequirePGCFiles) == 'true' and @(_PGCFiles) == ''" />
166 <Copy SourceFiles="@(_CopyFiles)"
167 DestinationFolder="$(OutDir)"
168 UseHardLinksIfPossible="true"
169 OverwriteReadOnlyFiles="true" />
170 </Target>
171
Steve Dower425ec152016-10-09 20:18:52 -0700172 <PropertyGroup>
Steve Dower5fcd5e62017-09-06 10:01:38 -0700173 <SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\$(DefaultWindowsSDKVersion)\x86</SdkBinPath>
174 <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 -0700175 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
176 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
177 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\</SdkBinPath>
Steve Dower21a92f82019-06-14 08:29:20 -0700178 <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificate)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /a /n "$(SigningCertificate)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)"</_SignCommand>
179 <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificateSha1)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /a /sha1 "$(SigningCertificateSha1)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)"</_SignCommand>
Steve Dower425ec152016-10-09 20:18:52 -0700180 <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
Steve Dowerbb240872015-02-05 22:08:48 -0800181 </PropertyGroup>
Steve Dowerd3bbc522018-12-21 13:48:18 -0800182
183 <Target Name="_SignBuild" AfterTargets="AfterBuild" Condition="'$(_SignCommand)' != '' and $(SupportSigning)">
Steve Dowerbb240872015-02-05 22:08:48 -0800184 <Error Text="Unable to locate signtool.exe. Set /p:SignToolPath and rebuild" Condition="'$(_SignCommand)' == ''" />
185 <Exec Command='$(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)"' ContinueOnError="false" />
186 </Target>
Steve Dower2dd41742020-03-11 11:18:12 +0000187
188
Steve Dower894adc12020-03-11 23:24:30 +0000189 <Target Name="FindVCRedistDir">
190 <!-- Hard coded path for VS 2015 -->
Steve Dower2dd41742020-03-11 11:18:12 +0000191 <PropertyGroup Condition="$(PlatformToolset) == 'v140'">
192 <VCRedistDir>$(VCInstallDir)\redist\</VCRedistDir>
Steve Dower894adc12020-03-11 23:24:30 +0000193 </PropertyGroup>
194
195 <!-- Search for version number in some broken Build Tools installs -->
196 <ItemGroup Condition="$(VCRedistDir) == '' and $(VCToolsRedistVersion) == ''">
197 <_RedistFiles Include="$(VCInstallDir)\Redist\MSVC\*\*.*" />
198 </ItemGroup>
199 <PropertyGroup Condition="$(VCRedistDir) == '' and $(VCToolsRedistVersion) == ''">
200 <_RedistDir>%(_RedistFiles.Directory)</_RedistDir>
201 <VCToolsRedistVersion>$([System.IO.Path]::GetFileName($(_RedistDir.Trim(`\`))))</VCToolsRedistVersion>
202 </PropertyGroup>
203
204 <!-- Use correct path for VS 2017 and later -->
205 <PropertyGroup Condition="$(VCRedistDir) == ''">
206 <VCRedistDir>$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\</VCRedistDir>
207 </PropertyGroup>
208
209 <PropertyGroup>
Steve Dower2dd41742020-03-11 11:18:12 +0000210 <VCRedistDir Condition="$(Platform) == 'Win32'">$(VCRedistDir)x86\</VCRedistDir>
211 <VCRedistDir Condition="$(Platform) != 'Win32'">$(VCRedistDir)$(Platform)\</VCRedistDir>
212 </PropertyGroup>
213
Steve Dower894adc12020-03-11 23:24:30 +0000214 <Message Text="VC Redist Directory: $(VCRedistDir)" />
215 <Message Text="VC Redist Version: $(VCToolsRedistVersion)" />
216 </Target>
217
218 <Target Name="FindVCRuntime" Returns="VCRuntimeDLL" DependsOnTargets="FindVCRedistDir">
Steve Dower2dd41742020-03-11 11:18:12 +0000219 <ItemGroup Condition="$(VCInstallDir) != ''">
220 <VCRuntimeDLL Include="$(VCRedistDir)\Microsoft.VC*.CRT\vcruntime*.dll" />
221 </ItemGroup>
222
Steve Dower894adc12020-03-11 23:24:30 +0000223 <Warning Text="vcruntime*.dll not found under $(VCRedistDir)." Condition="@(VCRuntimeDLL) == ''" />
224 <Message Text="VC Runtime DLL(s):%0A- @(VCRuntimeDLL,'%0A- ')" />
Steve Dower2dd41742020-03-11 11:18:12 +0000225 </Target>
Victor Stinner27e2d1f2018-11-01 00:52:28 +0100226</Project>