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.

151 lines
9.1 KiB

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3. <PropertyGroup>
  4. <Platform Condition="'$(Platform)' == ''">Win32</Platform>
  5. <Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
  6. <!--
  7. Use the latest available version of Visual Studio to build. To override
  8. this and build with an earlier version, pass "/p:PlatformToolset=v100"
  9. (for example) when building.
  10. -->
  11. <PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(VCTargetsPath14)' != ''">v140</PlatformToolset>
  12. <PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(VCTargetsPath12)' != ''">v120</PlatformToolset>
  13. <PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(VCTargetsPath11)' != ''">v110</PlatformToolset>
  14. <PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(VCTargetsPath10)' != ''">v100</PlatformToolset>
  15. <!--
  16. Convincing MSVC/MSBuild to prefer our platform names is too difficult,
  17. so we define our own constant ArchName and use wherever we need it.
  18. -->
  19. <ArchName Condition="'$(ArchName)' == '' and $(Platform) == 'x64'">amd64</ArchName>
  20. <ArchName Condition="'$(ArchName)' == ''">win32</ArchName>
  21. <ArchName Condition="$(Configuration) == 'PGInstrument' or $(Configuration) == 'PGUpdate'">$(ArchName)-pgo</ArchName>
  22. <!-- Root directory of the repository -->
  23. <PySourcePath Condition="'$(PySourcePath)' == ''">$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\))</PySourcePath>
  24. <PySourcePath Condition="!HasTrailingSlash($(PySourcePath))">$(PySourcePath)\</PySourcePath>
  25. <!-- Directory where build outputs are put -->
  26. <BuildPath Condition="'$(BuildPath)' == ''">$(PySourcePath)PCBuild\$(ArchName)\</BuildPath>
  27. <BuildPath Condition="!HasTrailingSlash($(BuildPath))">$(BuildPath)\</BuildPath>
  28. <!-- Directories of external projects. tcltk is handled in tcltk.props -->
  29. <ExternalsDir>$([System.IO.Path]::GetFullPath(`$(PySourcePath)externals\`))</ExternalsDir>
  30. <sqlite3Dir>$(ExternalsDir)sqlite-3.8.3.1\</sqlite3Dir>
  31. <bz2Dir>$(ExternalsDir)bzip2-1.0.6\</bz2Dir>
  32. <lzmaDir>$(ExternalsDir)xz-5.0.5\</lzmaDir>
  33. <opensslDir>$(ExternalsDir)openssl-1.0.2d\</opensslDir>
  34. <nasmDir>$(ExternalsDir)\nasm-2.11.06\</nasmDir>
  35. <!-- Suffix for all binaries when building for debug -->
  36. <PyDebugExt Condition="'$(PyDebugExt)' == '' and $(Configuration) == 'Debug'">_d</PyDebugExt>
  37. <!-- Full path of the resulting python.exe binary -->
  38. <PythonExe Condition="'$(PythonExe)' == ''">$(BuildPath)python$(PyDebugExt).exe</PythonExe>
  39. </PropertyGroup>
  40. <PropertyGroup Condition="'$(OverrideVersion)' == ''">
  41. <!--
  42. Read version information from Include\patchlevel.h. The following properties are set:
  43. MajorVersionNumber - the '3' in '3.5.2a1'
  44. MinorVersionNumber - the '5' in '3.5.2a1'
  45. MicroVersionNumber - the '2' in '3.5.2a1'
  46. ReleaseSerial - the '1' in '3.5.2a1'
  47. ReleaseLevelName - the 'a1' in '3.5.2a1'
  48. PythonVersionNumber - '3.5.2' for '3.5.2a1'
  49. PythonVersion - '3.5.2a1'
  50. PythonVersionHex - 0x030502a1 for '3.5.2a1'
  51. ReleaseLevelNumber - 10 for alpha, 11 for beta, 12 for RC (gamma), and 15 for final
  52. Field3Value - 2101 for '3.5.2a1' (== 1000*2 + 10*10 ('a') + 1)
  53. -->
  54. <_PatchLevelContent>$([System.IO.File]::ReadAllText(`$(PySourcePath)Include\patchlevel.h`))</_PatchLevelContent>
  55. <MajorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MAJOR_VERSION\s+(\d+)`).Groups[1].Value)</MajorVersionNumber>
  56. <MinorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MINOR_VERSION\s+(\d+)`).Groups[1].Value)</MinorVersionNumber>
  57. <MicroVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MICRO_VERSION\s+(\d+)`).Groups[1].Value)</MicroVersionNumber>
  58. <_ReleaseLevel>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_RELEASE_LEVEL\s+PY_RELEASE_LEVEL_(\w+)`).Groups[1].Value)</_ReleaseLevel>
  59. <ReleaseSerial>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_RELEASE_SERIAL\s+(\d+)`).Groups[1].Value)</ReleaseSerial>
  60. <ReleaseLevelNumber>15</ReleaseLevelNumber>
  61. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'ALPHA'">10</ReleaseLevelNumber>
  62. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'BETA'">11</ReleaseLevelNumber>
  63. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'GAMMA'">12</ReleaseLevelNumber>
  64. <ReleaseLevelName Condition="$(_ReleaseLevel) == 'ALPHA'">a$(ReleaseSerial)</ReleaseLevelName>
  65. <ReleaseLevelName Condition="$(_ReleaseLevel) == 'BETA'">b$(ReleaseSerial)</ReleaseLevelName>
  66. <ReleaseLevelName Condition="$(_ReleaseLevel) == 'GAMMA'">rc$(ReleaseSerial)</ReleaseLevelName>
  67. </PropertyGroup>
  68. <PropertyGroup Condition="'$(OverrideVersion)' != ''">
  69. <!--
  70. Override the version number when building by specifying OverrideVersion.
  71. For example:
  72. PCBuild\build.bat "/p:OverrideVersion=3.5.2a1"
  73. Use the -V option to check your version is valid:
  74. PCBuild\build.bat -V "/p:OverrideVersion=3.5.2a1"
  75. PythonVersionNumber: 3.5.2
  76. PythonVersion: 3.5.2a1
  77. PythonVersionHex: 0x030502A1
  78. Field3Value: 2101
  79. Note that this only affects the version numbers embedded in resources and
  80. installers, but not sys.version.
  81. -->
  82. <MajorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[1].Value)</MajorVersionNumber>
  83. <MinorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[2].Value)</MinorVersionNumber>
  84. <MicroVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[3].Value)</MicroVersionNumber>
  85. <ReleaseLevelName>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[4].Value)</ReleaseLevelName>
  86. <_ReleaseLevel>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[5].Value)</_ReleaseLevel>
  87. <ReleaseSerial>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[6].Value)</ReleaseSerial>
  88. <ReleaseSerial Condition="'$(ReleaseSerial)' == ''">0</ReleaseSerial>
  89. <ReleaseLevelNumber>15</ReleaseLevelNumber>
  90. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'a'">10</ReleaseLevelNumber>
  91. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'b'">11</ReleaseLevelNumber>
  92. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'rc'">12</ReleaseLevelNumber>
  93. </PropertyGroup>
  94. <PropertyGroup>
  95. <PythonVersionNumber>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)</PythonVersionNumber>
  96. <PythonVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)$(ReleaseLevelName)</PythonVersion>
  97. <PythonVersionHex>$([msbuild]::BitwiseOr(
  98. $([msbuild]::Multiply($(MajorVersionNumber), 16777216)),
  99. $([msbuild]::BitwiseOr(
  100. $([msbuild]::Multiply($(MinorVersionNumber), 65536)),
  101. $([msbuild]::BitwiseOr(
  102. $([msbuild]::Multiply($(MicroVersionNumber), 256)),
  103. $([msbuild]::BitwiseOr(
  104. $([msbuild]::Multiply($(ReleaseLevelNumber), 16)),
  105. $(ReleaseSerial)
  106. ))
  107. ))
  108. ))
  109. ))</PythonVersionHex>
  110. <Field3Value>$([msbuild]::Add(
  111. $(ReleaseSerial),
  112. $([msbuild]::Add(
  113. $([msbuild]::Multiply($(ReleaseLevelNumber), 10)),
  114. $([msbuild]::Multiply($(MicroVersionNumber), 1000))
  115. ))
  116. ))</Field3Value>
  117. <!-- The name of the resulting pythonXY.dll (without the extension) -->
  118. <PyDllName>python$(MajorVersionNumber)$(MinorVersionNumber)$(PyDebugExt)</PyDllName>
  119. <!-- The version and platform tag to include in .pyd filenames -->
  120. <PydTag Condition="$(Platform) == 'Win32' or $(Platform) == 'x86'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
  121. <PydTag Condition="$(Platform) == 'x64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_amd64</PydTag>
  122. <!-- The version number for sys.winver -->
  123. <SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)</SysWinVer>
  124. <SysWinVer Condition="$(Platform) == 'Win32' or $(Platform) == 'x86'">$(SysWinVer)-32</SysWinVer>
  125. </PropertyGroup>
  126. <!-- Displays the calculated version info -->
  127. <Target Name="ShowVersionInfo">
  128. <Message Importance="high" Text="PythonVersionNumber: $(PythonVersionNumber)" />
  129. <Message Importance="high" Text="PythonVersion: $(PythonVersion)" />
  130. <Message Importance="high" Text="PythonVersionHex: 0x$([System.UInt32]::Parse($(PythonVersionHex)).ToString(`X08`))" />
  131. <Message Importance="high" Text="Field3Value: $(Field3Value)" />
  132. </Target>
  133. </Project>