blob: 847e5f57c4b9baec48c71b423215a4e488357630 [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>
Steve Dower65e4cb12014-11-22 12:54:57 -080068 <ProfileGuidedDatabase Condition="$(SupportPGO)">$(OutDir)$(TargetName).pgd</ProfileGuidedDatabase>
69 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
70 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">PGInstrument</LinkTimeCodeGeneration>
71 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">PGUpdate</LinkTimeCodeGeneration>
Paul Monson8a1657b2019-02-14 08:31:30 -080072 <AdditionalDependencies>advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
Brian Curtin401f9f32012-05-13 11:19:23 -050073 </Link>
Steve Dower65e4cb12014-11-22 12:54:57 -080074 <Lib>
75 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">true</LinkTimeCodeGeneration>
76 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">true</LinkTimeCodeGeneration>
77 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">true</LinkTimeCodeGeneration>
78 </Lib>
Brian Curtin401f9f32012-05-13 11:19:23 -050079 <ResourceCompile>
Steve Dowerb0660582016-04-06 12:35:24 -070080 <AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Steve Dower65e4cb12014-11-22 12:54:57 -080081 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
82 <Culture>0x0409</Culture>
Brian Curtin401f9f32012-05-13 11:19:23 -050083 </ResourceCompile>
Steve Dower65e4cb12014-11-22 12:54:57 -080084 <Midl>
85 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
86 <MkTypLibCompatible>true</MkTypLibCompatible>
87 <SuppressStartupBanner>true</SuppressStartupBanner>
88 <TargetEnvironment>Win32</TargetEnvironment>
89 <TargetEnvironment Condition="'$(Platform)' == 'x64'">X64</TargetEnvironment>
Steve Dowerdf450d12016-07-16 16:17:33 -070090 <OutputDirectory>$(IntDir)</OutputDirectory>
91 <InterfaceIdentifierFileName>$(MSBuildProjectName)_i.c</InterfaceIdentifierFileName>
92 <ProxyFileName>$(MSBuildProjectName)_p.c</ProxyFileName>
Steve Dower65e4cb12014-11-22 12:54:57 -080093 </Midl>
Brian Curtin401f9f32012-05-13 11:19:23 -050094 </ItemDefinitionGroup>
Steve Dower65e4cb12014-11-22 12:54:57 -080095
96 <Target Name="GeneratePythonNtRcH"
Steve Dowerb0660582016-04-06 12:35:24 -070097 BeforeTargets="ClCompile"
Steve Dower65e4cb12014-11-22 12:54:57 -080098 Inputs="$(PySourcePath)Include\patchlevel.h"
Steve Dowerb0660582016-04-06 12:35:24 -070099 Outputs="$(IntDir)pythonnt_rc.h">
100 <WriteLinesToFile File="$(IntDir)pythonnt_rc.h" Overwrite="true" Encoding="ascii"
101 Lines='/* This file created by pyproject.props /t:GeneratePythonNtRcH */
Steve Dower65e4cb12014-11-22 12:54:57 -0800102#define FIELD3 $(Field3Value)
Steve Dower25879522015-01-15 09:10:16 -0800103#define MS_DLL_ID "$(SysWinVer)"
Steve Dowerb0660582016-04-06 12:35:24 -0700104#define PYTHON_DLL_NAME "$(TargetName)$(TargetExt)"
Steve Dower65e4cb12014-11-22 12:54:57 -0800105' />
106 <ItemGroup>
Steve Dowerb0660582016-04-06 12:35:24 -0700107 <FileWrites Include="$(IntDir)pythonnt_rc.h" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800108 </ItemGroup>
109 </Target>
110
111 <UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
112 <ParameterGroup>
113 <FileName Required="true" />
114 </ParameterGroup>
115 <Task>
Jeremy Klothfa532942018-10-23 05:41:48 -0600116 <Using Namespace="System.Diagnostics"/>
117 <Using Namespace="System.IO"/>
118 <Using Namespace="System.Runtime.InteropServices"/>
119 <Using Namespace="System.Text"/>
120 <Code Type="Method" Language="cs">
Steve Dower65e4cb12014-11-22 12:54:57 -0800121<![CDATA[
Jeremy Klothfa532942018-10-23 05:41:48 -0600122[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
123public static extern bool QueryFullProcessImageName([In]IntPtr hProcess, [In]int dwFlags,
124 [Out]StringBuilder lpExeName, ref int lpdwSize);
125public override bool Execute() {
126 string fullPath = Path.GetFullPath(FileName);
127 Log.LogMessage("Looking for " + fullPath, MessageImportance.Normal);
128 foreach (Process p in Process.GetProcesses()) {
129 try {
130 int pathLength = 32768;
131 StringBuilder pathBuilder = new StringBuilder(pathLength);
132 if (QueryFullProcessImageName(p.Handle, 0, pathBuilder, ref pathLength)) {
133 string exeName = Path.GetFullPath(pathBuilder.ToString());
134 Log.LogMessage("Found running process: " + exeName, MessageImportance.Low);
135 if (fullPath.Equals(exeName, StringComparison.OrdinalIgnoreCase)) {
136 Log.LogMessage("Terminating " + exeName, MessageImportance.High);
137 p.Kill();
138 }
139 }
140 } catch {
Steve Dower65e4cb12014-11-22 12:54:57 -0800141 }
Steve Dower65e4cb12014-11-22 12:54:57 -0800142 }
Jeremy Klothfa532942018-10-23 05:41:48 -0600143 return true;
Steve Dower65e4cb12014-11-22 12:54:57 -0800144}
145]]>
146 </Code>
147 </Task>
148 </UsingTask>
Steve Dower10e65852014-12-12 12:18:11 -0800149
Steve Dowerf4f10802014-12-12 13:45:25 -0800150 <Target Name="KillPython" BeforeTargets="PrepareForBuild" Condition="'$(KillPython)' == 'true'">
Steve Dower940f6a82015-10-31 12:17:11 -0700151 <Message Text="Killing any running python$(PyDebugExt)$(PyTestExt).exe instances..." Importance="high" />
152 <KillPython FileName="$(OutDir)python$(PyDebugExt)$(PyTestExt).exe" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800153 </Target>
154
155 <!--
156 A default target to handle msbuild pcbuild.proj /t:CleanAll.
157
158 Some externals projects don't respond to /t:Clean, so we invoke
159 CleanAll on them when we really want to clean up.
160 -->
161 <Target Name="CleanAll" DependsOnTargets="Clean">
162 <MSBuild Projects="@(ProjectReference->'%(FullPath)')"
163 Properties="Configuration=$(Configuration);Platform=$(Platform)"
164 BuildInParallel="true"
165 StopOnFirstFailure="false"
166 Condition="Exists(%(FullPath))"
167 Targets="CleanAll" />
168 </Target>
Steve Dowerbb240872015-02-05 22:08:48 -0800169
Steve Dower5fcd5e62017-09-06 10:01:38 -0700170 <Target Name="CopyPGCFiles" BeforeTargets="PrepareForBuild" Condition="$(Configuration) == 'PGUpdate'">
171 <ItemGroup>
172 <_PGCFiles Include="$(OutDir)instrumented\$(TargetName)!*.pgc" />
173 <_PGDFile Include="$(OutDir)instrumented\$(TargetName).pgd" />
174 <_CopyFiles Include="@(_PGCFiles);@(_PGDFile)" Condition="Exists(%(FullPath))" />
175 </ItemGroup>
176 <Delete Files="@(_CopyFiles->'$(OutDir)%(Filename)%(Extension)')" />
177 <Error Text="PGO run did not succeed (no $(TargetName)!*.pgc files) and there is no data to merge"
178 Condition="$(RequirePGCFiles) == 'true' and @(_PGCFiles) == ''" />
179 <Copy SourceFiles="@(_CopyFiles)"
180 DestinationFolder="$(OutDir)"
181 UseHardLinksIfPossible="true"
182 OverwriteReadOnlyFiles="true" />
183 </Target>
184
Steve Dower425ec152016-10-09 20:18:52 -0700185 <PropertyGroup>
Steve Dower5fcd5e62017-09-06 10:01:38 -0700186 <SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\$(DefaultWindowsSDKVersion)\x86</SdkBinPath>
187 <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 -0700188 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
189 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
190 <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 +0200191 <_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 -0800192 <_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 -0700193 <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
Steve Dowerbb240872015-02-05 22:08:48 -0800194 </PropertyGroup>
Steve Dowerd3bbc522018-12-21 13:48:18 -0800195
196 <Target Name="_SignBuild" AfterTargets="AfterBuild" Condition="'$(_SignCommand)' != '' and $(SupportSigning)">
Steve Dowerbb240872015-02-05 22:08:48 -0800197 <Error Text="Unable to locate signtool.exe. Set /p:SignToolPath and rebuild" Condition="'$(_SignCommand)' == ''" />
198 <Exec Command='$(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)"' ContinueOnError="false" />
199 </Target>
Victor Stinner27e2d1f2018-11-01 00:52:28 +0100200</Project>