You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
12 KiB

  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. <PropertyGroup>
  23. <_DebugPreprocessorDefinition>NDEBUG;</_DebugPreprocessorDefinition>
  24. <_DebugPreprocessorDefinition Condition="$(Configuration) == 'Debug'">_DEBUG;</_DebugPreprocessorDefinition>
  25. <_PlatformPreprocessorDefinition>_WIN32;</_PlatformPreprocessorDefinition>
  26. <_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64'">_WIN64;_M_X64;</_PlatformPreprocessorDefinition>
  27. <_PydPreprocessorDefinition Condition="$(TargetExt) == '.pyd'">Py_BUILD_CORE_MODULE;</_PydPreprocessorDefinition>
  28. </PropertyGroup>
  29. <ItemDefinitionGroup>
  30. <ClCompile>
  31. <AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)PC;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  32. <PreprocessorDefinitions>WIN32;$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PydPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
  33. <Optimization>MaxSpeed</Optimization>
  34. <IntrinsicFunctions>true</IntrinsicFunctions>
  35. <StringPooling>true</StringPooling>
  36. <ExceptionHandling></ExceptionHandling>
  37. <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
  38. <FunctionLevelLinking>true</FunctionLevelLinking>
  39. <WarningLevel>Level3</WarningLevel>
  40. <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
  41. <CompileAs>Default</CompileAs>
  42. <SuppressStartupBanner>true</SuppressStartupBanner>
  43. <WholeProgramOptimization>true</WholeProgramOptimization>
  44. <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OnlyExplicitInline</InlineFunctionExpansion>
  45. <InlineFunctionExpansion Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OnlyExplicitInline</InlineFunctionExpansion>
  46. </ClCompile>
  47. <ClCompile Condition="$(Configuration) == 'Debug'">
  48. <Optimization>Disabled</Optimization>
  49. <WholeProgramOptimization>false</WholeProgramOptimization>
  50. <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
  51. </ClCompile>
  52. <ClCompile Condition="$(ICCBuild) == 'true'">
  53. <FloatingPointModel>Strict</FloatingPointModel>
  54. </ClCompile>
  55. <Link>
  56. <AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
  57. <GenerateDebugInformation>true</GenerateDebugInformation>
  58. <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
  59. <SubSystem>Windows</SubSystem>
  60. <RandomizedBaseAddress>true</RandomizedBaseAddress>
  61. <DataExecutionPrevention>true</DataExecutionPrevention>
  62. <SuppressStartupBanner>true</SuppressStartupBanner>
  63. <IgnoreSpecificDefaultLibraries>LIBC;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
  64. <TargetMachine>MachineX86</TargetMachine>
  65. <TargetMachine Condition="'$(Platform)' == 'x64'">MachineX64</TargetMachine>
  66. <TargetMachine Condition="'$(Platform)'=='ARM'">MachineARM</TargetMachine>
  67. <TargetMachine Condition="'$(Platform)'=='ARM64'">MachineARM64</TargetMachine>
  68. <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>
  72. <AdditionalDependencies>advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
  73. </Link>
  74. <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>
  79. <ResourceCompile>
  80. <AdditionalIncludeDirectories>$(PySourcePath)PC;$(PySourcePath)Include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  81. <PreprocessorDefinitions>$(_DebugPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
  82. <Culture>0x0409</Culture>
  83. </ResourceCompile>
  84. <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>
  90. <OutputDirectory>$(IntDir)</OutputDirectory>
  91. <InterfaceIdentifierFileName>$(MSBuildProjectName)_i.c</InterfaceIdentifierFileName>
  92. <ProxyFileName>$(MSBuildProjectName)_p.c</ProxyFileName>
  93. </Midl>
  94. </ItemDefinitionGroup>
  95. <Target Name="GeneratePythonNtRcH"
  96. BeforeTargets="ClCompile"
  97. Inputs="$(PySourcePath)Include\patchlevel.h"
  98. Outputs="$(IntDir)pythonnt_rc.h">
  99. <WriteLinesToFile File="$(IntDir)pythonnt_rc.h" Overwrite="true" Encoding="ascii"
  100. Lines='/* This file created by pyproject.props /t:GeneratePythonNtRcH */
  101. #define FIELD3 $(Field3Value)
  102. #define MS_DLL_ID "$(SysWinVer)"
  103. #define PYTHON_DLL_NAME "$(TargetName)$(TargetExt)"
  104. ' />
  105. <ItemGroup>
  106. <FileWrites Include="$(IntDir)pythonnt_rc.h" />
  107. </ItemGroup>
  108. </Target>
  109. <UsingTask TaskName="KillPython" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
  110. <ParameterGroup>
  111. <FileName Required="true" />
  112. </ParameterGroup>
  113. <Task>
  114. <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">
  119. <![CDATA[
  120. [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
  121. public static extern bool QueryFullProcessImageName([In]IntPtr hProcess, [In]int dwFlags,
  122. [Out]StringBuilder lpExeName, ref int lpdwSize);
  123. public 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 {
  139. }
  140. }
  141. return true;
  142. }
  143. ]]>
  144. </Code>
  145. </Task>
  146. </UsingTask>
  147. <Target Name="KillPython" BeforeTargets="PrepareForBuild" Condition="'$(KillPython)' == 'true'">
  148. <Message Text="Killing any running python$(PyDebugExt)$(PyTestExt).exe instances..." Importance="high" />
  149. <KillPython FileName="$(OutDir)python$(PyDebugExt)$(PyTestExt).exe" />
  150. </Target>
  151. <!--
  152. A default target to handle msbuild pcbuild.proj /t:CleanAll.
  153. Some externals projects don't respond to /t:Clean, so we invoke
  154. CleanAll on them when we really want to clean up.
  155. -->
  156. <Target Name="CleanAll" DependsOnTargets="Clean">
  157. <MSBuild Projects="@(ProjectReference->'%(FullPath)')"
  158. Properties="Configuration=$(Configuration);Platform=$(Platform)"
  159. BuildInParallel="true"
  160. StopOnFirstFailure="false"
  161. Condition="Exists(%(FullPath))"
  162. Targets="CleanAll" />
  163. </Target>
  164. <Target Name="CopyPGCFiles" BeforeTargets="PrepareForBuild" Condition="$(Configuration) == 'PGUpdate'">
  165. <ItemGroup>
  166. <_PGCFiles Include="$(OutDir)instrumented\$(TargetName)!*.pgc" />
  167. <_PGDFile Include="$(OutDir)instrumented\$(TargetName).pgd" />
  168. <_CopyFiles Include="@(_PGCFiles);@(_PGDFile)" Condition="Exists(%(FullPath))" />
  169. </ItemGroup>
  170. <Delete Files="@(_CopyFiles->'$(OutDir)%(Filename)%(Extension)')" />
  171. <Error Text="PGO run did not succeed (no $(TargetName)!*.pgc files) and there is no data to merge"
  172. Condition="$(RequirePGCFiles) == 'true' and @(_PGCFiles) == ''" />
  173. <Copy SourceFiles="@(_CopyFiles)"
  174. DestinationFolder="$(OutDir)"
  175. UseHardLinksIfPossible="true"
  176. OverwriteReadOnlyFiles="true" />
  177. </Target>
  178. <PropertyGroup>
  179. <SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\$(DefaultWindowsSDKVersion)\x86</SdkBinPath>
  180. <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\x86</SdkBinPath>
  181. <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
  182. <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
  183. <SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\</SdkBinPath>
  184. <_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>
  185. <_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>
  186. <_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
  187. </PropertyGroup>
  188. <Target Name="_SignBuild" AfterTargets="AfterBuild" Condition="'$(_SignCommand)' != '' and $(SupportSigning)">
  189. <Error Text="Unable to locate signtool.exe. Set /p:SignToolPath and rebuild" Condition="'$(_SignCommand)' == ''" />
  190. <Exec Command='$(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)"' ContinueOnError="false" />
  191. </Target>
  192. </Project>