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 |
| 25 | |
| 26 | |
| 27 | :CheckOpts |
| 28 | if "%1" EQU "-c" (set CERTNAME=%~2) && shift && shift && goto CheckOpts |
| 29 | if "%1" EQU "-o" (set OUTDIR=%~2) && shift && shift && goto CheckOpts |
| 30 | if "%1" EQU "-D" (set SKIPDOC=1) && shift && goto CheckOpts |
| 31 | if "%1" EQU "-B" (set SKIPBUILD=1) && shift && goto CheckOpts |
| 32 | if "%1" EQU "--download" (set DOWNLOAD_URL=%~2) && shift && shift && goto CheckOpts |
| 33 | if "%1" EQU "-b" (set TARGET=Build) && shift && goto CheckOpts |
| 34 | if '%1' EQU '-x86' (set BUILDX86=1) && shift && goto CheckOpts |
| 35 | if '%1' EQU '-x64' (set BUILDX64=1) && shift && goto CheckOpts |
| 36 | |
| 37 | if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1) |
| 38 | |
| 39 | :builddoc |
| 40 | if "%SKIPBUILD%" EQU "1" goto skipdoc |
| 41 | if "%SKIPDOC%" EQU "1" goto skipdoc |
| 42 | |
| 43 | call "%D%..\..\doc\make.bat" htmlhelp |
| 44 | if errorlevel 1 goto :eof |
| 45 | :skipdoc |
| 46 | |
Steve Dower | 268f3de | 2015-02-06 09:02:54 -0800 | [diff] [blame^] | 47 | where hg >nul 2>nul |
| 48 | if errorlevel 1 echo Cannot find hg on PATH & exit /B 1 |
| 49 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 50 | where dlltool 2>nul >"%TEMP%\dlltool.loc" |
| 51 | if errorlevel 1 dir "%D%..\..\externals\dlltool.exe" /s/b > "%TEMP%\dlltool.loc" |
| 52 | if errorlevel 1 echo Cannot find binutils on PATH or in externals & exit /B 1 |
| 53 | set /P DLLTOOL= < "%TEMP%\dlltool.loc" |
| 54 | set PATH=%PATH%;%DLLTOOL:~,-12% |
| 55 | set DLLTOOL= |
| 56 | del "%TEMP%\dlltool.loc" |
| 57 | |
| 58 | |
| 59 | if defined BUILDX86 ( |
| 60 | call :build x86 |
| 61 | if errorlevel 1 exit /B |
| 62 | ) |
| 63 | |
| 64 | if defined BUILDX64 ( |
| 65 | call :build x64 |
| 66 | if errorlevel 1 exit /B |
| 67 | ) |
| 68 | |
| 69 | exit /B 0 |
| 70 | |
| 71 | :build |
| 72 | @setlocal |
| 73 | @echo off |
| 74 | |
| 75 | if "%1" EQU "x86" ( |
| 76 | call "%PCBUILD%env.bat" x86 |
| 77 | set BUILD=%PCBUILD%win32\ |
| 78 | set BUILD_PLAT=Win32 |
| 79 | set OUTDIR_PLAT=win32 |
| 80 | set OBJDIR_PLAT=x86 |
| 81 | set RELEASE_URI=%RELEASE_URI_X86% |
| 82 | ) ELSE ( |
| 83 | call "%PCBUILD%env.bat" x86_amd64 |
| 84 | set BUILD=%PCBUILD%amd64\ |
| 85 | set BUILD_PLAT=x64 |
| 86 | set OUTDIR_PLAT=amd64 |
| 87 | set OBJDIR_PLAT=x64 |
| 88 | set RELEASE_URI=%RELEASE_URI_X64% |
| 89 | ) |
| 90 | |
| 91 | echo on |
| 92 | if exist "%BUILD%en-us" ( |
| 93 | echo Deleting %BUILD%en-us |
| 94 | rmdir /q/s "%BUILD%en-us" |
| 95 | if errorlevel 1 exit /B |
| 96 | ) |
| 97 | |
| 98 | echo on |
| 99 | if exist "%D%obj\Release_%OBJDIR_PLAT%" ( |
| 100 | echo Deleting "%D%obj\Release_%OBJDIR_PLAT%" |
| 101 | rmdir /q/s "%D%obj\Release_%OBJDIR_PLAT%" |
| 102 | if errorlevel 1 exit /B |
| 103 | ) |
| 104 | |
| 105 | if not "%CERTNAME%" EQU "" ( |
| 106 | set CERTOPTS="/p:SigningCertificate=%CERTNAME%" |
| 107 | ) else ( |
| 108 | set CERTOPTS= |
| 109 | ) |
| 110 | |
| 111 | if not "%SKIPBUILD%" EQU "1" ( |
| 112 | call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -d -t %TARGET% %CERTOPTS% |
| 113 | if errorlevel 1 exit /B |
| 114 | call "%PCBUILD%build.bat" -p %BUILD_PLAT% -t %TARGET% %CERTOPTS% |
| 115 | if errorlevel 1 exit /B |
| 116 | @rem build.bat turns echo back on, so we disable it again |
| 117 | @echo off |
| 118 | ) |
| 119 | |
| 120 | "%BUILD%python.exe" "%D%get_wix.py" |
| 121 | |
| 122 | set BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI% |
| 123 | msbuild "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true |
| 124 | if errorlevel 1 exit /B |
| 125 | msbuild "%D%bundle\releaseweb.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=false |
| 126 | if errorlevel 1 exit /B |
| 127 | |
| 128 | if not "%OUTDIR%" EQU "" ( |
| 129 | mkdir "%OUTDIR%\%OUTDIR_PLAT%" |
| 130 | copy /Y "%BUILD%en-us\*.cab" "%OUTDIR%\%OUTDIR_PLAT%" |
| 131 | copy /Y "%BUILD%en-us\*.exe" "%OUTDIR%\%OUTDIR_PLAT%" |
| 132 | copy /Y "%BUILD%en-us\*.msi" "%OUTDIR%\%OUTDIR_PLAT%" |
| 133 | ) |
| 134 | |