buildrelease.bat revision 2a1f30f681a5c624a4c9409a5f97a46423e46df3
1@setlocal 2@echo off 3 4rem This script is intended for building official releases of Python. 5rem To use it to build alternative releases, you should clone this file 6rem and modify the following three URIs. 7 8rem These two will ensure that your release can be installed 9rem alongside an official Python release, by modifying the GUIDs used 10rem for all components. 11rem 12rem The following substitutions will be applied to the release URI: 13rem Variable Description Example 14rem {arch} architecture amd64, win32 15set RELEASE_URI=http://www.python.org/{arch} 16 17rem This is the URL that will be used to download installation files. 18rem The files available from the default URL *will* conflict with your 19rem installer. Trust me, you don't want them, even if it seems like a 20rem good idea. 21rem 22rem The following substitutions will be applied to the download URL: 23rem Variable Description Example 24rem {version} version number 3.5.0 25rem {arch} architecture amd64, win32 26rem {releasename} release name a1, b2, rc3 (or blank for final) 27rem {msi} MSI filename core.msi 28set DOWNLOAD_URL=https://www.python.org/ftp/python/{version}/{arch}{releasename}/{msi} 29 30set D=%~dp0 31set PCBUILD=%D%..\..\PCBuild\ 32set EXTERNALS=%D%..\..\externals\windows-installer\ 33 34set BUILDX86= 35set BUILDX64= 36set TARGET=Rebuild 37set TESTTARGETDIR= 38set PGO=default 39 40 41:CheckOpts 42if "%1" EQU "-h" goto Help 43if "%1" EQU "-c" (set CERTNAME=%~2) && shift && shift && goto CheckOpts 44if "%1" EQU "--certificate" (set CERTNAME=%~2) && shift && shift && goto CheckOpts 45if "%1" EQU "-o" (set OUTDIR=%~2) && shift && shift && goto CheckOpts 46if "%1" EQU "--out" (set OUTDIR=%~2) && shift && shift && goto CheckOpts 47if "%1" EQU "-D" (set SKIPDOC=1) && shift && goto CheckOpts 48if "%1" EQU "--skip-doc" (set SKIPDOC=1) && shift && goto CheckOpts 49if "%1" EQU "-B" (set SKIPBUILD=1) && shift && goto CheckOpts 50if "%1" EQU "--skip-build" (set SKIPBUILD=1) && shift && goto CheckOpts 51if "%1" EQU "--download" (set DOWNLOAD_URL=%~2) && shift && shift && goto CheckOpts 52if "%1" EQU "--test" (set TESTTARGETDIR=%~2) && shift && shift && goto CheckOpts 53if "%1" EQU "-b" (set TARGET=Build) && shift && goto CheckOpts 54if "%1" EQU "--build" (set TARGET=Build) && shift && goto CheckOpts 55if "%1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts 56if "%1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts 57if "%1" EQU "--pgo" (set PGO=%~2) && shift && shift && goto CheckOpts 58if "%1" EQU "--skip-pgo" (set PGO=) && shift && goto CheckOpts 59 60if "%1" NEQ "" echo Invalid option: "%1" && exit /B 1 61 62if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1) 63 64call "%D%get_externals.bat" 65 66:builddoc 67if "%SKIPBUILD%" EQU "1" goto skipdoc 68if "%SKIPDOC%" EQU "1" goto skipdoc 69 70if not defined PYTHON where py -q || echo Cannot find py on path and PYTHON is not set. && exit /B 1 71if not defined SPHINXBUILD where sphinx-build -q || echo Cannot find sphinx-build on path and SPHINXBUILD is not set. && exit /B 1 72 73call "%D%..\..\doc\make.bat" htmlhelp 74if errorlevel 1 goto :eof 75:skipdoc 76 77where hg /q || echo Cannot find Mercurial on PATH && exit /B 1 78 79where dlltool /q && goto skipdlltoolsearch 80set _DLLTOOL_PATH= 81where /R "%EXTERNALS%\" dlltool > "%TEMP%\dlltool.loc" 2> nul && set /P _DLLTOOL_PATH= < "%TEMP%\dlltool.loc" & del "%TEMP%\dlltool.loc" 82if not exist "%_DLLTOOL_PATH%" echo Cannot find binutils on PATH or in external && exit /B 1 83for %%f in (%_DLLTOOL_PATH%) do set PATH=%PATH%;%%~dpf 84set _DLLTOOL_PATH= 85:skipdlltoolsearch 86 87if defined BUILDX86 ( 88 call :build x86 89 if errorlevel 1 exit /B 90) 91 92if defined BUILDX64 ( 93 call :build x64 "%PGO%" 94 if errorlevel 1 exit /B 95) 96 97if defined TESTTARGETDIR ( 98 call "%D%testrelease.bat" -t "%TESTTARGETDIR%" 99) 100 101exit /B 0 102 103:build 104@setlocal 105@echo off 106 107if "%1" EQU "x86" ( 108 call "%PCBUILD%env.bat" x86 109 set PGO= 110 set BUILD=%PCBUILD%win32\ 111 set BUILD_PLAT=Win32 112 set OUTDIR_PLAT=win32 113 set OBJDIR_PLAT=x86 114) else if "%~2" NEQ "" ( 115 call "%PCBUILD%env.bat" amd64 116 set PGO=%~2 117 set BUILD=%PCBUILD%amd64-pgo\ 118 set BUILD_PLAT=x64 119 set OUTDIR_PLAT=amd64 120 set OBJDIR_PLAT=x64 121) else ( 122 call "%PCBUILD%env.bat" amd64 123 set BUILD=%PCBUILD%amd64\ 124 set BUILD_PLAT=x64 125 set OUTDIR_PLAT=amd64 126 set OBJDIR_PLAT=x64 127) 128 129if exist "%BUILD%en-us" ( 130 echo Deleting %BUILD%en-us 131 rmdir /q/s "%BUILD%en-us" 132 if errorlevel 1 exit /B 133) 134 135if exist "%D%obj\Release_%OBJDIR_PLAT%" ( 136 echo Deleting "%D%obj\Release_%OBJDIR_PLAT%" 137 rmdir /q/s "%D%obj\Release_%OBJDIR_PLAT%" 138 if errorlevel 1 exit /B 139) 140 141if not "%CERTNAME%" EQU "" ( 142 set CERTOPTS="/p:SigningCertificate=%CERTNAME%" 143) else ( 144 set CERTOPTS= 145) 146 147if not "%SKIPBUILD%" EQU "1" ( 148 @call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -d -t %TARGET% %CERTOPTS% 149 @if errorlevel 1 exit /B 150 @rem build.bat turns echo back on, so we disable it again 151 @echo off 152 153 if "%PGO%" EQU "" ( 154 @call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -t %TARGET% %CERTOPTS% 155 ) else ( 156 @call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -c PGInstrument -t %TARGET% %CERTOPTS% 157 @if errorlevel 1 exit /B 158 159 @del "%BUILD%*.pgc" 160 if "%PGO%" EQU "default" ( 161 "%BUILD%python.exe" -m test -q --pgo 162 ) else if "%PGO%" EQU "default2" ( 163 "%BUILD%python.exe" -m test -r -q --pgo 164 "%BUILD%python.exe" -m test -r -q --pgo 165 ) else if "%PGO%" EQU "default10" ( 166 for /L %%i in (0, 1, 9) do "%BUILD%python.exe" -m test -q -r --pgo 167 ) else if "%PGO%" EQU "pybench" ( 168 "%BUILD%python.exe" "%PCBUILD%..\Tools\pybench\pybench.py" 169 ) else ( 170 "%BUILD%python.exe" %PGO% 171 ) 172 173 @call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -c PGUpdate -t Build %CERTOPTS% 174 ) 175 @if errorlevel 1 exit /B 176 @echo off 177) 178 179set BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI% 180if "%PGO%" NEQ "" set BUILDOPTS=%BUILDOPTS% /p:PGOBuildPath=%BUILD% 181msbuild "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true 182if errorlevel 1 exit /B 183msbuild "%D%bundle\releaseweb.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=false 184if errorlevel 1 exit /B 185 186msbuild "%D%make_zip.proj" /t:Build %BUILDOPTS% %CERTOPTS% 187 188if not "%OUTDIR%" EQU "" ( 189 mkdir "%OUTDIR%\%OUTDIR_PLAT%" 190 copy /Y "%BUILD%en-us\*.cab" "%OUTDIR%\%OUTDIR_PLAT%" 191 copy /Y "%BUILD%en-us\*.exe" "%OUTDIR%\%OUTDIR_PLAT%" 192 copy /Y "%BUILD%en-us\*.msi" "%OUTDIR%\%OUTDIR_PLAT%" 193 copy /Y "%BUILD%en-us\*.msu" "%OUTDIR%\%OUTDIR_PLAT%" 194) 195 196exit /B 0 197 198:Help 199echo buildrelease.bat [--out DIR] [-x86] [-x64] [--certificate CERTNAME] [--build] [--skip-build] 200echo [--pgo COMMAND] [--skip-pgo] [--skip-doc] [--download DOWNLOAD URL] [--test TARGETDIR] 201echo [-h] 202echo. 203echo --out (-o) Specify an additional output directory for installers 204echo -x86 Build x86 installers 205echo -x64 Build x64 installers 206echo --build (-b) Incrementally build Python rather than rebuilding 207echo --skip-build (-B) Do not build Python (just do the installers) 208echo --skip-doc (-D) Do not build documentation 209echo --pgo Specify PGO command for x64 installers 210echo --skip-pgo Build x64 installers using PGO 211echo --download Specify the full download URL for MSIs 212echo --test Specify the test directory to run the installer tests 213echo -h Display this help information 214echo. 215echo If no architecture is specified, all architectures will be built. 216echo If --test is not specified, the installer tests are not run. 217echo. 218echo For the --pgo option, any Python command line can be used as well as the 219echo following shortcuts: 220echo Shortcut Description 221echo default Test suite with --pgo 222echo default2 2x test suite with --pgo and randomized test order 223echo default10 10x test suite with --pgo and randomized test order 224echo pybench pybench script 225echo. 226echo The following substitutions will be applied to the download URL: 227echo Variable Description Example 228echo {version} version number 3.5.0 229echo {arch} architecture amd64, win32 230echo {releasename} release name a1, b2, rc3 (or blank for final) 231echo {msi} MSI filename core.msi 232