blob: 7016130b6fe86213a399d406a58e0a98ca18a92d [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>
Steve Dower65e4cb12014-11-22 12:54:57 -080045 </ClCompile>
46 <ClCompile Condition="$(Configuration) == 'Debug'">
47 <Optimization>Disabled</Optimization>
48 <WholeProgramOptimization>false</WholeProgramOptimization>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070049 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
Brian Curtin401f9f32012-05-13 11:19:23 -050050 </ClCompile>
Zachary Ware4c5ad942016-01-29 19:08:55 -060051 <ClCompile Condition="$(ICCBuild) == 'true'">
52 <FloatingPointModel>Strict</FloatingPointModel>
53 </ClCompile>
Brian Curtin401f9f32012-05-13 11:19:23 -050054 <Link>
55 <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
56 <GenerateDebugInformation>true</GenerateDebugInformation>
57 <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
58 <SubSystem>Windows</SubSystem>
Christian Heimesf3bf35e2013-11-20 17:43:23 +010059 <RandomizedBaseAddress>true</RandomizedBaseAddress>
60 <DataExecutionPrevention>true</DataExecutionPrevention>
Steve Dower65e4cb12014-11-22 12:54:57 -080061 <SuppressStartupBanner>true</SuppressStartupBanner>
Steve Dowerfcbe1df2015-09-08 21:39:01 -070062 <IgnoreSpecificDefaultLibraries>LIBC;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
Brian Curtin401f9f32012-05-13 11:19:23 -050063 <TargetMachine>MachineX86</TargetMachine>
Steve Dower65e4cb12014-11-22 12:54:57 -080064 <TargetMachine Condition="'$(Platform)' == 'x64'">MachineX64</TargetMachine>
65 <ProfileGuidedDatabase Condition="$(SupportPGO)">$(OutDir)$(TargetName).pgd</ProfileGuidedDatabase>
66 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
67 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">PGInstrument</LinkTimeCodeGeneration>
68 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">PGUpdate</LinkTimeCodeGeneration>
Brian Curtin401f9f32012-05-13 11:19:23 -050069 </Link>
Steve Dower65e4cb12014-11-22 12:54:57 -080070 <Lib>
71 <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">true</LinkTimeCodeGeneration>
72 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">true</LinkTimeCodeGeneration>
73 <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">true</LinkTimeCodeGeneration>
74 </Lib>
Brian Curtin401f9f32012-05-13 11:19:23 -050075 <ResourceCompile>
Steve Dowerb0660582016-04-06 12:35:24 -070076 <AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
Steve Dower65e4cb12014-11-22 12:54:57 -080077 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
78 <Culture>0x0409</Culture>
Brian Curtin401f9f32012-05-13 11:19:23 -050079 </ResourceCompile>
Steve Dower65e4cb12014-11-22 12:54:57 -080080 <Midl>
81 <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
82 <MkTypLibCompatible>true</MkTypLibCompatible>
83 <SuppressStartupBanner>true</SuppressStartupBanner>
84 <TargetEnvironment>Win32</TargetEnvironment>
85 <TargetEnvironment Condition="'$(Platform)' == 'x64'">X64</TargetEnvironment>
Steve Dowerdf450d12016-07-16 16:17:33 -070086 <OutputDirectory>$(IntDir)</OutputDirectory>
87 <InterfaceIdentifierFileName>$(MSBuildProjectName)_i.c</InterfaceIdentifierFileName>
88 <ProxyFileName>$(MSBuildProjectName)_p.c</ProxyFileName>
Steve Dower65e4cb12014-11-22 12:54:57 -080089 </Midl>
Brian Curtin401f9f32012-05-13 11:19:23 -050090 </ItemDefinitionGroup>
Steve Dower65e4cb12014-11-22 12:54:57 -080091
92 <Target Name="GeneratePythonNtRcH"
Steve Dowerb0660582016-04-06 12:35:24 -070093 BeforeTargets="ClCompile"
Steve Dower65e4cb12014-11-22 12:54:57 -080094 Inputs="$(PySourcePath)Include\patchlevel.h"
Steve Dowerb0660582016-04-06 12:35:24 -070095 Outputs="$(IntDir)pythonnt_rc.h">
96 <WriteLinesToFile File="$(IntDir)pythonnt_rc.h" Overwrite="true" Encoding="ascii"
97 Lines='/* This file created by pyproject.props /t:GeneratePythonNtRcH */
Steve Dower65e4cb12014-11-22 12:54:57 -080098#define FIELD3 $(Field3Value)
Steve Dower25879522015-01-15 09:10:16 -080099#define MS_DLL_ID "$(SysWinVer)"
Steve Dowerb0660582016-04-06 12:35:24 -0700100#define PYTHON_DLL_NAME "$(TargetName)$(TargetExt)"
Steve Dower65e4cb12014-11-22 12:54:57 -0800101' />
102 <ItemGroup>
Steve Dowerb0660582016-04-06 12:35:24 -0700103 <FileWrites Include="$(IntDir)pythonnt_rc.h" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800104 </ItemGroup>
105 </Target>
106
107 <UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
108 <ParameterGroup>
109 <FileName Required="true" />
110 </ParameterGroup>
111 <Task>
112 <Code Type="Fragment" Language="cs">
113<![CDATA[
114string fullPath = System.IO.Path.GetFullPath(FileName);
115Log.LogMessage("Looking for " + fullPath, MessageImportance.Normal);
116foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses()) {
117 try {
118 Log.LogMessage("Found running process: " + p.MainModule.FileName, MessageImportance.Low);
119 if (fullPath.Equals(System.IO.Path.GetFullPath(p.MainModule.FileName), StringComparison.OrdinalIgnoreCase)) {
120 Log.LogMessage("Terminating " + p.MainModule.FileName, MessageImportance.High);
121 p.Kill();
122 }
123 } catch {
124 }
125}
126]]>
127 </Code>
128 </Task>
129 </UsingTask>
Steve Dower10e65852014-12-12 12:18:11 -0800130
Steve Dowerf4f10802014-12-12 13:45:25 -0800131 <Target Name="KillPython" BeforeTargets="PrepareForBuild" Condition="'$(KillPython)' == 'true'">
Steve Dower940f6a82015-10-31 12:17:11 -0700132 <Message Text="Killing any running python$(PyDebugExt)$(PyTestExt).exe instances..." Importance="high" />
133 <KillPython FileName="$(OutDir)python$(PyDebugExt)$(PyTestExt).exe" />
Steve Dower65e4cb12014-11-22 12:54:57 -0800134 </Target>
135
136 <!--
137 A default target to handle msbuild pcbuild.proj /t:CleanAll.
138
139 Some externals projects don't respond to /t:Clean, so we invoke
140 CleanAll on them when we really want to clean up.
141 -->
142 <Target Name="CleanAll" DependsOnTargets="Clean">
143 <MSBuild Projects="@(ProjectReference->'%(FullPath)')"
144 Properties="Configuration=$(Configuration);Platform=$(Platform)"
145 BuildInParallel="true"
146 StopOnFirstFailure="false"
147 Condition="Exists(%(FullPath))"
148 Targets="CleanAll" />
149 </Target>
Steve Dowerbb240872015-02-05 22:08:48 -0800150
Steve Dower5fcd5e62017-09-06 10:01:38 -0700151 <Target Name="CopyPGCFiles" BeforeTargets="PrepareForBuild" Condition="$(Configuration) == 'PGUpdate'">
152 <ItemGroup>
153 <_PGCFiles Include="$(OutDir)instrumented\$(TargetName)!*.pgc" />
154 <_PGDFile Include="$(OutDir)instrumented\$(TargetName).pgd" />
155 <_CopyFiles Include="@(_PGCFiles);@(_PGDFile)" Condition="Exists(%(FullPath))" />
156 </ItemGroup>
157 <Delete Files="@(_CopyFiles->'$(OutDir)%(Filename)%(Extension)')" />
158 <Error Text="PGO run did not succeed (no $(TargetName)!*.pgc files) and there is no data to merge"
159 Condition="$(RequirePGCFiles) == 'true' and @(_PGCFiles) == ''" />
160 <Copy SourceFiles="@(_CopyFiles)"
161 DestinationFolder="$(OutDir)"
162 UseHardLinksIfPossible="true"
163 OverwriteReadOnlyFiles="true" />
164 </Target>
165
Steve Dower425ec152016-10-09 20:18:52 -0700166 <PropertyGroup>
Steve Dower5fcd5e62017-09-06 10:01:38 -0700167 <SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\$(DefaultWindowsSDKVersion)\x86</SdkBinPath>
168 <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 -0700169 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
170 <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
171 <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 +0200172 <_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 -0700173 <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
Steve Dowerbb240872015-02-05 22:08:48 -0800174 </PropertyGroup>
175
176 <Target Name="_SignBuild" AfterTargets="AfterBuild" Condition="'$(SigningCertificate)' != '' and $(SupportSigning)">
177 <Error Text="Unable to locate signtool.exe. Set /p:SignToolPath and rebuild" Condition="'$(_SignCommand)' == ''" />
178 <Exec Command='$(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)"' ContinueOnError="false" />
179 </Target>
Zachary Warea191b912014-03-21 22:58:19 -0500180</Project>