• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?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'" />
4  <PropertyGroup Label="Globals">
5    <__PyProject_Props_Imported>true</__PyProject_Props_Imported>
6    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
7    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
8    <OutDir>$(BuildPath)</OutDir>
9    <OutDir Condition="!HasTrailingSlash($(OutDir))">$(OutDir)\</OutDir>
10    <Py_IntDir Condition="'$(Py_IntDir)' == ''">$(MSBuildThisFileDirectory)obj\</Py_IntDir>
11    <IntDir>$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\$(ProjectName)\</IntDir>
12    <IntDir>$(IntDir.Replace(`\\`, `\`))</IntDir>
13    <TargetName Condition="'$(TargetName)' == ''">$(ProjectName)</TargetName>
14    <TargetName>$(TargetName)$(PyDebugExt)</TargetName>
15    <GenerateManifest>false</GenerateManifest>
16    <EmbedManifest>false</EmbedManifest>
17    <SupportPGO Condition="'$(SupportPGO)' == ''">true</SupportPGO>
18    <SupportSigning Condition="'$(SupportSigning)' == ''">true</SupportSigning>
19    <SupportSigning Condition="'$(Configuration)' == 'Debug'">false</SupportSigning>
20    <SupportSigning Condition="'$(ConfigurationType)' == 'StaticLibrary'">false</SupportSigning>
21  </PropertyGroup>
22
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>
29  </PropertyGroup>
30  <ItemDefinitionGroup>
31    <ClCompile>
32      <AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)PC;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
33      <PreprocessorDefinitions>WIN32;$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PydPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
34
35      <Optimization>MaxSpeed</Optimization>
36      <IntrinsicFunctions>true</IntrinsicFunctions>
37      <StringPooling>true</StringPooling>
38      <ExceptionHandling></ExceptionHandling>
39      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
40      <FunctionLevelLinking>true</FunctionLevelLinking>
41      <WarningLevel>Level3</WarningLevel>
42      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
43      <CompileAs>Default</CompileAs>
44      <SuppressStartupBanner>true</SuppressStartupBanner>
45      <WholeProgramOptimization>true</WholeProgramOptimization>
46      <EnableEnhancedInstructionSet Condition="'$(Platform)'=='Win32'">NoExtensions</EnableEnhancedInstructionSet>
47      <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OnlyExplicitInline</InlineFunctionExpansion>
48      <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OnlyExplicitInline</InlineFunctionExpansion>
49    </ClCompile>
50    <ClCompile Condition="$(Configuration) == 'Debug'">
51      <Optimization>Disabled</Optimization>
52      <WholeProgramOptimization>false</WholeProgramOptimization>
53      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
54    </ClCompile>
55    <ClCompile Condition="$(ICCBuild) == 'true'">
56      <FloatingPointModel>Strict</FloatingPointModel>
57    </ClCompile>
58    <Link>
59      <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
60      <GenerateDebugInformation>true</GenerateDebugInformation>
61      <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
62      <SubSystem>Windows</SubSystem>
63      <RandomizedBaseAddress>true</RandomizedBaseAddress>
64      <DataExecutionPrevention>true</DataExecutionPrevention>
65      <SuppressStartupBanner>true</SuppressStartupBanner>
66      <IgnoreSpecificDefaultLibraries>LIBC;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
67      <TargetMachine>MachineX86</TargetMachine>
68      <TargetMachine Condition="'$(Platform)' == 'x64'">MachineX64</TargetMachine>
69      <TargetMachine Condition="'$(Platform)'=='ARM'">MachineARM</TargetMachine>
70      <TargetMachine Condition="'$(Platform)'=='ARM64'">MachineARM64</TargetMachine>
71      <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>
75      <AdditionalDependencies>advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
76    </Link>
77    <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>
82    <ResourceCompile>
83      <AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
84      <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
85      <Culture>0x0409</Culture>
86    </ResourceCompile>
87    <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>
93      <OutputDirectory>$(IntDir)</OutputDirectory>
94      <InterfaceIdentifierFileName>$(MSBuildProjectName)_i.c</InterfaceIdentifierFileName>
95      <ProxyFileName>$(MSBuildProjectName)_p.c</ProxyFileName>
96    </Midl>
97  </ItemDefinitionGroup>
98
99  <Target Name="GeneratePythonNtRcH"
100          BeforeTargets="ClCompile"
101          Inputs="$(PySourcePath)Include\patchlevel.h"
102          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 */
105#define FIELD3 $(Field3Value)
106#define MS_DLL_ID "$(SysWinVer)"
107#define PYTHON_DLL_NAME "$(TargetName)$(TargetExt)"
108' />
109    <ItemGroup>
110        <FileWrites Include="$(IntDir)pythonnt_rc.h" />
111    </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>
119      <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">
124<![CDATA[
125[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 {
144        }
145    }
146    return true;
147}
148]]>
149      </Code>
150    </Task>
151  </UsingTask>
152
153  <Target Name="KillPython" BeforeTargets="PrepareForBuild" Condition="'$(KillPython)' == 'true'">
154    <Message Text="Killing any running python$(PyDebugExt)$(PyTestExt).exe instances..." Importance="high" />
155    <KillPython FileName="$(OutDir)python$(PyDebugExt)$(PyTestExt).exe" />
156  </Target>
157
158  <!--
159  A default target to handle msbuild pcbuild.proj /t:CleanAll.
160
161  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>
172
173  <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
188  <PropertyGroup>
189    <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>
191    <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>
194    <_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>
196    <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
197  </PropertyGroup>
198
199  <Target Name="_SignBuild" AfterTargets="AfterBuild" Condition="'$(_SignCommand)' != '' and $(SupportSigning)">
200    <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>
203</Project>
204