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