blob: 95b349c077e5bcaba0a042f482101c07faa77288 [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>
Steve Dower6fd76bc2016-07-16 16:13:19 -070030 <AdditionalIncludeDirectories>$(PySourcePath)Include;$(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>
67 <ProfileGuidedDatabase Condition="$(SupportPGO)">$(OutDir)$(TargetName).pgd</ProfileGuidedDatabase>
68 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
69 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">PGInstrument</LinkTimeCodeGeneration>
70 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">PGUpdate</LinkTimeCodeGeneration>
Brian Curtin401f9f32012-05-13 11:19:23 -050071 </Link>
Steve Dower65e4cb12014-11-22 12:54:57 -080072 <Lib>
73 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">true</LinkTimeCodeGeneration>
74 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">true</LinkTimeCodeGeneration>
75 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">true</LinkTimeCodeGeneration>
76 </Lib>
Brian Curtin401f9f32012-05-13 11:19:23 -050077 <ResourceCompile>
Steve Dowerb0660582016-04-06 12:35:24 -070078 <AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Steve Dower65e4cb12014-11-22 12:54:57 -080079 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
80 <Culture>0x0409</Culture>
Brian Curtin401f9f32012-05-13 11:19:23 -050081 </ResourceCompile>
Steve Dower65e4cb12014-11-22 12:54:57 -080082 <Midl>
83 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
84 <MkTypLibCompatible>true</MkTypLibCompatible>
85 <SuppressStartupBanner>true</SuppressStartupBanner>
86 <TargetEnvironment>Win32</TargetEnvironment>
87 <TargetEnvironment Condition="'$(Platform)' == 'x64'">X64</TargetEnvironment>
Steve Dowerdf450d12016-07-16 16:17:33 -070088 <OutputDirectory>$(IntDir)</OutputDirectory>
89 <InterfaceIdentifierFileName>$(MSBuildProjectName)_i.c</InterfaceIdentifierFileName>
90 <ProxyFileName>$(MSBuildProjectName)_p.c</ProxyFileName>
Steve Dower65e4cb12014-11-22 12:54:57 -080091 </Midl>
Brian Curtin401f9f32012-05-13 11:19:23 -050092 </ItemDefinitionGroup>
Steve Dower65e4cb12014-11-22 12:54:57 -080093
94 <Target Name="GeneratePythonNtRcH"
Steve Dowerb0660582016-04-06 12:35:24 -070095 BeforeTargets="ClCompile"
Steve Dower65e4cb12014-11-22 12:54:57 -080096 Inputs="$(PySourcePath)Include\patchlevel.h"
Steve Dowerb0660582016-04-06 12:35:24 -070097 Outputs="$(IntDir)pythonnt_rc.h">
98 <WriteLinesToFile File="$(IntDir)pythonnt_rc.h" Overwrite="true" Encoding="ascii"
99 Lines='/* This file created by pyproject.props /t:GeneratePythonNtRcH */
Steve Dower65e4cb12014-11-22 12:54:57 -0800100#define FIELD3 $(Field3Value)
Steve Dower25879522015-01-15 09:10:16 -0800101#define MS_DLL_ID "$(SysWinVer)"
Steve Dowerb0660582016-04-06 12:35:24 -0700102#define PYTHON_DLL_NAME "$(TargetName)$(TargetExt)"
Steve Dower65e4cb12014-11-22 12:54:57 -0800103' />
104 <ItemGroup>
Steve Dowerb0660582016-04-06 12:35:24 -0700105 <FileWrites Include="$(IntDir)pythonnt_rc.h" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800106 </ItemGroup>
107 </Target>
108
109 <UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
110 <ParameterGroup>
111 <FileName Required="true" />
112 </ParameterGroup>
113 <Task>
Jeremy Klothfa532942018-10-23 05:41:48 -0600114 <Using Namespace="System.Diagnostics"/>
115 <Using Namespace="System.IO"/>
116 <Using Namespace="System.Runtime.InteropServices"/>
117 <Using Namespace="System.Text"/>
118 <Code Type="Method" Language="cs">
Steve Dower65e4cb12014-11-22 12:54:57 -0800119<![CDATA[
Jeremy Klothfa532942018-10-23 05:41:48 -0600120[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
121public static extern bool QueryFullProcessImageName([In]IntPtr hProcess, [In]int dwFlags,
122 [Out]StringBuilder lpExeName, ref int lpdwSize);
123public override bool Execute() {
124 string fullPath = Path.GetFullPath(FileName);
125 Log.LogMessage("Looking for " + fullPath, MessageImportance.Normal);
126 foreach (Process p in Process.GetProcesses()) {
127 try {
128 int pathLength = 32768;
129 StringBuilder pathBuilder = new StringBuilder(pathLength);
130 if (QueryFullProcessImageName(p.Handle, 0, pathBuilder, ref pathLength)) {
131 string exeName = Path.GetFullPath(pathBuilder.ToString());
132 Log.LogMessage("Found running process: " + exeName, MessageImportance.Low);
133 if (fullPath.Equals(exeName, StringComparison.OrdinalIgnoreCase)) {
134 Log.LogMessage("Terminating " + exeName, MessageImportance.High);
135 p.Kill();
136 }
137 }
138 } catch {
Steve Dower65e4cb12014-11-22 12:54:57 -0800139 }
Steve Dower65e4cb12014-11-22 12:54:57 -0800140 }
Jeremy Klothfa532942018-10-23 05:41:48 -0600141 return true;
Steve Dower65e4cb12014-11-22 12:54:57 -0800142}
143]]>
144 </Code>
145 </Task>
146 </UsingTask>
Steve Dower10e65852014-12-12 12:18:11 -0800147
Steve Dowerf4f10802014-12-12 13:45:25 -0800148 <Target Name="KillPython" BeforeTargets="PrepareForBuild" Condition="'$(KillPython)' == 'true'">
Steve Dower940f6a82015-10-31 12:17:11 -0700149 <Message Text="Killing any running python$(PyDebugExt)$(PyTestExt).exe instances..." Importance="high" />
150 <KillPython FileName="$(OutDir)python$(PyDebugExt)$(PyTestExt).exe" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800151 </Target>
152
153 <!--
154 A default target to handle msbuild pcbuild.proj /t:CleanAll.
155
156 Some externals projects don't respond to /t:Clean, so we invoke
157 CleanAll on them when we really want to clean up.
158 -->
159 <Target Name="CleanAll" DependsOnTargets="Clean">
160 <MSBuild Projects="@(ProjectReference->'%(FullPath)')"
161 Properties="Configuration=$(Configuration);Platform=$(Platform)"
162 BuildInParallel="true"
163 StopOnFirstFailure="false"
164 Condition="Exists(%(FullPath))"
165 Targets="CleanAll" />
166 </Target>
Steve Dowerbb240872015-02-05 22:08:48 -0800167
Steve Dower5fcd5e62017-09-06 10:01:38 -0700168 <Target Name="CopyPGCFiles" BeforeTargets="PrepareForBuild" Condition="$(Configuration) == 'PGUpdate'">
169 <ItemGroup>
170 <_PGCFiles Include="$(OutDir)instrumented\$(TargetName)!*.pgc" />
171 <_PGDFile Include="$(OutDir)instrumented\$(TargetName).pgd" />
172 <_CopyFiles Include="@(_PGCFiles);@(_PGDFile)" Condition="Exists(%(FullPath))" />
173 </ItemGroup>
174 <Delete Files="@(_CopyFiles->'$(OutDir)%(Filename)%(Extension)')" />
175 <Error Text="PGO run did not succeed (no $(TargetName)!*.pgc files) and there is no data to merge"
176 Condition="$(RequirePGCFiles) == 'true' and @(_PGCFiles) == ''" />
177 <Copy SourceFiles="@(_CopyFiles)"
178 DestinationFolder="$(OutDir)"
179 UseHardLinksIfPossible="true"
180 OverwriteReadOnlyFiles="true" />
181 </Target>
182
Steve Dower425ec152016-10-09 20:18:52 -0700183 <PropertyGroup>
Steve Dower5fcd5e62017-09-06 10:01:38 -0700184 <SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\$(DefaultWindowsSDKVersion)\x86</SdkBinPath>
185 <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 -0700186 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
187 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
188 <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 +0200189 <_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 Dower425ec152016-10-09 20:18:52 -0700190 <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
Steve Dowerbb240872015-02-05 22:08:48 -0800191 </PropertyGroup>
192
193 <Target Name="_SignBuild" AfterTargets="AfterBuild" Condition="'$(SigningCertificate)' != '' and $(SupportSigning)">
194 <Error Text="Unable to locate signtool.exe. Set /p:SignToolPath and rebuild" Condition="'$(_SignCommand)' == ''" />
195 <Exec Command='$(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)"' ContinueOnError="false" />
196 </Target>
Zachary Warea191b912014-03-21 22:58:19 -0500197</Project>