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