• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="utf-8"?>
2<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3  <PropertyGroup>
4    <__Python_Props_Imported>true</__Python_Props_Imported>
5    <Platform Condition="'$(Platform)' == ''">Win32</Platform>
6    <Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
7    <!--
8    Use the latest available version of Visual Studio to build. To override
9    this and build with an earlier version, pass "/p:PlatformToolset=v100"
10    (for example) when building.
11
12    We set BasePlatformToolset for ICC's benefit, it's otherwise ignored.
13    -->
14    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and ('$(MSBuildToolsVersion)' == '16.0' or '$(VisualStudioVersion)' == '16.0')">v142</BasePlatformToolset>
15    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and ('$(MSBuildToolsVersion)' == '15.0' or '$(VisualStudioVersion)' == '15.0')">v141</BasePlatformToolset>
16    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath14)' != ''">v140</BasePlatformToolset>
17    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath12)' != ''">v120</BasePlatformToolset>
18    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath11)' != ''">v110</BasePlatformToolset>
19    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath10)' != ''">v100</BasePlatformToolset>
20
21    <PlatformToolset Condition="'$(PlatformToolset)' == ''">$(BasePlatformToolset)</PlatformToolset>
22    <ICCBuild>false</ICCBuild>
23    <ICCBuild Condition="$(PlatformToolset.StartsWith(`Intel C++ Compiler`))">true</ICCBuild>
24
25    <!--
26    Convincing MSVC/MSBuild to prefer our platform names is too difficult,
27    so we define our own constant ArchName and use wherever we need it.
28    -->
29    <ArchName Condition="'$(ArchName)' == '' and $(Platform) == 'x64'">amd64</ArchName>
30    <ArchName Condition="'$(ArchName)' == '' and $(Platform) == 'ARM'">arm32</ArchName>
31    <ArchName Condition="'$(ArchName)' == '' and $(Platform) == 'ARM64'">arm64</ArchName>
32    <ArchName Condition="'$(ArchName)' == ''">win32</ArchName>
33
34    <!-- Root directory of the repository -->
35    <PySourcePath Condition="'$(PySourcePath)' == ''">$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\))</PySourcePath>
36    <PySourcePath Condition="!HasTrailingSlash($(PySourcePath))">$(PySourcePath)\</PySourcePath>
37
38    <!-- Directory where build outputs are put -->
39    <BuildPath32 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\win32\</BuildPath32>
40    <BuildPath32 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\win32\</BuildPath32>
41    <BuildPath64 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\amd64\</BuildPath64>
42    <BuildPath64 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\amd64\</BuildPath64>
43    <BuildPathArm32 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\arm32\</BuildPathArm32>
44    <BuildPathArm32 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\arm32\</BuildPathArm32>
45    <BuildPathArm64 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\arm64\</BuildPathArm64>
46    <BuildPathArm64 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\arm64\</BuildPathArm64>
47    <BuildPath Condition="'$(ArchName)' == 'win32'">$(BuildPath32)</BuildPath>
48    <BuildPath Condition="'$(ArchName)' == 'amd64'">$(BuildPath64)</BuildPath>
49    <BuildPath Condition="'$(ArchName)' == 'arm32'">$(BuildPathArm32)</BuildPath>
50    <BuildPath Condition="'$(ArchName)' == 'arm64'">$(BuildPathArm64)</BuildPath>
51    <BuildPath Condition="'$(BuildPath)' == ''">$(PySourcePath)PCbuild\$(ArchName)\</BuildPath>
52    <BuildPath Condition="!HasTrailingSlash($(BuildPath))">$(BuildPath)\</BuildPath>
53    <BuildPath Condition="$(Configuration) == 'PGInstrument'">$(BuildPath)instrumented\</BuildPath>
54
55    <!-- Directories of external projects. tcltk is handled in tcltk.props -->
56    <ExternalsDir>$(EXTERNALS_DIR)</ExternalsDir>
57    <ExternalsDir Condition="$(ExternalsDir) == ''">$([System.IO.Path]::GetFullPath(`$(PySourcePath)externals`))</ExternalsDir>
58    <ExternalsDir Condition="!HasTrailingSlash($(ExternalsDir))">$(ExternalsDir)\</ExternalsDir>
59    <sqlite3Dir>$(ExternalsDir)sqlite-3.33.0.0\</sqlite3Dir>
60    <bz2Dir>$(ExternalsDir)bzip2-1.0.6\</bz2Dir>
61    <lzmaDir>$(ExternalsDir)xz-5.2.2\</lzmaDir>
62    <libffiDir>$(ExternalsDir)libffi\</libffiDir>
63    <libffiOutDir>$(ExternalsDir)libffi\$(ArchName)\</libffiOutDir>
64    <libffiIncludeDir>$(libffiOutDir)include</libffiIncludeDir>
65    <opensslDir>$(ExternalsDir)openssl-1.1.1g\</opensslDir>
66    <opensslOutDir>$(ExternalsDir)openssl-bin-1.1.1g\$(ArchName)\</opensslOutDir>
67    <opensslIncludeDir>$(opensslOutDir)include</opensslIncludeDir>
68    <nasmDir>$(ExternalsDir)\nasm-2.11.06\</nasmDir>
69    <zlibDir>$(ExternalsDir)\zlib-1.2.11\</zlibDir>
70
71    <!-- Suffix for all binaries when building for debug -->
72    <PyDebugExt Condition="'$(PyDebugExt)' == '' and $(Configuration) == 'Debug'">_d</PyDebugExt>
73
74    <!-- Suffix for versions/keys when building with test markers -->
75    <PyTestExt Condition="$(UseTestMarker) == 'true'">-test</PyTestExt>
76
77    <!-- Suffix for versions/keys when building for particular platforms -->
78    <PyArchExt Condition="'$(ArchName)' == 'win32'">-32</PyArchExt>
79    <PyArchExt Condition="'$(ArchName)' == 'arm32'">-arm32</PyArchExt>
80    <PyArchExt Condition="'$(ArchName)' == 'arm64'">-arm64</PyArchExt>
81
82    <!-- Full path of the resulting python.exe binary -->
83    <PythonExe Condition="'$(PythonExe)' == ''">$(BuildPath)python$(PyDebugExt).exe</PythonExe>
84
85    <!-- Include Tkinter by default -->
86    <IncludeTkinter Condition="'$(IncludeTkinter)' == ''">true</IncludeTkinter>
87  </PropertyGroup>
88
89  <PropertyGroup Condition="'$(Platform)'=='ARM'" Label="ArmConfiguration">
90    <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
91  </PropertyGroup>
92
93  <PropertyGroup Condition="'$(Platform)'=='ARM64'" Label="Arm64Configuration">
94    <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
95  </PropertyGroup>
96
97  <PropertyGroup Condition="$(DefaultWindowsSDKVersion) == ''">
98    <!--
99    Attempt to select the latest installed WinSDK. If we don't find any, then we will
100    let the MSBuild targets determine which one it wants to use (typically the earliest
101    possible version). Since we limit WINVER to Windows 7 anyway, it doesn't really
102    matter which WinSDK version we use.
103    -->
104    <_RegistryVersion>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion)</_RegistryVersion>
105    <_RegistryVersion Condition="$(_RegistryVersion) == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion)</_RegistryVersion>
106    <!-- Sometimes the version in the registry has to .0 suffix, and sometimes it doesn't. Check and add it -->
107    <_RegistryVersion Condition="$(_RegistryVersion) != '' and !$(_RegistryVersion.EndsWith('.0'))">$(_RegistryVersion).0</_RegistryVersion>
108
109    <!-- The minimum allowed SDK version to use for building -->
110    <DefaultWindowsSDKVersion>10.0.10586.0</DefaultWindowsSDKVersion>
111    <DefaultWindowsSDKVersion Condition="$([System.Version]::Parse($(_RegistryVersion))) > $([System.Version]::Parse($(DefaultWindowsSDKVersion)))">$(_RegistryVersion)</DefaultWindowsSDKVersion>
112  </PropertyGroup>
113
114  <PropertyGroup Condition="$(WindowsTargetPlatformVersion) == ''">
115    <WindowsTargetPlatformVersion>$(DefaultWindowsSDKVersion)</WindowsTargetPlatformVersion>
116  </PropertyGroup>
117
118  <PropertyGroup Condition="'$(OverrideVersion)' == ''">
119    <!--
120    Read version information from Include\patchlevel.h. The following properties are set:
121
122        MajorVersionNumber  -   the '3' in '3.5.2a1'
123        MinorVersionNumber  -   the '5' in '3.5.2a1'
124        MicroVersionNumber  -   the '2' in '3.5.2a1'
125        ReleaseSerial       -   the '1' in '3.5.2a1'
126        ReleaseLevelName    -   the 'a1' in '3.5.2a1'
127        PythonVersionNumber -   '3.5.2' for '3.5.2a1'
128        PythonVersion       -   '3.5.2a1'
129        PythonVersionHex    -   0x030502a1 for '3.5.2a1'
130        ReleaseLevelNumber  -   10 for alpha, 11 for beta, 12 for RC (gamma), and 15 for final
131        Field3Value         -   2101 for '3.5.2a1' (== 1000*2 + 10*10 ('a') + 1)
132    -->
133    <_PatchLevelContent>$([System.IO.File]::ReadAllText(`$(PySourcePath)Include\patchlevel.h`))</_PatchLevelContent>
134    <MajorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MAJOR_VERSION\s+(\d+)`).Groups[1].Value)</MajorVersionNumber>
135    <MinorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MINOR_VERSION\s+(\d+)`).Groups[1].Value)</MinorVersionNumber>
136    <MicroVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MICRO_VERSION\s+(\d+)`).Groups[1].Value)</MicroVersionNumber>
137    <_ReleaseLevel>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_RELEASE_LEVEL\s+PY_RELEASE_LEVEL_(\w+)`).Groups[1].Value)</_ReleaseLevel>
138    <ReleaseSerial>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_RELEASE_SERIAL\s+(\d+)`).Groups[1].Value)</ReleaseSerial>
139    <ReleaseLevelNumber>15</ReleaseLevelNumber>
140    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'ALPHA'">10</ReleaseLevelNumber>
141    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'BETA'">11</ReleaseLevelNumber>
142    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'GAMMA'">12</ReleaseLevelNumber>
143    <ReleaseLevelName Condition="$(_ReleaseLevel) == 'ALPHA'">a$(ReleaseSerial)</ReleaseLevelName>
144    <ReleaseLevelName Condition="$(_ReleaseLevel) == 'BETA'">b$(ReleaseSerial)</ReleaseLevelName>
145    <ReleaseLevelName Condition="$(_ReleaseLevel) == 'GAMMA'">rc$(ReleaseSerial)</ReleaseLevelName>
146  </PropertyGroup>
147
148  <PropertyGroup Condition="'$(OverrideVersion)' != ''">
149    <!--
150    Override the version number when building by specifying OverrideVersion.
151    For example:
152
153        PCbuild\build.bat "/p:OverrideVersion=3.5.2a1"
154
155    Use the -V option to check your version is valid:
156
157        PCbuild\build.bat -V "/p:OverrideVersion=3.5.2a1"
158          PythonVersionNumber: 3.5.2
159          PythonVersion:       3.5.2a1
160          PythonVersionHex:    0x030502A1
161          Field3Value:         2101
162
163    Note that this only affects the version numbers embedded in resources and
164    installers, but not sys.version.
165    -->
166    <MajorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[1].Value)</MajorVersionNumber>
167    <MinorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[2].Value)</MinorVersionNumber>
168    <MicroVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[3].Value)</MicroVersionNumber>
169    <ReleaseLevelName>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[4].Value)</ReleaseLevelName>
170    <_ReleaseLevel>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[5].Value)</_ReleaseLevel>
171    <ReleaseSerial>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[6].Value)</ReleaseSerial>
172    <ReleaseSerial Condition="'$(ReleaseSerial)' == ''">0</ReleaseSerial>
173    <ReleaseLevelNumber>15</ReleaseLevelNumber>
174    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'a'">10</ReleaseLevelNumber>
175    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'b'">11</ReleaseLevelNumber>
176    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'rc'">12</ReleaseLevelNumber>
177  </PropertyGroup>
178
179  <PropertyGroup>
180    <PythonVersionNumber>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)</PythonVersionNumber>
181    <PythonVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)$(ReleaseLevelName)</PythonVersion>
182    <PythonVersionHex>$([msbuild]::BitwiseOr(
183        $([msbuild]::Multiply($(MajorVersionNumber), 16777216)),
184        $([msbuild]::BitwiseOr(
185            $([msbuild]::Multiply($(MinorVersionNumber), 65536)),
186            $([msbuild]::BitwiseOr(
187                $([msbuild]::Multiply($(MicroVersionNumber), 256)),
188                $([msbuild]::BitwiseOr(
189                    $([msbuild]::Multiply($(ReleaseLevelNumber), 16)),
190                    $(ReleaseSerial)
191                ))
192            ))
193        ))
194    ))</PythonVersionHex>
195    <Field3Value>$([msbuild]::Add(
196        $(ReleaseSerial),
197        $([msbuild]::Add(
198            $([msbuild]::Multiply($(ReleaseLevelNumber), 10)),
199            $([msbuild]::Multiply($(MicroVersionNumber), 1000))
200        ))
201    ))</Field3Value>
202    <Field3Value Condition="$(UseTestMarker) == 'true'">$([msbuild]::Add($(Field3Value), 9000))</Field3Value>
203
204    <!-- The name of the resulting pythonXY.dll (without the extension) -->
205    <PyDllName>python$(MajorVersionNumber)$(MinorVersionNumber)$(PyDebugExt)</PyDllName>
206    <!-- The name of the resulting pythonX.dll (without the extension) -->
207    <Py3DllName>python3$(PyDebugExt)</Py3DllName>
208
209    <!-- The version and platform tag to include in .pyd filenames -->
210    <PydTag Condition="$(ArchName) == 'win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
211    <PydTag Condition="$(ArchName) == 'arm32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_arm32</PydTag>
212    <PydTag Condition="$(ArchName) == 'arm64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_arm64</PydTag>
213    <PydTag Condition="$(ArchName) == 'amd64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_amd64</PydTag>
214
215    <!-- The version number for sys.winver -->
216    <SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)$(PyArchExt)$(PyTestExt)</SysWinVer>
217  </PropertyGroup>
218
219  <!-- Displays the calculated version info -->
220  <Target Name="ShowVersionInfo">
221    <Message Importance="high" Text="PythonVersionNumber: $(PythonVersionNumber)" />
222    <Message Importance="high" Text="PythonVersion:       $(PythonVersion)" />
223    <Message Importance="high" Text="PythonVersionHex:    0x$([System.UInt32]::Parse($(PythonVersionHex)).ToString(`X08`))" />
224    <Message Importance="high" Text="PythonVersionUnique: $(MajorVersionNumber).$(MinorVersionNumber).$(Field3Value)" />
225    <Message Importance="high" Text="Field3Value:         $(Field3Value)" />
226    <Message Importance="high" Text="SysWinVer:           $(SysWinVer)" />
227    <Message Importance="high" Text="PyDllName:           $(PyDllName)" />
228    <Message Importance="high" Text="WindowsSdkVersion:   $(TargetPlatformVersion)" />
229  </Target>
230</Project>
231