Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 1 | @setlocal |
| 2 | @echo off |
| 3 | |
| 4 | rem This script is intended for building official releases of Python. |
| 5 | rem To use it to build alternative releases, you should clone this file |
| 6 | rem and modify the following three URIs. |
| 7 | rem |
| 8 | rem The first two will ensure that your release can be installed |
| 9 | rem alongside an official Python release, while the second specifies |
| 10 | rem the URL that will be used to download installation files. The |
| 11 | rem files available from this URL *will* conflict with your installer. |
| 12 | rem Trust me, you don't want them, even if it seems like a good idea. |
| 13 | |
| 14 | set RELEASE_URI_X86=http://www.python.org/win32 |
| 15 | set RELEASE_URI_X64=http://www.python.org/amd64 |
| 16 | set DOWNLOAD_URL_BASE=https://www.python.org/ftp/python |
| 17 | set DOWNLOAD_URL= |
| 18 | |
| 19 | set D=%~dp0 |
| 20 | set PCBUILD=%D%..\..\PCBuild\ |
| 21 | |
| 22 | set BUILDX86= |
| 23 | set BUILDX64= |
| 24 | set TARGET=Rebuild |
Steve Dower | 5056455 | 2015-02-07 15:42:53 -0800 | [diff] [blame] | 25 | set TESTTARGETDIR= |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 26 | |
| 27 | |
| 28 | :CheckOpts |
| 29 | if "%1" EQU "-c" (set CERTNAME=%~2) && shift && shift && goto CheckOpts |
| 30 | if "%1" EQU "-o" (set OUTDIR=%~2) && shift && shift && goto CheckOpts |
| 31 | if "%1" EQU "-D" (set SKIPDOC=1) && shift && goto CheckOpts |
| 32 | if "%1" EQU "-B" (set SKIPBUILD=1) && shift && goto CheckOpts |
| 33 | if "%1" EQU "--download" (set DOWNLOAD_URL=%~2) && shift && shift && goto CheckOpts |
Steve Dower | 5056455 | 2015-02-07 15:42:53 -0800 | [diff] [blame] | 34 | if "%1" EQU "--test" (set TESTTARGETDIR=%~2) && shift && shift && goto CheckOpts |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 35 | if "%1" EQU "-b" (set TARGET=Build) && shift && goto CheckOpts |
| 36 | if '%1' EQU '-x86' (set BUILDX86=1) && shift && goto CheckOpts |
| 37 | if '%1' EQU '-x64' (set BUILDX64=1) && shift && goto CheckOpts |
| 38 | |
| 39 | if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1) |
| 40 | |
| 41 | :builddoc |
| 42 | if "%SKIPBUILD%" EQU "1" goto skipdoc |
| 43 | if "%SKIPDOC%" EQU "1" goto skipdoc |
| 44 | |
| 45 | call "%D%..\..\doc\make.bat" htmlhelp |
| 46 | if errorlevel 1 goto :eof |
| 47 | :skipdoc |
| 48 | |
Steve Dower | 268f3de | 2015-02-06 09:02:54 -0800 | [diff] [blame] | 49 | where hg >nul 2>nul |
| 50 | if errorlevel 1 echo Cannot find hg on PATH & exit /B 1 |
| 51 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 52 | where dlltool 2>nul >"%TEMP%\dlltool.loc" |
| 53 | if errorlevel 1 dir "%D%..\..\externals\dlltool.exe" /s/b > "%TEMP%\dlltool.loc" |
| 54 | if errorlevel 1 echo Cannot find binutils on PATH or in externals & exit /B 1 |
| 55 | set /P DLLTOOL= < "%TEMP%\dlltool.loc" |
| 56 | set PATH=%PATH%;%DLLTOOL:~,-12% |
| 57 | set DLLTOOL= |
| 58 | del "%TEMP%\dlltool.loc" |
| 59 | |
| 60 | |
| 61 | if defined BUILDX86 ( |
| 62 | call :build x86 |
| 63 | if errorlevel 1 exit /B |
| 64 | ) |
| 65 | |
| 66 | if defined BUILDX64 ( |
| 67 | call :build x64 |
| 68 | if errorlevel 1 exit /B |
| 69 | ) |
| 70 | |
Steve Dower | 5056455 | 2015-02-07 15:42:53 -0800 | [diff] [blame] | 71 | if defined TESTTARGETDIR ( |
| 72 | call "%D%testrelease.bat" -t "%TESTTARGETDIR%" |
| 73 | ) |
| 74 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 75 | exit /B 0 |
| 76 | |
| 77 | :build |
| 78 | @setlocal |
| 79 | @echo off |
| 80 | |
| 81 | if "%1" EQU "x86" ( |
| 82 | call "%PCBUILD%env.bat" x86 |
| 83 | set BUILD=%PCBUILD%win32\ |
| 84 | set BUILD_PLAT=Win32 |
| 85 | set OUTDIR_PLAT=win32 |
| 86 | set OBJDIR_PLAT=x86 |
| 87 | set RELEASE_URI=%RELEASE_URI_X86% |
| 88 | ) ELSE ( |
| 89 | call "%PCBUILD%env.bat" x86_amd64 |
| 90 | set BUILD=%PCBUILD%amd64\ |
| 91 | set BUILD_PLAT=x64 |
| 92 | set OUTDIR_PLAT=amd64 |
| 93 | set OBJDIR_PLAT=x64 |
| 94 | set RELEASE_URI=%RELEASE_URI_X64% |
| 95 | ) |
| 96 | |
| 97 | echo on |
| 98 | if exist "%BUILD%en-us" ( |
| 99 | echo Deleting %BUILD%en-us |
| 100 | rmdir /q/s "%BUILD%en-us" |
| 101 | if errorlevel 1 exit /B |
| 102 | ) |
| 103 | |
| 104 | echo on |
| 105 | if exist "%D%obj\Release_%OBJDIR_PLAT%" ( |
| 106 | echo Deleting "%D%obj\Release_%OBJDIR_PLAT%" |
| 107 | rmdir /q/s "%D%obj\Release_%OBJDIR_PLAT%" |
| 108 | if errorlevel 1 exit /B |
| 109 | ) |
| 110 | |
| 111 | if not "%CERTNAME%" EQU "" ( |
| 112 | set CERTOPTS="/p:SigningCertificate=%CERTNAME%" |
| 113 | ) else ( |
| 114 | set CERTOPTS= |
| 115 | ) |
| 116 | |
| 117 | if not "%SKIPBUILD%" EQU "1" ( |
| 118 | call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -d -t %TARGET% %CERTOPTS% |
| 119 | if errorlevel 1 exit /B |
| 120 | call "%PCBUILD%build.bat" -p %BUILD_PLAT% -t %TARGET% %CERTOPTS% |
| 121 | if errorlevel 1 exit /B |
| 122 | @rem build.bat turns echo back on, so we disable it again |
| 123 | @echo off |
| 124 | ) |
| 125 | |
| 126 | "%BUILD%python.exe" "%D%get_wix.py" |
| 127 | |
| 128 | set BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI% |
| 129 | msbuild "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true |
| 130 | if errorlevel 1 exit /B |
| 131 | msbuild "%D%bundle\releaseweb.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=false |
| 132 | if errorlevel 1 exit /B |
| 133 | |
| 134 | if not "%OUTDIR%" EQU "" ( |
| 135 | mkdir "%OUTDIR%\%OUTDIR_PLAT%" |
| 136 | copy /Y "%BUILD%en-us\*.cab" "%OUTDIR%\%OUTDIR_PLAT%" |
| 137 | copy /Y "%BUILD%en-us\*.exe" "%OUTDIR%\%OUTDIR_PLAT%" |
| 138 | copy /Y "%BUILD%en-us\*.msi" "%OUTDIR%\%OUTDIR_PLAT%" |
| 139 | ) |
| 140 | |