• 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 '$(VisualStudioVersion)' == '17.0'">v143</BasePlatformToolset>
15    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VisualStudioVersion)' == '16.0'">v142</BasePlatformToolset>
16    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and ('$(MSBuildToolsVersion)' == '15.0' or '$(VisualStudioVersion)' == '15.0')">v141</BasePlatformToolset>
17    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath14)' != ''">v140</BasePlatformToolset>
18    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath12)' != ''">v120</BasePlatformToolset>
19    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath11)' != ''">v110</BasePlatformToolset>
20    <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath10)' != ''">v100</BasePlatformToolset>
21
22    <PlatformToolset Condition="'$(PlatformToolset)' == ''">$(BasePlatformToolset)</PlatformToolset>
23    <ICCBuild>false</ICCBuild>
24    <ICCBuild Condition="$(PlatformToolset.StartsWith(`Intel C++ Compiler`))">true</ICCBuild>
25
26    <!--
27    Convincing MSVC/MSBuild to prefer our platform names is too difficult,
28    so we define our own constant ArchName and use wherever we need it.
29    -->
30    <ArchName Condition="'$(ArchName)' == '' and $(Platform) == 'x64'">amd64</ArchName>
31    <ArchName Condition="'$(ArchName)' == '' and $(Platform) == 'ARM'">arm32</ArchName>
32    <ArchName Condition="'$(ArchName)' == '' and $(Platform) == 'ARM64'">arm64</ArchName>
33    <ArchName Condition="'$(ArchName)' == ''">win32</ArchName>
34
35    <!-- Root directory of the repository -->
36    <PySourcePath Condition="'$(PySourcePath)' == ''">$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\))</PySourcePath>
37    <PySourcePath Condition="!HasTrailingSlash($(PySourcePath))">$(PySourcePath)\</PySourcePath>
38
39    <!-- Directory where build outputs are put -->
40    <BuildPath32 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\win32\</BuildPath32>
41    <BuildPath32 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\win32\</BuildPath32>
42    <BuildPath64 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\amd64\</BuildPath64>
43    <BuildPath64 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\amd64\</BuildPath64>
44    <BuildPathArm32 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\arm32\</BuildPathArm32>
45    <BuildPathArm32 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\arm32\</BuildPathArm32>
46    <BuildPathArm64 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\arm64\</BuildPathArm64>
47    <BuildPathArm64 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\arm64\</BuildPathArm64>
48    <BuildPath Condition="'$(ArchName)' == 'win32'">$(BuildPath32)</BuildPath>
49    <BuildPath Condition="'$(ArchName)' == 'amd64'">$(BuildPath64)</BuildPath>
50    <BuildPath Condition="'$(ArchName)' == 'arm32'">$(BuildPathArm32)</BuildPath>
51    <BuildPath Condition="'$(ArchName)' == 'arm64'">$(BuildPathArm64)</BuildPath>
52    <BuildPath Condition="'$(BuildPath)' == ''">$(PySourcePath)PCbuild\$(ArchName)\</BuildPath>
53    <BuildPath Condition="!HasTrailingSlash($(BuildPath))">$(BuildPath)\</BuildPath>
54    <BuildPath Condition="$(Configuration) == 'PGInstrument'">$(BuildPath)instrumented\</BuildPath>
55
56    <!-- VPATH definition (escaped) -->
57    <PyVPath Condition="$(Configuration) != 'PGInstrument'">..\\..</PyVPath>
58    <PyVPath Condition="$(Configuration) == 'PGInstrument'">..\\..\\..</PyVPath>
59  </PropertyGroup>
60
61  <!-- Directories of external projects. tcltk is handled in tcltk.props -->
62  <PropertyGroup>
63    <ExternalsDir Condition="$(ExternalsDir) == ''">$(EXTERNALS_DIR)</ExternalsDir>
64    <ExternalsDir Condition="$(ExternalsDir) == ''">$([System.IO.Path]::GetFullPath(`$(PySourcePath)externals`))</ExternalsDir>
65    <ExternalsDir Condition="!HasTrailingSlash($(ExternalsDir))">$(ExternalsDir)\</ExternalsDir>
66  </PropertyGroup>
67
68  <Import Project="$(ExternalProps)" Condition="$(ExternalProps) != '' and Exists('$(ExternalProps)')" />
69
70  <PropertyGroup>
71    <sqlite3Dir Condition="$(sqlite3Dir) == ''">$(ExternalsDir)sqlite-3.45.3.0\</sqlite3Dir>
72    <bz2Dir Condition="$(bz2Dir) == ''">$(ExternalsDir)bzip2-1.0.8\</bz2Dir>
73    <lzmaDir Condition="$(lzmaDir) == ''">$(ExternalsDir)xz-5.2.5\</lzmaDir>
74    <libffiDir Condition="$(libffiDir) == ''">$(ExternalsDir)libffi-3.4.4\</libffiDir>
75    <libffiOutDir Condition="$(libffiOutDir) == ''">$(libffiDir)$(ArchName)\</libffiOutDir>
76    <libffiIncludeDir Condition="$(libffiIncludeDir) == ''">$(libffiOutDir)include</libffiIncludeDir>
77    <mpdecimalDir Condition="$(mpdecimalDir) == ''">$(ExternalsDir)\mpdecimal-4.0.0\</mpdecimalDir>
78    <opensslDir Condition="$(opensslDir) == ''">$(ExternalsDir)openssl-3.0.15\</opensslDir>
79    <opensslOutDir Condition="$(opensslOutDir) == ''">$(ExternalsDir)openssl-bin-3.0.15\$(ArchName)\</opensslOutDir>
80    <opensslIncludeDir Condition="$(opensslIncludeDir) == ''">$(opensslOutDir)include</opensslIncludeDir>
81    <nasmDir Condition="$(nasmDir) == ''">$(ExternalsDir)\nasm-2.11.06\</nasmDir>
82    <zlibDir Condition="$(zlibDir) == ''">$(ExternalsDir)\zlib-1.3.1\</zlibDir>
83  </PropertyGroup>
84
85  <PropertyGroup>
86    <!-- Suffix for all binaries when building for debug -->
87    <PyDebugExt Condition="'$(PyDebugExt)' == '' and $(Configuration) == 'Debug'">_d</PyDebugExt>
88
89    <!-- Suffix for versions/keys when building with test markers -->
90    <PyTestExt Condition="$(UseTestMarker) == 'true'">-test</PyTestExt>
91
92    <!-- Suffix for versions/keys when building for particular platforms -->
93    <PyArchExt Condition="'$(ArchName)' == 'win32'">-32</PyArchExt>
94    <PyArchExt Condition="'$(ArchName)' == 'arm32'">-arm32</PyArchExt>
95    <PyArchExt Condition="'$(ArchName)' == 'arm64'">-arm64</PyArchExt>
96
97    <!-- Include Tkinter by default -->
98    <IncludeTkinter Condition="'$(IncludeTkinter)' == ''">true</IncludeTkinter>
99  </PropertyGroup>
100
101  <PropertyGroup Condition="'$(Platform)'=='ARM'" Label="ArmConfiguration">
102    <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
103  </PropertyGroup>
104
105  <PropertyGroup Condition="'$(Platform)'=='ARM64'" Label="Arm64Configuration">
106    <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
107  </PropertyGroup>
108
109  <PropertyGroup Condition="$(DefaultWindowsSDKVersion) == ''">
110    <!--
111    Attempt to select the latest installed WinSDK. If we don't find any, then we will
112    let the MSBuild targets determine which one it wants to use (typically the earliest
113    possible version). Since we limit WINVER to Windows 7 anyway, it doesn't really
114    matter which WinSDK version we use.
115    -->
116    <_RegistryVersion>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion)</_RegistryVersion>
117    <_RegistryVersion Condition="$(_RegistryVersion) == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion)</_RegistryVersion>
118    <!-- Sometimes the version in the registry has to .0 suffix, and sometimes it doesn't. Check and add it -->
119    <_RegistryVersion Condition="$(_RegistryVersion) != '' and !$(_RegistryVersion.EndsWith('.0'))">$(_RegistryVersion).0</_RegistryVersion>
120
121    <!-- The minimum allowed SDK version to use for building -->
122    <DefaultWindowsSDKVersion>10.0.10586.0</DefaultWindowsSDKVersion>
123    <DefaultWindowsSDKVersion Condition="$(_RegistryVersion) != '' and $([System.Version]::Parse($(_RegistryVersion))) > $([System.Version]::Parse($(DefaultWindowsSDKVersion)))">$(_RegistryVersion)</DefaultWindowsSDKVersion>
124  </PropertyGroup>
125
126  <Target Name="_CheckWindowsSDKFound" BeforeTargets="_CheckWindowsSDKInstalled" Condition="$(_RegistryVersion) == ''">
127    <PropertyGroup>
128      <_Message>Failed to locate a Windows SDK installation.</_Message>
129      <_Message>$(_Message) If the build fails, please use the Visual Studio Installer to install the Windows SDK.</_Message>
130      <_Message>$(_Message) (Ignore the version number specified in the error message and select the latest.)</_Message>
131    </PropertyGroup>
132    <Warning Text="$(_Message)" />
133  </Target>
134
135  <PropertyGroup Condition="$(WindowsTargetPlatformVersion) == ''">
136    <WindowsTargetPlatformVersion>$(DefaultWindowsSDKVersion)</WindowsTargetPlatformVersion>
137  </PropertyGroup>
138
139  <PropertyGroup Condition="'$(OverrideVersion)' == ''">
140    <!--
141    Read version information from Include\patchlevel.h. The following properties are set:
142
143        MajorVersionNumber  -   the '3' in '3.5.2a1'
144        MinorVersionNumber  -   the '5' in '3.5.2a1'
145        MicroVersionNumber  -   the '2' in '3.5.2a1'
146        ReleaseSerial       -   the '1' in '3.5.2a1'
147        ReleaseLevelName    -   the 'a1' in '3.5.2a1'
148        PythonVersionNumber -   '3.5.2' for '3.5.2a1'
149        PythonVersion       -   '3.5.2a1'
150        PythonVersionHex    -   0x030502a1 for '3.5.2a1'
151        ReleaseLevelNumber  -   10 for alpha, 11 for beta, 12 for RC (gamma), and 15 for final
152        Field3Value         -   2101 for '3.5.2a1' (== 1000*2 + 10*10 ('a') + 1)
153    -->
154    <_PatchLevelContent>$([System.IO.File]::ReadAllText(`$(PySourcePath)Include\patchlevel.h`))</_PatchLevelContent>
155    <MajorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MAJOR_VERSION\s+(\d+)`).Groups[1].Value)</MajorVersionNumber>
156    <MinorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MINOR_VERSION\s+(\d+)`).Groups[1].Value)</MinorVersionNumber>
157    <MicroVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MICRO_VERSION\s+(\d+)`).Groups[1].Value)</MicroVersionNumber>
158    <_ReleaseLevel>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_RELEASE_LEVEL\s+PY_RELEASE_LEVEL_(\w+)`).Groups[1].Value)</_ReleaseLevel>
159    <ReleaseSerial>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_RELEASE_SERIAL\s+(\d+)`).Groups[1].Value)</ReleaseSerial>
160    <ReleaseLevelNumber>15</ReleaseLevelNumber>
161    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'ALPHA'">10</ReleaseLevelNumber>
162    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'BETA'">11</ReleaseLevelNumber>
163    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'GAMMA'">12</ReleaseLevelNumber>
164    <ReleaseLevelName Condition="$(_ReleaseLevel) == 'ALPHA'">a$(ReleaseSerial)</ReleaseLevelName>
165    <ReleaseLevelName Condition="$(_ReleaseLevel) == 'BETA'">b$(ReleaseSerial)</ReleaseLevelName>
166    <ReleaseLevelName Condition="$(_ReleaseLevel) == 'GAMMA'">rc$(ReleaseSerial)</ReleaseLevelName>
167  </PropertyGroup>
168
169  <PropertyGroup Condition="'$(OverrideVersion)' != ''">
170    <!--
171    Override the version number when building by specifying OverrideVersion.
172    For example:
173
174        PCbuild\build.bat "/p:OverrideVersion=3.5.2a1"
175
176    Use the -V option to check your version is valid:
177
178        PCbuild\build.bat -V "/p:OverrideVersion=3.5.2a1"
179          PythonVersionNumber: 3.5.2
180          PythonVersion:       3.5.2a1
181          PythonVersionHex:    0x030502A1
182          Field3Value:         2101
183
184    Note that this only affects the version numbers embedded in resources and
185    installers, but not sys.version.
186    -->
187    <MajorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[1].Value)</MajorVersionNumber>
188    <MinorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[2].Value)</MinorVersionNumber>
189    <MicroVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[3].Value)</MicroVersionNumber>
190    <ReleaseLevelName>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[4].Value)</ReleaseLevelName>
191    <_ReleaseLevel>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[5].Value)</_ReleaseLevel>
192    <ReleaseSerial>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[6].Value)</ReleaseSerial>
193    <ReleaseSerial Condition="'$(ReleaseSerial)' == ''">0</ReleaseSerial>
194    <ReleaseLevelNumber>15</ReleaseLevelNumber>
195    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'a'">10</ReleaseLevelNumber>
196    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'b'">11</ReleaseLevelNumber>
197    <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'rc'">12</ReleaseLevelNumber>
198  </PropertyGroup>
199
200  <PropertyGroup>
201    <PythonVersionNumber>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)</PythonVersionNumber>
202    <PythonVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)$(ReleaseLevelName)</PythonVersion>
203    <PythonVersionHex>$([msbuild]::BitwiseOr(
204        $([msbuild]::Multiply($(MajorVersionNumber), 16777216)),
205        $([msbuild]::BitwiseOr(
206            $([msbuild]::Multiply($(MinorVersionNumber), 65536)),
207            $([msbuild]::BitwiseOr(
208                $([msbuild]::Multiply($(MicroVersionNumber), 256)),
209                $([msbuild]::BitwiseOr(
210                    $([msbuild]::Multiply($(ReleaseLevelNumber), 16)),
211                    $(ReleaseSerial)
212                ))
213            ))
214        ))
215    ))</PythonVersionHex>
216    <Field3Value>$([msbuild]::Add(
217        $(ReleaseSerial),
218        $([msbuild]::Add(
219            $([msbuild]::Multiply($(ReleaseLevelNumber), 10)),
220            $([msbuild]::Multiply($(MicroVersionNumber), 1000))
221        ))
222    ))</Field3Value>
223    <Field3Value Condition="$(UseTestMarker) == 'true'">$([msbuild]::Add($(Field3Value), 9000))</Field3Value>
224
225    <!-- Name and full path of the resulting python.exe binary -->
226    <PyExeName Condition="$(DisableGil) == 'true'">python$(MajorVersionNumber).$(MinorVersionNumber)t</PyExeName>
227    <PyExeName Condition="$(PyExeName) == ''">python</PyExeName>
228    <PythonExe Condition="'$(PythonExe)' == ''">$(BuildPath)$(PyExeName)$(PyDebugExt).exe</PythonExe>
229    <PyWExeName Condition="$(DisableGil) == 'true'">pythonw$(MajorVersionNumber).$(MinorVersionNumber)t</PyWExeName>
230    <PyWExeName Condition="$(PyWExeName) == ''">pythonw</PyWExeName>
231
232    <!-- The name of the resulting pythonXY.dll (without the extension) -->
233    <PyDllName Condition="$(DisableGil) == 'true'">python$(MajorVersionNumber)$(MinorVersionNumber)t$(PyDebugExt)</PyDllName>
234    <PyDllName Condition="$(PyDllName) == ''">python$(MajorVersionNumber)$(MinorVersionNumber)$(PyDebugExt)</PyDllName>
235    <!-- The name of the resulting pythonX.dll (without the extension) -->
236    <Py3DllName Condition="$(DisableGil) == 'true'">python3t</Py3DllName>
237    <Py3DllName Condition="$(Py3DllName) == ''">python3</Py3DllName>
238
239    <!-- The version and platform tag to include in .pyd filenames -->
240    <PydTag Condition="$(ArchName) == 'win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
241    <PydTag Condition="$(ArchName) == 'arm32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_arm32</PydTag>
242    <PydTag Condition="$(ArchName) == 'arm64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_arm64</PydTag>
243    <PydTag Condition="$(ArchName) == 'amd64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_amd64</PydTag>
244
245    <!-- The version number for sys.winver -->
246    <SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)$(PyArchExt)$(PyTestExt)</SysWinVer>
247
248    <!-- The version and platform tag to include in .pyd filenames for freethreaded builds -->
249    <FreethreadedPydTag Condition="$(ArchName) == 'win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win32</FreethreadedPydTag>
250    <FreethreadedPydTag Condition="$(ArchName) == 'arm32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win_arm32</FreethreadedPydTag>
251    <FreethreadedPydTag Condition="$(ArchName) == 'arm64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win_arm64</FreethreadedPydTag>
252    <FreethreadedPydTag Condition="$(ArchName) == 'amd64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win_amd64</FreethreadedPydTag>
253
254    <!-- The version number for sys.winver for freethreaded builds -->
255    <FreethreadedSysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)t$(PyArchExt)$(PyTestExt)</FreethreadedSysWinVer>
256  </PropertyGroup>
257
258  <PropertyGroup Condition="$(DisableGil) != 'true'">
259    <!-- The extension to use for standard library PYDs -->
260    <PyStdlibPydExt>.pyd</PyStdlibPydExt>
261  </PropertyGroup>
262
263  <PropertyGroup Condition="$(DisableGil) == 'true'">
264    <PydTag>$(FreethreadedPydTag)</PydTag>
265
266    <!-- The extension to use for standard library PYDs -->
267    <PyStdlibPydExt>$(PydTag).pyd</PyStdlibPydExt>
268
269    <!-- The version number for sys.winver -->
270    <SysWinVer>$(FreethreadedSysWinVer)</SysWinVer>
271  </PropertyGroup>
272
273  <!-- Displays the calculated version info -->
274  <Target Name="ShowVersionInfo">
275    <Message Importance="high" Text="PythonVersionNumber: $(PythonVersionNumber)" />
276    <Message Importance="high" Text="PythonVersion:       $(PythonVersion)" />
277    <Message Importance="high" Text="PythonVersionHex:    0x$([System.UInt32]::Parse($(PythonVersionHex)).ToString(`X08`))" />
278    <Message Importance="high" Text="PythonVersionUnique: $(MajorVersionNumber).$(MinorVersionNumber).$(Field3Value)" />
279    <Message Importance="high" Text="Field3Value:         $(Field3Value)" />
280    <Message Importance="high" Text="SysWinVer:           $(SysWinVer)" />
281    <Message Importance="high" Text="PyDllName:           $(PyDllName)" />
282    <Message Importance="high" Text="WindowsSdkVersion:   $(TargetPlatformVersion)" />
283  </Target>
284</Project>
285