blob: 12f07dd51287e7c72a4fd7abd4d12d23b61c7db0 [file] [log] [blame]
Brian Curtin401f9f32012-05-13 11:19:23 -05001<?xml version="1.0" encoding="utf-8"?>
Steve Dowerde9fb282015-07-27 14:56:58 -07002<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="Py_IntDir">
Steve Dower65e4cb12014-11-22 12:54:57 -08003 <PropertyGroup Label="Globals">
Stefan Krah318c56c2012-06-24 19:04:35 +02004 <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
Steve Dower65e4cb12014-11-22 12:54:57 -08005 <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
6 <OutDir>$(BuildPath)</OutDir>
Steve Dowerde9fb282015-07-27 14:56:58 -07007 <OutDir Condition="!HasTrailingSlash($(OutDir))">$(OutDir)\</OutDir>
Steve Dower6ed63f32016-07-24 18:03:22 -07008 <Py_IntDir Condition="'$(Py_IntDir)' == ''">$(MSBuildThisFileDirectory)obj\</Py_IntDir>
Steve Dower2084b302017-10-05 13:35:36 -07009 <IntDir>$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\$(ProjectName)\</IntDir>
Steve Dower0d2a9082017-11-04 16:28:47 -070010 <IntDir>$(IntDir.Replace(`\\`, `\`))</IntDir>
Steve Dower65e4cb12014-11-22 12:54:57 -080011 <TargetName Condition="'$(TargetName)' == ''">$(ProjectName)</TargetName>
12 <TargetName>$(TargetName)$(PyDebugExt)</TargetName>
13 <GenerateManifest>false</GenerateManifest>
14 <EmbedManifest>false</EmbedManifest>
15 <SupportPGO Condition="'$(SupportPGO)' == ''">true</SupportPGO>
Steve Dowerbb240872015-02-05 22:08:48 -080016 <SupportSigning Condition="'$(SupportSigning)' == ''">true</SupportSigning>
17 <SupportSigning Condition="'$(Configuration)' == 'Debug'">false</SupportSigning>
18 <SupportSigning Condition="'$(ConfigurationType)' == 'StaticLibrary'">false</SupportSigning>
Zachary Ware6373ba52014-03-17 15:57:38 -050019 </PropertyGroup>
Steve Dower65e4cb12014-11-22 12:54:57 -080020
21 <PropertyGroup>
22 <_DebugPreprocessorDefinition>NDEBUG;</_DebugPreprocessorDefinition>
23 <_DebugPreprocessorDefinition Condition="$(Configuration) == 'Debug'">_DEBUG;</_DebugPreprocessorDefinition>
24 <_PlatformPreprocessorDefinition>_WIN32;</_PlatformPreprocessorDefinition>
25 <_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64'">_WIN64;_M_X64;</_PlatformPreprocessorDefinition>
26 <_PydPreprocessorDefinition Condition="$(TargetExt) == '.pyd'">Py_BUILD_CORE_MODULE;</_PydPreprocessorDefinition>
Brian Curtin401f9f32012-05-13 11:19:23 -050027 </PropertyGroup>
Brian Curtin401f9f32012-05-13 11:19:23 -050028 <ItemDefinitionGroup>
29 <ClCompile>
Victor Stinner27e2d1f2018-11-01 00:52:28 +010030 <AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)PC;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Steve Dower65e4cb12014-11-22 12:54:57 -080031 <PreprocessorDefinitions>WIN32;$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PydPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
32
Brian Curtin401f9f32012-05-13 11:19:23 -050033 <Optimization>MaxSpeed</Optimization>
Brian Curtin401f9f32012-05-13 11:19:23 -050034 <IntrinsicFunctions>true</IntrinsicFunctions>
Brian Curtin401f9f32012-05-13 11:19:23 -050035 <StringPooling>true</StringPooling>
Steve Dower65e4cb12014-11-22 12:54:57 -080036 <ExceptionHandling></ExceptionHandling>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070037 <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
Brian Curtin401f9f32012-05-13 11:19:23 -050038 <FunctionLevelLinking>true</FunctionLevelLinking>
39 <WarningLevel>Level3</WarningLevel>
40 <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
41 <CompileAs>Default</CompileAs>
Steve Dower65e4cb12014-11-22 12:54:57 -080042 <SuppressStartupBanner>true</SuppressStartupBanner>
43 <WholeProgramOptimization>true</WholeProgramOptimization>
Steve Dower5700ae82015-10-11 15:15:52 -070044 <EnableEnhancedInstructionSet Condition="'$(Platform)'=='Win32'">NoExtensions</EnableEnhancedInstructionSet>
Victor Stinnera05bef42018-10-26 15:10:29 +020045 <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OnlyExplicitInline</InlineFunctionExpansion>
46 <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OnlyExplicitInline</InlineFunctionExpansion>
Steve Dower65e4cb12014-11-22 12:54:57 -080047 </ClCompile>
48 <ClCompile Condition="$(Configuration) == 'Debug'">
49 <Optimization>Disabled</Optimization>
50 <WholeProgramOptimization>false</WholeProgramOptimization>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070051 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
Brian Curtin401f9f32012-05-13 11:19:23 -050052 </ClCompile>
Zachary Ware4c5ad942016-01-29 19:08:55 -060053 <ClCompile Condition="$(ICCBuild) == 'true'">
54 <FloatingPointModel>Strict</FloatingPointModel>
55 </ClCompile>
Brian Curtin401f9f32012-05-13 11:19:23 -050056 <Link>
57 <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
58 <GenerateDebugInformation>true</GenerateDebugInformation>
59 <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
60 <SubSystem>Windows</SubSystem>
Christian Heimesf3bf35e2013-11-20 17:43:23 +010061 <RandomizedBaseAddress>true</RandomizedBaseAddress>
62 <DataExecutionPrevention>true</DataExecutionPrevention>
Steve Dower65e4cb12014-11-22 12:54:57 -080063 <SuppressStartupBanner>true</SuppressStartupBanner>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070064 <IgnoreSpecificDefaultLibraries>LIBC;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
Brian Curtin401f9f32012-05-13 11:19:23 -050065 <TargetMachine>MachineX86</TargetMachine>
Steve Dower65e4cb12014-11-22 12:54:57 -080066 <TargetMachine Condition="'$(Platform)' == 'x64'">MachineX64</TargetMachine>
Paul Monson8a1657b2019-02-14 08:31:30 -080067 <TargetMachine Condition="'$(Platform)'=='ARM'">MachineARM</TargetMachine>
Paul Monsonf96e7fd2019-05-17 10:07:24 -070068 <TargetMachine Condition="'$(Platform)'=='ARM64'">MachineARM64</TargetMachine>
Steve Dower65e4cb12014-11-22 12:54:57 -080069 <ProfileGuidedDatabase Condition="$(SupportPGO)">$(OutDir)$(TargetName).pgd</ProfileGuidedDatabase>
70 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
71 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">PGInstrument</LinkTimeCodeGeneration>
72 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">PGUpdate</LinkTimeCodeGeneration>
Paul Monson8a1657b2019-02-14 08:31:30 -080073 <AdditionalDependencies>advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
Brian Curtin401f9f32012-05-13 11:19:23 -050074 </Link>
Steve Dower65e4cb12014-11-22 12:54:57 -080075 <Lib>
76 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">true</LinkTimeCodeGeneration>
77 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">true</LinkTimeCodeGeneration>
78 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">true</LinkTimeCodeGeneration>
79 </Lib>
Brian Curtin401f9f32012-05-13 11:19:23 -050080 <ResourceCompile>
Steve Dowerb0660582016-04-06 12:35:24 -070081 <AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Steve Dower65e4cb12014-11-22 12:54:57 -080082 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
83 <Culture>0x0409</Culture>
Brian Curtin401f9f32012-05-13 11:19:23 -050084 </ResourceCompile>
Steve Dower65e4cb12014-11-22 12:54:57 -080085 <Midl>
86 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
87 <MkTypLibCompatible>true</MkTypLibCompatible>
88 <SuppressStartupBanner>true</SuppressStartupBanner>
89 <TargetEnvironment>Win32</TargetEnvironment>
90 <TargetEnvironment Condition="'$(Platform)' == 'x64'">X64</TargetEnvironment>
Steve Dowerdf450d12016-07-16 16:17:33 -070091 <OutputDirectory>$(IntDir)</OutputDirectory>
92 <InterfaceIdentifierFileName>$(MSBuildProjectName)_i.c</InterfaceIdentifierFileName>
93 <ProxyFileName>$(MSBuildProjectName)_p.c</ProxyFileName>
Steve Dower65e4cb12014-11-22 12:54:57 -080094 </Midl>
Brian Curtin401f9f32012-05-13 11:19:23 -050095 </ItemDefinitionGroup>
Steve Dower65e4cb12014-11-22 12:54:57 -080096
97 <Target Name="GeneratePythonNtRcH"
Steve Dowerb0660582016-04-06 12:35:24 -070098 BeforeTargets="ClCompile"
Steve Dower65e4cb12014-11-22 12:54:57 -080099 Inputs="$(PySourcePath)Include\patchlevel.h"
Steve Dowerb0660582016-04-06 12:35:24 -0700100 Outputs="$(IntDir)pythonnt_rc.h">
101 <WriteLinesToFile File="$(IntDir)pythonnt_rc.h" Overwrite="true" Encoding="ascii"
102 Lines='/* This file created by pyproject.props /t:GeneratePythonNtRcH */
Steve Dower65e4cb12014-11-22 12:54:57 -0800103#define FIELD3 $(Field3Value)
Steve Dower25879522015-01-15 09:10:16 -0800104#define MS_DLL_ID "$(SysWinVer)"
Steve Dowerb0660582016-04-06 12:35:24 -0700105#define PYTHON_DLL_NAME "$(TargetName)$(TargetExt)"
Steve Dower65e4cb12014-11-22 12:54:57 -0800106' />
107 <ItemGroup>
Steve Dowerb0660582016-04-06 12:35:24 -0700108 <FileWrites Include="$(IntDir)pythonnt_rc.h" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800109 </ItemGroup>
110 </Target>
111
112 <UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
113 <ParameterGroup>
114 <FileName Required="true" />
115 </ParameterGroup>
116 <Task>
Jeremy Klothfa532942018-10-23 05:41:48 -0600117 <Using Namespace="System.Diagnostics"/>
118 <Using Namespace="System.IO"/>
119 <Using Namespace="System.Runtime.InteropServices"/>
120 <Using Namespace="System.Text"/>
121 <Code Type="Method" Language="cs">
Steve Dower65e4cb12014-11-22 12:54:57 -0800122<![CDATA[
Jeremy Klothfa532942018-10-23 05:41:48 -0600123[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
124public static extern bool QueryFullProcessImageName([In]IntPtr hProcess, [In]int dwFlags,
125 [Out]StringBuilder lpExeName, ref int lpdwSize);
126public override bool Execute() {
127 string fullPath = Path.GetFullPath(FileName);
128 Log.LogMessage("Looking for " + fullPath, MessageImportance.Normal);
129 foreach (Process p in Process.GetProcesses()) {
130 try {
131 int pathLength = 32768;
132 StringBuilder pathBuilder = new StringBuilder(pathLength);
133 if (QueryFullProcessImageName(p.Handle, 0, pathBuilder, ref pathLength)) {
134 string exeName = Path.GetFullPath(pathBuilder.ToString());
135 Log.LogMessage("Found running process: " + exeName, MessageImportance.Low);
136 if (fullPath.Equals(exeName, StringComparison.OrdinalIgnoreCase)) {
137 Log.LogMessage("Terminating " + exeName, MessageImportance.High);
138 p.Kill();
139 }
140 }
141 } catch {
Steve Dower65e4cb12014-11-22 12:54:57 -0800142 }
Steve Dower65e4cb12014-11-22 12:54:57 -0800143 }
Jeremy Klothfa532942018-10-23 05:41:48 -0600144 return true;
Steve Dower65e4cb12014-11-22 12:54:57 -0800145}
146]]>
147 </Code>
148 </Task>
149 </UsingTask>
Steve Dower10e65852014-12-12 12:18:11 -0800150
Steve Dowerf4f10802014-12-12 13:45:25 -0800151 <Target Name="KillPython" BeforeTargets="PrepareForBuild" Condition="'$(KillPython)' == 'true'">
Steve Dower940f6a82015-10-31 12:17:11 -0700152 <Message Text="Killing any running python$(PyDebugExt)$(PyTestExt).exe instances..." Importance="high" />
153 <KillPython FileName="$(OutDir)python$(PyDebugExt)$(PyTestExt).exe" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800154 </Target>
155
156 <!--
157 A default target to handle msbuild pcbuild.proj /t:CleanAll.
158
159 Some externals projects don't respond to /t:Clean, so we invoke
160 CleanAll on them when we really want to clean up.
161 -->
162 <Target Name="CleanAll" DependsOnTargets="Clean">
163 <MSBuild Projects="@(ProjectReference->'%(FullPath)')"
164 Properties="Configuration=$(Configuration);Platform=$(Platform)"
165 BuildInParallel="true"
166 StopOnFirstFailure="false"
167 Condition="Exists(%(FullPath))"
168 Targets="CleanAll" />
169 </Target>
Steve Dowerbb240872015-02-05 22:08:48 -0800170
Steve Dower5fcd5e62017-09-06 10:01:38 -0700171 <Target Name="CopyPGCFiles" BeforeTargets="PrepareForBuild" Condition="$(Configuration) == 'PGUpdate'">
172 <ItemGroup>
173 <_PGCFiles Include="$(OutDir)instrumented\$(TargetName)!*.pgc" />
174 <_PGDFile Include="$(OutDir)instrumented\$(TargetName).pgd" />
175 <_CopyFiles Include="@(_PGCFiles);@(_PGDFile)" Condition="Exists(%(FullPath))" />
176 </ItemGroup>
177 <Delete Files="@(_CopyFiles->'$(OutDir)%(Filename)%(Extension)')" />
178 <Error Text="PGO run did not succeed (no $(TargetName)!*.pgc files) and there is no data to merge"
179 Condition="$(RequirePGCFiles) == 'true' and @(_PGCFiles) == ''" />
180 <Copy SourceFiles="@(_CopyFiles)"
181 DestinationFolder="$(OutDir)"
182 UseHardLinksIfPossible="true"
183 OverwriteReadOnlyFiles="true" />
184 </Target>
185
Steve Dower425ec152016-10-09 20:18:52 -0700186 <PropertyGroup>
Steve Dower5fcd5e62017-09-06 10:01:38 -0700187 <SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\$(DefaultWindowsSDKVersion)\x86</SdkBinPath>
188 <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 -0700189 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
190 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
191 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\</SdkBinPath>
Steve Dower68d663c2017-07-17 11:15:48 +0200192 <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificate)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /q /a /n "$(SigningCertificate)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)"</_SignCommand>
Steve Dowerd3bbc522018-12-21 13:48:18 -0800193 <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificateSha1)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /q /a /sha1 "$(SigningCertificateSha1)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)"</_SignCommand>
Steve Dower425ec152016-10-09 20:18:52 -0700194 <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
Steve Dowerbb240872015-02-05 22:08:48 -0800195 </PropertyGroup>
Steve Dowerd3bbc522018-12-21 13:48:18 -0800196
197 <Target Name="_SignBuild" AfterTargets="AfterBuild" Condition="'$(_SignCommand)' != '' and $(SupportSigning)">
Steve Dowerbb240872015-02-05 22:08:48 -0800198 <Error Text="Unable to locate signtool.exe. Set /p:SignToolPath and rebuild" Condition="'$(_SignCommand)' == ''" />
199 <Exec Command='$(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)"' ContinueOnError="false" />
200 </Target>
Victor Stinner27e2d1f2018-11-01 00:52:28 +0100201</Project>