blob: 7c0f50be9ea8ea2b62277876a757ffb6b498ddcc [file] [log] [blame]
Steve Dowerf78e66c2019-06-14 14:20:16 -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 Dowerf78e66c2019-06-14 14:20:16 -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 Dowerf78e66c2019-06-14 14:20:16 -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>
Steve Dower5700ae82015-10-11 15:15:52 -070046 <EnableEnhancedInstructionSet Condition="'$(Platform)'=='Win32'">NoExtensions</EnableEnhancedInstructionSet>
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>
Steve Dower65e4cb12014-11-22 12:54:57 -080049 </ClCompile>
50 <ClCompile Condition="$(Configuration) == 'Debug'">
51 <Optimization>Disabled</Optimization>
52 <WholeProgramOptimization>false</WholeProgramOptimization>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070053 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
Brian Curtin401f9f32012-05-13 11:19:23 -050054 </ClCompile>
Zachary Ware4c5ad942016-01-29 19:08:55 -060055 <ClCompile Condition="$(ICCBuild) == 'true'">
56 <FloatingPointModel>Strict</FloatingPointModel>
57 </ClCompile>
Brian Curtin401f9f32012-05-13 11:19:23 -050058 <Link>
59 <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
60 <GenerateDebugInformation>true</GenerateDebugInformation>
61 <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
62 <SubSystem>Windows</SubSystem>
Christian Heimesf3bf35e2013-11-20 17:43:23 +010063 <RandomizedBaseAddress>true</RandomizedBaseAddress>
64 <DataExecutionPrevention>true</DataExecutionPrevention>
Steve Dower65e4cb12014-11-22 12:54:57 -080065 <SuppressStartupBanner>true</SuppressStartupBanner>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070066 <IgnoreSpecificDefaultLibraries>LIBC;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
Brian Curtin401f9f32012-05-13 11:19:23 -050067 <TargetMachine>MachineX86</TargetMachine>
Steve Dower65e4cb12014-11-22 12:54:57 -080068 <TargetMachine Condition="'$(Platform)' == 'x64'">MachineX64</TargetMachine>
Paul Monson8a1657b2019-02-14 08:31:30 -080069 <TargetMachine Condition="'$(Platform)'=='ARM'">MachineARM</TargetMachine>
Paul Monsonf96e7fd2019-05-17 10:07:24 -070070 <TargetMachine Condition="'$(Platform)'=='ARM64'">MachineARM64</TargetMachine>
Steve Dower65e4cb12014-11-22 12:54:57 -080071 <ProfileGuidedDatabase Condition="$(SupportPGO)">$(OutDir)$(TargetName).pgd</ProfileGuidedDatabase>
72 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
73 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">PGInstrument</LinkTimeCodeGeneration>
74 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">PGUpdate</LinkTimeCodeGeneration>
Paul Monson8a1657b2019-02-14 08:31:30 -080075 <AdditionalDependencies>advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
Brian Curtin401f9f32012-05-13 11:19:23 -050076 </Link>
Steve Dower65e4cb12014-11-22 12:54:57 -080077 <Lib>
78 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">true</LinkTimeCodeGeneration>
79 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">true</LinkTimeCodeGeneration>
80 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">true</LinkTimeCodeGeneration>
81 </Lib>
Brian Curtin401f9f32012-05-13 11:19:23 -050082 <ResourceCompile>
Steve Dowerb0660582016-04-06 12:35:24 -070083 <AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Steve Dower65e4cb12014-11-22 12:54:57 -080084 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
85 <Culture>0x0409</Culture>
Brian Curtin401f9f32012-05-13 11:19:23 -050086 </ResourceCompile>
Steve Dower65e4cb12014-11-22 12:54:57 -080087 <Midl>
88 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
89 <MkTypLibCompatible>true</MkTypLibCompatible>
90 <SuppressStartupBanner>true</SuppressStartupBanner>
91 <TargetEnvironment>Win32</TargetEnvironment>
92 <TargetEnvironment Condition="'$(Platform)' == 'x64'">X64</TargetEnvironment>
Steve Dowerdf450d12016-07-16 16:17:33 -070093 <OutputDirectory>$(IntDir)</OutputDirectory>
94 <InterfaceIdentifierFileName>$(MSBuildProjectName)_i.c</InterfaceIdentifierFileName>
95 <ProxyFileName>$(MSBuildProjectName)_p.c</ProxyFileName>
Steve Dower65e4cb12014-11-22 12:54:57 -080096 </Midl>
Brian Curtin401f9f32012-05-13 11:19:23 -050097 </ItemDefinitionGroup>
Steve Dower65e4cb12014-11-22 12:54:57 -080098
99 <Target Name="GeneratePythonNtRcH"
Steve Dowerb0660582016-04-06 12:35:24 -0700100 BeforeTargets="ClCompile"
Steve Dower65e4cb12014-11-22 12:54:57 -0800101 Inputs="$(PySourcePath)Include\patchlevel.h"
Steve Dowerb0660582016-04-06 12:35:24 -0700102 Outputs="$(IntDir)pythonnt_rc.h">
103 <WriteLinesToFile File="$(IntDir)pythonnt_rc.h" Overwrite="true" Encoding="ascii"
104 Lines='/* This file created by pyproject.props /t:GeneratePythonNtRcH */
Steve Dower65e4cb12014-11-22 12:54:57 -0800105#define FIELD3 $(Field3Value)
Steve Dower25879522015-01-15 09:10:16 -0800106#define MS_DLL_ID "$(SysWinVer)"
Steve Dowerb0660582016-04-06 12:35:24 -0700107#define PYTHON_DLL_NAME "$(TargetName)$(TargetExt)"
Steve Dower65e4cb12014-11-22 12:54:57 -0800108' />
109 <ItemGroup>
Steve Dowerb0660582016-04-06 12:35:24 -0700110 <FileWrites Include="$(IntDir)pythonnt_rc.h" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800111 </ItemGroup>
112 </Target>
113
114 <UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
115 <ParameterGroup>
116 <FileName Required="true" />
117 </ParameterGroup>
118 <Task>
Jeremy Klothfa532942018-10-23 05:41:48 -0600119 <Using Namespace="System.Diagnostics"/>
120 <Using Namespace="System.IO"/>
121 <Using Namespace="System.Runtime.InteropServices"/>
122 <Using Namespace="System.Text"/>
123 <Code Type="Method" Language="cs">
Steve Dower65e4cb12014-11-22 12:54:57 -0800124<![CDATA[
Jeremy Klothfa532942018-10-23 05:41:48 -0600125[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
126public static extern bool QueryFullProcessImageName([In]IntPtr hProcess, [In]int dwFlags,
127 [Out]StringBuilder lpExeName, ref int lpdwSize);
128public override bool Execute() {
129 string fullPath = Path.GetFullPath(FileName);
130 Log.LogMessage("Looking for " + fullPath, MessageImportance.Normal);
131 foreach (Process p in Process.GetProcesses()) {
132 try {
133 int pathLength = 32768;
134 StringBuilder pathBuilder = new StringBuilder(pathLength);
135 if (QueryFullProcessImageName(p.Handle, 0, pathBuilder, ref pathLength)) {
136 string exeName = Path.GetFullPath(pathBuilder.ToString());
137 Log.LogMessage("Found running process: " + exeName, MessageImportance.Low);
138 if (fullPath.Equals(exeName, StringComparison.OrdinalIgnoreCase)) {
139 Log.LogMessage("Terminating " + exeName, MessageImportance.High);
140 p.Kill();
141 }
142 }
143 } catch {
Steve Dower65e4cb12014-11-22 12:54:57 -0800144 }
Steve Dower65e4cb12014-11-22 12:54:57 -0800145 }
Jeremy Klothfa532942018-10-23 05:41:48 -0600146 return true;
Steve Dower65e4cb12014-11-22 12:54:57 -0800147}
148]]>
149 </Code>
150 </Task>
151 </UsingTask>
Steve Dowerf78e66c2019-06-14 14:20:16 -0700152
Steve Dowerf4f10802014-12-12 13:45:25 -0800153 <Target Name="KillPython" BeforeTargets="PrepareForBuild" Condition="'$(KillPython)' == 'true'">
Steve Dower940f6a82015-10-31 12:17:11 -0700154 <Message Text="Killing any running python$(PyDebugExt)$(PyTestExt).exe instances..." Importance="high" />
155 <KillPython FileName="$(OutDir)python$(PyDebugExt)$(PyTestExt).exe" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800156 </Target>
Steve Dowerf78e66c2019-06-14 14:20:16 -0700157
Steve Dower65e4cb12014-11-22 12:54:57 -0800158 <!--
159 A default target to handle msbuild pcbuild.proj /t:CleanAll.
Steve Dowerf78e66c2019-06-14 14:20:16 -0700160
Steve Dower65e4cb12014-11-22 12:54:57 -0800161 Some externals projects don't respond to /t:Clean, so we invoke
162 CleanAll on them when we really want to clean up.
163 -->
164 <Target Name="CleanAll" DependsOnTargets="Clean">
165 <MSBuild Projects="@(ProjectReference->'%(FullPath)')"
166 Properties="Configuration=$(Configuration);Platform=$(Platform)"
167 BuildInParallel="true"
168 StopOnFirstFailure="false"
169 Condition="Exists(%(FullPath))"
170 Targets="CleanAll" />
171 </Target>
Steve Dowerbb240872015-02-05 22:08:48 -0800172
Steve Dower5fcd5e62017-09-06 10:01:38 -0700173 <Target Name="CopyPGCFiles" BeforeTargets="PrepareForBuild" Condition="$(Configuration) == 'PGUpdate'">
174 <ItemGroup>
175 <_PGCFiles Include="$(OutDir)instrumented\$(TargetName)!*.pgc" />
176 <_PGDFile Include="$(OutDir)instrumented\$(TargetName).pgd" />
177 <_CopyFiles Include="@(_PGCFiles);@(_PGDFile)" Condition="Exists(%(FullPath))" />
178 </ItemGroup>
179 <Delete Files="@(_CopyFiles->'$(OutDir)%(Filename)%(Extension)')" />
180 <Error Text="PGO run did not succeed (no $(TargetName)!*.pgc files) and there is no data to merge"
181 Condition="$(RequirePGCFiles) == 'true' and @(_PGCFiles) == ''" />
182 <Copy SourceFiles="@(_CopyFiles)"
183 DestinationFolder="$(OutDir)"
184 UseHardLinksIfPossible="true"
185 OverwriteReadOnlyFiles="true" />
186 </Target>
187
Steve Dower425ec152016-10-09 20:18:52 -0700188 <PropertyGroup>
Steve Dower5fcd5e62017-09-06 10:01:38 -0700189 <SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\$(DefaultWindowsSDKVersion)\x86</SdkBinPath>
190 <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 -0700191 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
192 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
193 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\</SdkBinPath>
Steve Dowerf78e66c2019-06-14 14:20:16 -0700194 <_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>
195 <_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 -0700196 <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
Steve Dowerbb240872015-02-05 22:08:48 -0800197 </PropertyGroup>
Steve Dowerd3bbc522018-12-21 13:48:18 -0800198
199 <Target Name="_SignBuild" AfterTargets="AfterBuild" Condition="'$(_SignCommand)' != '' and $(SupportSigning)">
Steve Dowerbb240872015-02-05 22:08:48 -0800200 <Error Text="Unable to locate signtool.exe. Set /p:SignToolPath and rebuild" Condition="'$(_SignCommand)' == ''" />
201 <Exec Command='$(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)"' ContinueOnError="false" />
202 </Target>
Victor Stinner27e2d1f2018-11-01 00:52:28 +0100203</Project>