Home | History | Annotate | Download | only in PCbuild
      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 '$(VCTargetsPath14)' != ''">v140</BasePlatformToolset>
     14     <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath12)' != ''">v120</BasePlatformToolset>
     15     <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath11)' != ''">v110</BasePlatformToolset>
     16     <BasePlatformToolset Condition="'$(BasePlatformToolset)' == '' and '$(VCTargetsPath10)' != ''">v100</BasePlatformToolset>
     17 
     18     <PlatformToolset Condition="'$(PlatformToolset)' == ''">$(BasePlatformToolset)</PlatformToolset>
     19     <ICCBuild>false</ICCBuild>
     20     <ICCBuild Condition="$(PlatformToolset.StartsWith(`Intel C++ Compiler`))">true</ICCBuild>
     21 
     22     <!--
     23     Convincing MSVC/MSBuild to prefer our platform names is too difficult,
     24     so we define our own constant ArchName and use wherever we need it.
     25     -->
     26     <ArchName Condition="'$(ArchName)' == '' and $(Platform) == 'x64'">amd64</ArchName>
     27     <ArchName Condition="'$(ArchName)' == ''">win32</ArchName>
     28     
     29     <!-- Root directory of the repository -->
     30     <PySourcePath Condition="'$(PySourcePath)' == ''">$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\))</PySourcePath>
     31     <PySourcePath Condition="!HasTrailingSlash($(PySourcePath))">$(PySourcePath)\</PySourcePath>
     32     
     33     <!-- Directory where build outputs are put -->
     34     <BuildPath32 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCBuild\win32\</BuildPath32>
     35     <BuildPath32 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\win32\</BuildPath32>
     36     <BuildPath64 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCBuild\amd64\</BuildPath64>
     37     <BuildPath64 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\amd64\</BuildPath64>
     38     <BuildPath Condition="'$(ArchName)' == 'win32'">$(BuildPath32)</BuildPath>
     39     <BuildPath Condition="'$(ArchName)' == 'amd64'">$(BuildPath64)</BuildPath>
     40     <BuildPath Condition="'$(BuildPath)' == ''">$(PySourcePath)PCBuild\$(ArchName)\</BuildPath>
     41     <BuildPath Condition="!HasTrailingSlash($(BuildPath))">$(BuildPath)\</BuildPath>
     42     
     43     <!-- Directories of external projects. tcltk is handled in tcltk.props -->
     44     <ExternalsDir>$([System.IO.Path]::GetFullPath(`$(PySourcePath)externals\`))</ExternalsDir>
     45     <sqlite3Dir>$(ExternalsDir)sqlite-3.14.2.0\</sqlite3Dir>
     46     <bz2Dir>$(ExternalsDir)bzip2-1.0.6\</bz2Dir>
     47     <lzmaDir>$(ExternalsDir)xz-5.2.2\</lzmaDir>
     48     <opensslDir>$(ExternalsDir)openssl-1.0.2k\</opensslDir>
     49     <opensslIncludeDir>$(opensslDir)include32</opensslIncludeDir>
     50     <opensslIncludeDir Condition="'$(ArchName)' == 'amd64'">$(opensslDir)include64</opensslIncludeDir>
     51     <nasmDir>$(ExternalsDir)\nasm-2.11.06\</nasmDir>
     52     
     53     <!-- Suffix for all binaries when building for debug -->
     54     <PyDebugExt Condition="'$(PyDebugExt)' == '' and $(Configuration) == 'Debug'">_d</PyDebugExt>
     55     
     56     <!-- Suffix for versions/keys when building with test markers -->
     57     <PyTestExt Condition="$(UseTestMarker) == 'true'">-test</PyTestExt>
     58     
     59     <!-- Suffix for versions/keys when building for particular platforms -->
     60     <PyArchExt Condition="'$(ArchName)' == 'win32'">-32</PyArchExt>
     61     
     62     <!-- Full path of the resulting python.exe binary -->
     63     <PythonExe Condition="'$(PythonExe)' == ''">$(BuildPath)python$(PyDebugExt).exe</PythonExe>
     64   </PropertyGroup>
     65   
     66   <PropertyGroup Condition="'$(OverrideVersion)' == ''">
     67     <!--
     68     Read version information from Include\patchlevel.h. The following properties are set:
     69     
     70         MajorVersionNumber  -   the '3' in '3.5.2a1'
     71         MinorVersionNumber  -   the '5' in '3.5.2a1'
     72         MicroVersionNumber  -   the '2' in '3.5.2a1'
     73         ReleaseSerial       -   the '1' in '3.5.2a1'
     74         ReleaseLevelName    -   the 'a1' in '3.5.2a1'
     75         PythonVersionNumber -   '3.5.2' for '3.5.2a1'
     76         PythonVersion       -   '3.5.2a1'
     77         PythonVersionHex    -   0x030502a1 for '3.5.2a1'
     78         ReleaseLevelNumber  -   10 for alpha, 11 for beta, 12 for RC (gamma), and 15 for final
     79         Field3Value         -   2101 for '3.5.2a1' (== 1000*2 + 10*10 ('a') + 1)
     80     -->
     81     <_PatchLevelContent>$([System.IO.File]::ReadAllText(`$(PySourcePath)Include\patchlevel.h`))</_PatchLevelContent>
     82     <MajorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MAJOR_VERSION\s+(\d+)`).Groups[1].Value)</MajorVersionNumber>
     83     <MinorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MINOR_VERSION\s+(\d+)`).Groups[1].Value)</MinorVersionNumber>
     84     <MicroVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_MICRO_VERSION\s+(\d+)`).Groups[1].Value)</MicroVersionNumber>
     85     <_ReleaseLevel>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_RELEASE_LEVEL\s+PY_RELEASE_LEVEL_(\w+)`).Groups[1].Value)</_ReleaseLevel>
     86     <ReleaseSerial>$([System.Text.RegularExpressions.Regex]::Match($(_PatchLevelContent), `define\s+PY_RELEASE_SERIAL\s+(\d+)`).Groups[1].Value)</ReleaseSerial>
     87     <ReleaseLevelNumber>15</ReleaseLevelNumber>
     88     <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'ALPHA'">10</ReleaseLevelNumber>
     89     <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'BETA'">11</ReleaseLevelNumber>
     90     <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'GAMMA'">12</ReleaseLevelNumber>
     91     <ReleaseLevelName Condition="$(_ReleaseLevel) == 'ALPHA'">a$(ReleaseSerial)</ReleaseLevelName>
     92     <ReleaseLevelName Condition="$(_ReleaseLevel) == 'BETA'">b$(ReleaseSerial)</ReleaseLevelName>
     93     <ReleaseLevelName Condition="$(_ReleaseLevel) == 'GAMMA'">rc$(ReleaseSerial)</ReleaseLevelName>
     94   </PropertyGroup>
     95   
     96   <PropertyGroup Condition="'$(OverrideVersion)' != ''">
     97     <!--
     98     Override the version number when building by specifying OverrideVersion.
     99     For example:
    100     
    101         PCBuild\build.bat "/p:OverrideVersion=3.5.2a1"
    102     
    103     Use the -V option to check your version is valid:
    104     
    105         PCBuild\build.bat -V "/p:OverrideVersion=3.5.2a1"
    106           PythonVersionNumber: 3.5.2
    107           PythonVersion:       3.5.2a1
    108           PythonVersionHex:    0x030502A1
    109           Field3Value:         2101
    110     
    111     Note that this only affects the version numbers embedded in resources and
    112     installers, but not sys.version.
    113     -->
    114     <MajorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[1].Value)</MajorVersionNumber>
    115     <MinorVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[2].Value)</MinorVersionNumber>
    116     <MicroVersionNumber>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[3].Value)</MicroVersionNumber>
    117     <ReleaseLevelName>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[4].Value)</ReleaseLevelName>
    118     <_ReleaseLevel>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[5].Value)</_ReleaseLevel>
    119     <ReleaseSerial>$([System.Text.RegularExpressions.Regex]::Match($(OverrideVersion), `(\d+)\.(\d+)\.(\d+)((a|b|rc)(\d))?`).Groups[6].Value)</ReleaseSerial>
    120     <ReleaseSerial Condition="'$(ReleaseSerial)' == ''">0</ReleaseSerial>
    121     <ReleaseLevelNumber>15</ReleaseLevelNumber>
    122     <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'a'">10</ReleaseLevelNumber>
    123     <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'b'">11</ReleaseLevelNumber>
    124     <ReleaseLevelNumber Condition="$(_ReleaseLevel) == 'rc'">12</ReleaseLevelNumber>
    125   </PropertyGroup>
    126   
    127   <PropertyGroup>
    128     <PythonVersionNumber>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)</PythonVersionNumber>
    129     <PythonVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)$(ReleaseLevelName)</PythonVersion>
    130     <PythonVersionHex>$([msbuild]::BitwiseOr(
    131         $([msbuild]::Multiply($(MajorVersionNumber), 16777216)),
    132         $([msbuild]::BitwiseOr(
    133             $([msbuild]::Multiply($(MinorVersionNumber), 65536)),
    134             $([msbuild]::BitwiseOr(
    135                 $([msbuild]::Multiply($(MicroVersionNumber), 256)),
    136                 $([msbuild]::BitwiseOr(
    137                     $([msbuild]::Multiply($(ReleaseLevelNumber), 16)),
    138                     $(ReleaseSerial)
    139                 ))
    140             ))
    141         ))
    142     ))</PythonVersionHex>
    143     <Field3Value>$([msbuild]::Add(
    144         $(ReleaseSerial),
    145         $([msbuild]::Add(
    146             $([msbuild]::Multiply($(ReleaseLevelNumber), 10)),
    147             $([msbuild]::Multiply($(MicroVersionNumber), 1000))
    148         ))
    149     ))</Field3Value>
    150     <Field3Value Condition="$(UseTestMarker) == 'true'">$([msbuild]::Add($(Field3Value), 9000))</Field3Value>
    151     
    152     <!-- The name of the resulting pythonXY.dll (without the extension) -->
    153     <PyDllName>python$(MajorVersionNumber)$(MinorVersionNumber)$(PyDebugExt)</PyDllName>
    154 
    155     <!-- The version and platform tag to include in .pyd filenames -->
    156     <PydTag Condition="$(ArchName) == 'win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
    157     <PydTag Condition="$(ArchName) == 'amd64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_amd64</PydTag>
    158     
    159     <!-- The version number for sys.winver -->
    160     <SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)$(PyArchExt)$(PyTestExt)</SysWinVer>
    161   </PropertyGroup>
    162   
    163   <!-- Displays the calculated version info -->
    164   <Target Name="ShowVersionInfo">
    165     <Message Importance="high" Text="PythonVersionNumber: $(PythonVersionNumber)" />
    166     <Message Importance="high" Text="PythonVersion:       $(PythonVersion)" />
    167     <Message Importance="high" Text="PythonVersionHex:    0x$([System.UInt32]::Parse($(PythonVersionHex)).ToString(`X08`))" />
    168     <Message Importance="high" Text="Field3Value:         $(Field3Value)" />
    169     <Message Importance="high" Text="SysWinVer:           $(SysWinVer)" />
    170     <Message Importance="high" Text="PyDllName:           $(PyDllName)" />
    171   </Target>
    172 </Project>
    173