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    <_Py3NamePreprocessorDefinition>PY3_DLLNAME=L"$(Py3DllName)";</_Py3NamePreprocessorDefinition>
30  </PropertyGroup>
31  <ItemDefinitionGroup>
32    <ClCompile>
33      <AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)PC;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
34      <PreprocessorDefinitions>WIN32;$(_Py3NamePreprocessorDefinition);$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PydPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
35
36      <Optimization>MaxSpeed</Optimization>
37      <IntrinsicFunctions>true</IntrinsicFunctions>
38      <StringPooling>true</StringPooling>
39      <ExceptionHandling></ExceptionHandling>
40      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
41      <FunctionLevelLinking>true</FunctionLevelLinking>
42      <WarningLevel>Level3</WarningLevel>
43      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
44      <CompileAs>Default</CompileAs>
45      <SuppressStartupBanner>true</SuppressStartupBanner>
46      <WholeProgramOptimization>true</WholeProgramOptimization>
47      <ControlFlowGuard Condition="$(EnableControlFlowGuard) != ''">$(EnableControlFlowGuard)</ControlFlowGuard>
48      <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
49    </ClCompile>
50    <ClCompile Condition="$(Configuration) == 'Debug'">
51      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
52      <Optimization>Disabled</Optimization>
53      <WholeProgramOptimization>false</WholeProgramOptimization>
54      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
55    </ClCompile>
56    <ClCompile Condition="$(ICCBuild) == 'true'">
57      <FloatingPointModel>Strict</FloatingPointModel>
58    </ClCompile>
59    <Link>
60      <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
61      <GenerateDebugInformation>true</GenerateDebugInformation>
62      <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
63      <SubSystem>Windows</SubSystem>
64      <RandomizedBaseAddress>true</RandomizedBaseAddress>
65      <DataExecutionPrevention>true</DataExecutionPrevention>
66      <SuppressStartupBanner>true</SuppressStartupBanner>
67      <IgnoreSpecificDefaultLibraries>LIBC;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
68      <TargetMachine>MachineX86</TargetMachine>
69      <TargetMachine Condition="'$(Platform)' == 'x64'">MachineX64</TargetMachine>
70      <TargetMachine Condition="'$(Platform)'=='ARM'">MachineARM</TargetMachine>
71      <TargetMachine Condition="'$(Platform)'=='ARM64'">MachineARM64</TargetMachine>
72      <ProfileGuidedDatabase Condition="$(SupportPGO)">$(OutDir)$(TargetName).pgd</ProfileGuidedDatabase>
73      <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
74      <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">PGInstrument</LinkTimeCodeGeneration>
75      <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">PGUpdate</LinkTimeCodeGeneration>
76      <AdditionalDependencies>advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
77    </Link>
78    <Lib>
79      <LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">true</LinkTimeCodeGeneration>
80      <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">true</LinkTimeCodeGeneration>
81      <LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">true</LinkTimeCodeGeneration>
82    </Lib>
83    <ResourceCompile>
84      <AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
85      <PreprocessorDefinitions>ORIGINAL_FILENAME=\"$(TargetName)$(TargetExt)\";FIELD3=$(Field3Value);$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
86      <Culture>0x0409</Culture>
87    </ResourceCompile>
88    <Midl>
89      <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
90      <MkTypLibCompatible>true</MkTypLibCompatible>
91      <SuppressStartupBanner>true</SuppressStartupBanner>
92      <TargetEnvironment>Win32</TargetEnvironment>
93      <TargetEnvironment Condition="'$(Platform)' == 'x64'">X64</TargetEnvironment>
94      <OutputDirectory>$(IntDir)</OutputDirectory>
95      <InterfaceIdentifierFileName>$(MSBuildProjectName)_i.c</InterfaceIdentifierFileName>
96      <ProxyFileName>$(MSBuildProjectName)_p.c</ProxyFileName>
97    </Midl>
98  </ItemDefinitionGroup>
99
100  <UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
101    <ParameterGroup>
102      <FileName Required="true" />
103    </ParameterGroup>
104    <Task>
105      <Using Namespace="System.Diagnostics"/>
106      <Using Namespace="System.IO"/>
107      <Using Namespace="System.Runtime.InteropServices"/>
108      <Using Namespace="System.Text"/>
109      <Code Type="Method" Language="cs">
110<![CDATA[
111[DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
112public static extern bool QueryFullProcessImageName([In]IntPtr hProcess, [In]int dwFlags,
113                                                    [Out]StringBuilder lpExeName, ref int lpdwSize);
114public override bool Execute() {
115    string fullPath = Path.GetFullPath(FileName);
116    Log.LogMessage("Looking for " + fullPath, MessageImportance.Normal);
117    foreach (Process p in Process.GetProcesses()) {
118        try {
119            int pathLength = 32768;
120            StringBuilder pathBuilder = new StringBuilder(pathLength);
121            if (QueryFullProcessImageName(p.Handle, 0, pathBuilder, ref pathLength)) {
122                string exeName = Path.GetFullPath(pathBuilder.ToString());
123                Log.LogMessage("Found running process: " + exeName, MessageImportance.Low);
124                if (fullPath.Equals(exeName, StringComparison.OrdinalIgnoreCase)) {
125                    Log.LogMessage("Terminating " + exeName, MessageImportance.High);
126                    p.Kill();
127                }
128            }
129        } catch {
130        }
131    }
132    return true;
133}
134]]>
135      </Code>
136    </Task>
137  </UsingTask>
138
139  <Target Name="KillPython" BeforeTargets="PrepareForBuild" Condition="'$(KillPython)' == 'true'">
140    <Message Text="Killing any running python$(PyDebugExt)$(PyTestExt).exe instances..." Importance="high" />
141    <KillPython FileName="$(OutDir)python$(PyDebugExt)$(PyTestExt).exe" />
142  </Target>
143
144  <!--
145  A default target to handle msbuild pcbuild.proj /t:CleanAll.
146
147  Some externals projects don't respond to /t:Clean, so we invoke
148  CleanAll on them when we really want to clean up.
149  -->
150  <Target Name="CleanAll" DependsOnTargets="Clean">
151    <MSBuild Projects="@(ProjectReference->'%(FullPath)')"
152             Properties="Configuration=$(Configuration);Platform=$(Platform)"
153             BuildInParallel="true"
154             StopOnFirstFailure="false"
155             Condition="Exists(%(FullPath))"
156             Targets="CleanAll" />
157  </Target>
158
159  <Target Name="CopyPGCFiles" BeforeTargets="PrepareForBuild" Condition="$(Configuration) == 'PGUpdate'">
160    <ItemGroup>
161      <_PGCFiles Include="$(OutDir)instrumented\$(TargetName)!*.pgc" />
162      <_PGDFile Include="$(OutDir)instrumented\$(TargetName).pgd" />
163      <_CopyFiles Include="@(_PGCFiles);@(_PGDFile)" Condition="Exists(%(FullPath))" />
164    </ItemGroup>
165    <Delete Files="@(_CopyFiles->'$(OutDir)%(Filename)%(Extension)')" />
166    <Error Text="PGO run did not succeed (no $(TargetName)!*.pgc files) and there is no data to merge"
167           Condition="$(RequirePGCFiles) == 'true' and @(_PGCFiles) == ''" />
168    <Copy SourceFiles="@(_CopyFiles)"
169          DestinationFolder="$(OutDir)"
170          UseHardLinksIfPossible="true"
171          OverwriteReadOnlyFiles="true" />
172  </Target>
173
174  <PropertyGroup>
175    <SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\$(DefaultWindowsSDKVersion)\x86</SdkBinPath>
176    <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\x86</SdkBinPath>
177    <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
178    <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
179    <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\</SdkBinPath>
180    <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificate)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /a /n "$(SigningCertificate)" /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d "Python $(PythonVersion)"</_SignCommand>
181    <_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificateSha1)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /a /sha1 "$(SigningCertificateSha1)" /fd sha256 /tr http://timestamp.digicert.com/ /td sha256 /d "Python $(PythonVersion)"</_SignCommand>
182    <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
183  </PropertyGroup>
184
185  <Target Name="_SignBuild" AfterTargets="AfterBuild" Condition="'$(_SignCommand)' != '' and $(SupportSigning)">
186    <Error Text="Unable to locate signtool.exe. Set /p:SignToolPath and rebuild" Condition="'$(_SignCommand)' == ''" />
187    <Exec Command='$(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)"' ContinueOnError="false" />
188  </Target>
189
190
191  <Target Name="FindVCRedistDir">
192    <!-- Hard coded path for VS 2015 -->
193    <PropertyGroup Condition="$(PlatformToolset) == 'v140'">
194      <VCRedistDir>$(VCInstallDir)\redist\</VCRedistDir>
195    </PropertyGroup>
196
197    <!-- Search for version number in some broken Build Tools installs -->
198    <ItemGroup Condition="$(VCRedistDir) == '' and $(VCToolsRedistVersion) == ''">
199      <_RedistFiles Include="$(VCInstallDir)\Redist\MSVC\*\*.*" />
200    </ItemGroup>
201    <PropertyGroup Condition="$(VCRedistDir) == '' and $(VCToolsRedistVersion) == ''">
202      <_RedistDir>%(_RedistFiles.Directory)</_RedistDir>
203      <VCToolsRedistVersion>$([System.IO.Path]::GetFileName($(_RedistDir.Trim(`\`))))</VCToolsRedistVersion>
204    </PropertyGroup>
205
206    <!-- Use correct path for VS 2017 and later -->
207    <PropertyGroup Condition="$(VCRedistDir) == ''">
208      <VCRedistDir>$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\</VCRedistDir>
209    </PropertyGroup>
210
211    <PropertyGroup>
212      <VCRedistDir Condition="$(Platform) == 'Win32'">$(VCRedistDir)x86\</VCRedistDir>
213      <VCRedistDir Condition="$(Platform) != 'Win32'">$(VCRedistDir)$(Platform)\</VCRedistDir>
214    </PropertyGroup>
215
216    <Message Text="VC Redist Directory: $(VCRedistDir)" />
217    <Message Text="VC Redist Version: $(VCToolsRedistVersion)" />
218  </Target>
219
220  <Target Name="FindVCRuntime" Returns="VCRuntimeDLL" DependsOnTargets="FindVCRedistDir">
221    <ItemGroup Condition="$(VCInstallDir) != ''">
222      <VCRuntimeDLL Include="$(VCRedistDir)\Microsoft.VC*.CRT\vcruntime*.dll" />
223    </ItemGroup>
224
225    <Warning Text="vcruntime*.dll not found under $(VCRedistDir)." Condition="@(VCRuntimeDLL) == ''" />
226    <Message Text="VC Runtime DLL(s):%0A- @(VCRuntimeDLL,'%0A- ')" />
227  </Target>
228</Project>
229