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.

152 lines
9.2 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="'$(PyBuildPath)' == ''">$(PySourcePath)PCBuild\$(ArchName)\</BuildPath>
  27. <BuildPath Condition="'$(PyBuildPath)' != ''">$(PyBuildPath)</BuildPath>
  28. <BuildPath Condition="!HasTrailingSlash($(BuildPath))">$(BuildPath)\</BuildPath>
  29. <!-- Directories of external projects. tcltk is handled in tcltk.props -->
  30. <ExternalsDir>$([System.IO.Path]::GetFullPath(`$(PySourcePath)externals\`))</ExternalsDir>
  31. <sqlite3Dir>$(ExternalsDir)sqlite-3.8.11.0\</sqlite3Dir>
  32. <bz2Dir>$(ExternalsDir)bzip2-1.0.6\</bz2Dir>
  33. <lzmaDir>$(ExternalsDir)xz-5.0.5\</lzmaDir>
  34. <opensslDir>$(ExternalsDir)openssl-1.0.2d\</opensslDir>
  35. <nasmDir>$(ExternalsDir)\nasm-2.11.06\</nasmDir>
  36. <!-- Suffix for all binaries when building for debug -->
  37. <PyDebugExt Condition="'$(PyDebugExt)' == '' and $(Configuration) == 'Debug'">_d</PyDebugExt>
  38. <!-- Full path of the resulting python.exe binary -->
  39. <PythonExe Condition="'$(PythonExe)' == ''">$(BuildPath)python$(PyDebugExt).exe</PythonExe>
  40. </PropertyGroup>
  41. <PropertyGroup Condition="'$(OverrideVersion)' == ''">
  42. <!--
  43. Read version information from Include\patchlevel.h. The following properties are set:
  44. MajorVersionNumber - the '3' in '3.5.2a1'
  45. MinorVersionNumber - the '5' in '3.5.2a1'
  46. MicroVersionNumber - the '2' in '3.5.2a1'
  47. ReleaseSerial - the '1' in '3.5.2a1'
  48. ReleaseLevelName - the 'a1' in '3.5.2a1'
  49. PythonVersionNumber - '3.5.2' for '3.5.2a1'
  50. PythonVersion - '3.5.2a1'
  51. PythonVersionHex - 0x030502a1 for '3.5.2a1'
  52. ReleaseLevelNumber - 10 for alpha, 11 for beta, 12 for RC (gamma), and 15 for final
  53. Field3Value - 2101 for '3.5.2a1' (== 1000*2 + 10*10 ('a') + 1)
  54. -->
  55. <_PatchLevelContent>$([System.IO.File]::ReadAllText(`$(PySourcePath)Include\patchlevel.h`))</_PatchLevelContent>
  56. <MajorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MAJOR_VERSION\s+(\d+)`).Groups[1].Value)</MajorVersionNumber>
  57. <MinorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MINOR_VERSION\s+(\d+)`).Groups[1].Value)</MinorVersionNumber>
  58. <MicroVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MICRO_VERSION\s+(\d+)`).Groups[1].Value)</MicroVersionNumber>
  59. <_ReleaseLevel>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_RELEASE_LEVEL\s+PY_RELEASE_LEVEL_(\w+)`).Groups[1].Value)</_ReleaseLevel>
  60. <ReleaseSerial>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_RELEASE_SERIAL\s+(\d+)`).Groups[1].Value)</ReleaseSerial>
  61. <ReleaseLevelNumber>15</ReleaseLevelNumber>
  62. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'ALPHA'">10</ReleaseLevelNumber>
  63. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'BETA'">11</ReleaseLevelNumber>
  64. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'GAMMA'">12</ReleaseLevelNumber>
  65. <ReleaseLevelName Condition="$(_ReleaseLevel) == 'ALPHA'">a$(ReleaseSerial)</ReleaseLevelName>
  66. <ReleaseLevelName Condition="$(_ReleaseLevel) == 'BETA'">b$(ReleaseSerial)</ReleaseLevelName>
  67. <ReleaseLevelName Condition="$(_ReleaseLevel) == 'GAMMA'">rc$(ReleaseSerial)</ReleaseLevelName>
  68. </PropertyGroup>
  69. <PropertyGroup Condition="'$(OverrideVersion)' != ''">
  70. <!--
  71. Override the version number when building by specifying OverrideVersion.
  72. For example:
  73. PCBuild\build.bat "/p:OverrideVersion=3.5.2a1"
  74. Use the -V option to check your version is valid:
  75. PCBuild\build.bat -V "/p:OverrideVersion=3.5.2a1"
  76. PythonVersionNumber: 3.5.2
  77. PythonVersion: 3.5.2a1
  78. PythonVersionHex: 0x030502A1
  79. Field3Value: 2101
  80. Note that this only affects the version numbers embedded in resources and
  81. installers, but not sys.version.
  82. -->
  83. <MajorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[1].Value)</MajorVersionNumber>
  84. <MinorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[2].Value)</MinorVersionNumber>
  85. <MicroVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[3].Value)</MicroVersionNumber>
  86. <ReleaseLevelName>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[4].Value)</ReleaseLevelName>
  87. <_ReleaseLevel>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[5].Value)</_ReleaseLevel>
  88. <ReleaseSerial>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[6].Value)</ReleaseSerial>
  89. <ReleaseSerial Condition="'$(ReleaseSerial)' == ''">0</ReleaseSerial>
  90. <ReleaseLevelNumber>15</ReleaseLevelNumber>
  91. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'a'">10</ReleaseLevelNumber>
  92. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'b'">11</ReleaseLevelNumber>
  93. <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'rc'">12</ReleaseLevelNumber>
  94. </PropertyGroup>
  95. <PropertyGroup>
  96. <PythonVersionNumber>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)</PythonVersionNumber>
  97. <PythonVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)$(ReleaseLevelName)</PythonVersion>
  98. <PythonVersionHex>$([msbuild]::BitwiseOr(
  99. $([msbuild]::Multiply($(MajorVersionNumber), 16777216)),
  100. $([msbuild]::BitwiseOr(
  101. $([msbuild]::Multiply($(MinorVersionNumber), 65536)),
  102. $([msbuild]::BitwiseOr(
  103. $([msbuild]::Multiply($(MicroVersionNumber), 256)),
  104. $([msbuild]::BitwiseOr(
  105. $([msbuild]::Multiply($(ReleaseLevelNumber), 16)),
  106. $(ReleaseSerial)
  107. ))
  108. ))
  109. ))
  110. ))</PythonVersionHex>
  111. <Field3Value>$([msbuild]::Add(
  112. $(ReleaseSerial),
  113. $([msbuild]::Add(
  114. $([msbuild]::Multiply($(ReleaseLevelNumber), 10)),
  115. $([msbuild]::Multiply($(MicroVersionNumber), 1000))
  116. ))
  117. ))</Field3Value>
  118. <!-- The name of the resulting pythonXY.dll (without the extension) -->
  119. <PyDllName>python$(MajorVersionNumber)$(MinorVersionNumber)$(PyDebugExt)</PyDllName>
  120. <!-- The version and platform tag to include in .pyd filenames -->
  121. <PydTag Condition="$(Platform) == 'Win32' or $(Platform) == 'x86'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
  122. <PydTag Condition="$(Platform) == 'x64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_amd64</PydTag>
  123. <!-- The version number for sys.winver -->
  124. <SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)</SysWinVer>
  125. <SysWinVer Condition="$(Platform) == 'Win32' or $(Platform) == 'x86'">$(SysWinVer)-32</SysWinVer>
  126. </PropertyGroup>
  127. <!-- Displays the calculated version info -->
  128. <Target Name="ShowVersionInfo">
  129. <Message Importance="high" Text="PythonVersionNumber: $(PythonVersionNumber)" />
  130. <Message Importance="high" Text="PythonVersion: $(PythonVersion)" />
  131. <Message Importance="high" Text="PythonVersionHex: 0x$([System.UInt32]::Parse($(PythonVersionHex)).ToString(`X08`))" />
  132. <Message Importance="high" Text="Field3Value: $(Field3Value)" />
  133. </Target>
  134. </Project>