buildrelease.bat revision 43d2b264b99a79903ad1ce6fc38b46963e2db27d
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 39set BUILDNUGET=1 40set BUILDZIP=1 41 42 43:CheckOpts 44if "%1" EQU "-h" goto Help 45if "%1" EQU "-c" (set CERTNAME=%~2) && shift && shift && goto CheckOpts 46if "%1" EQU "--certificate" (set CERTNAME=%~2) && shift && shift && goto CheckOpts 47if "%1" EQU "-o" (set OUTDIR=%~2) && shift && shift && goto CheckOpts 48if "%1" EQU "--out" (set OUTDIR=%~2) && shift && shift && goto CheckOpts 49if "%1" EQU "-D" (set SKIPDOC=1) && shift && goto CheckOpts 50if "%1" EQU "--skip-doc" (set SKIPDOC=1) && shift && goto CheckOpts 51if "%1" EQU "-B" (set SKIPBUILD=1) && shift && goto CheckOpts 52if "%1" EQU "--skip-build" (set SKIPBUILD=1) && shift && goto CheckOpts 53if "%1" EQU "--download" (set DOWNLOAD_URL=%~2) && shift && shift && goto CheckOpts 54if "%1" EQU "--test" (set TESTTARGETDIR=%~2) && shift && shift && goto CheckOpts 55if "%1" EQU "-b" (set TARGET=Build) && shift && goto CheckOpts 56if "%1" EQU "--build" (set TARGET=Build) && shift && goto CheckOpts 57if "%1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts 58if "%1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts 59if "%1" EQU "--pgo" (set PGO=%~2) && shift && shift && goto CheckOpts 60if "%1" EQU "--skip-pgo" (set PGO=) && shift && goto CheckOpts 61if "%1" EQU "--skip-nuget" (set BUILDNUGET=) && shift && goto CheckOpts 62if "%1" EQU "--skip-zip" (set BUILDZIP=) && shift && goto CheckOpts 63 64if "%1" NEQ "" echo Invalid option: "%1" && exit /B 1 65 66if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1) 67 68call "%D%get_externals.bat" 69 70:builddoc 71if "%SKIPBUILD%" EQU "1" goto skipdoc 72if "%SKIPDOC%" EQU "1" goto skipdoc 73 74if not defined PYTHON where py -q || echo Cannot find py on path and PYTHON is not set. && exit /B 1 75if not defined SPHINXBUILD where sphinx-build -q || echo Cannot find sphinx-build on path and SPHINXBUILD is not set. && exit /B 1 76 77call "%D%..\..\doc\make.bat" htmlhelp 78if errorlevel 1 goto :eof 79:skipdoc 80 81where hg /q || echo Cannot find Mercurial on PATH && exit /B 1 82 83where dlltool /q && goto skipdlltoolsearch 84set _DLLTOOL_PATH= 85where /R "%EXTERNALS%\" dlltool > "%TEMP%\dlltool.loc" 2> nul && set /P _DLLTOOL_PATH= < "%TEMP%\dlltool.loc" & del "%TEMP%\dlltool.loc" 86if not exist "%_DLLTOOL_PATH%" echo Cannot find binutils on PATH or in external && exit /B 1 87for %%f in (%_DLLTOOL_PATH%) do set PATH=%PATH%;%%~dpf 88set _DLLTOOL_PATH= 89:skipdlltoolsearch 90 91if defined BUILDX86 ( 92 call :build x86 93 if errorlevel 1 exit /B 94) 95 96if defined BUILDX64 ( 97 call :build x64 "%PGO%" 98 if errorlevel 1 exit /B 99) 100 101if defined TESTTARGETDIR ( 102 call "%D%testrelease.bat" -t "%TESTTARGETDIR%" 103) 104 105exit /B 0 106 107:build 108@setlocal 109@echo off 110 111if "%1" EQU "x86" ( 112 call "%PCBUILD%env.bat" x86 113 set PGO= 114 set BUILD=%PCBUILD%win32\ 115 set BUILD_PLAT=Win32 116 set OUTDIR_PLAT=win32 117 set OBJDIR_PLAT=x86 118) else ( 119 call "%PCBUILD%env.bat" amd64 120 set BUILD=%PCBUILD%amd64\ 121 set PGO=%~2 122 set BUILD_PLAT=x64 123 set OUTDIR_PLAT=amd64 124 set OBJDIR_PLAT=x64 125) 126 127if exist "%BUILD%en-us" ( 128 echo Deleting %BUILD%en-us 129 rmdir /q/s "%BUILD%en-us" 130 if errorlevel 1 exit /B 131) 132 133if exist "%D%obj\Release_%OBJDIR_PLAT%" ( 134 echo Deleting "%D%obj\Release_%OBJDIR_PLAT%" 135 rmdir /q/s "%D%obj\Release_%OBJDIR_PLAT%" 136 if errorlevel 1 exit /B 137) 138 139if not "%CERTNAME%" EQU "" ( 140 set CERTOPTS="/p:SigningCertificate=%CERTNAME%" 141) else ( 142 set CERTOPTS= 143) 144 145if not "%SKIPBUILD%" EQU "1" ( 146 @call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -d -t %TARGET% %CERTOPTS% 147 @if errorlevel 1 exit /B 148 @rem build.bat turns echo back on, so we disable it again 149 @echo off 150 151 if "%PGO%" EQU "" ( 152 @call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -t %TARGET% %CERTOPTS% 153 ) else ( 154 @call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -c PGInstrument -t %TARGET% %CERTOPTS% 155 @if errorlevel 1 exit /B 156 157 @del "%BUILD%*.pgc" 158 if "%PGO%" EQU "default" ( 159 "%BUILD%python.exe" -m test -q --pgo 160 ) else if "%PGO%" EQU "default2" ( 161 "%BUILD%python.exe" -m test -r -q --pgo 162 "%BUILD%python.exe" -m test -r -q --pgo 163 ) else if "%PGO%" EQU "default10" ( 164 for /L %%i in (0, 1, 9) do "%BUILD%python.exe" -m test -q -r --pgo 165 ) else if "%PGO%" EQU "pybench" ( 166 "%BUILD%python.exe" "%PCBUILD%..\Tools\pybench\pybench.py" 167 ) else ( 168 "%BUILD%python.exe" %PGO% 169 ) 170 171 @call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -c PGUpdate -t Build %CERTOPTS% 172 ) 173 @if errorlevel 1 exit /B 174 @echo off 175) 176 177if "%OUTDIR_PLAT%" EQU "win32" ( 178 msbuild "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI% 179 if errorlevel 1 exit /B 180) else if not exist "%PCBUILD%win32\en-us\launcher.msi" ( 181 msbuild "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI% 182 if errorlevel 1 exit /B 183) 184 185set BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI% 186msbuild "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true 187if errorlevel 1 exit /B 188msbuild "%D%bundle\releaseweb.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=false 189if errorlevel 1 exit /B 190 191if defined BUILDZIP ( 192 msbuild "%D%make_zip.proj" /t:Build %BUILDOPTS% %CERTOPTS% 193 if errorlevel 1 exit /B 194) 195 196if defined BUILDNUGET ( 197 msbuild "%D%..\nuget\make_pkg.proj" /t:Build /p:Configuration=Release /p:Platform=%1 /p:OutputPath="%BUILD%en-us" 198 if errorlevel 1 exit /B 199) 200 201if not "%OUTDIR%" EQU "" ( 202 mkdir "%OUTDIR%\%OUTDIR_PLAT%" 203 mkdir "%OUTDIR%\%OUTDIR_PLAT%\binaries" 204 mkdir "%OUTDIR%\%OUTDIR_PLAT%\symbols" 205 robocopy "%BUILD%en-us" "%OUTDIR%\%OUTDIR_PLAT%" /XF "*.wixpdb" 206 robocopy "%BUILD%\" "%OUTDIR%\%OUTDIR_PLAT%\binaries" *.exe *.dll *.pyd /XF "_test*" /XF "*_d.*" /XF "_freeze*" /XF "tcl*" /XF "tk*" /XF "*_test.*" 207 robocopy "%BUILD%\" "%OUTDIR%\%OUTDIR_PLAT%\symbols" *.pdb /XF "_test*" /XF "*_d.*" /XF "_freeze*" /XF "tcl*" /XF "tk*" /XF "*_test.*" 208) 209 210exit /B 0 211 212:Help 213echo buildrelease.bat [--out DIR] [-x86] [-x64] [--certificate CERTNAME] [--build] [--pgo COMMAND] 214echo [--skip-build] [--skip-doc] [--skip-nuget] [--skip-zip] [--skip-pgo] 215echo [--download DOWNLOAD URL] [--test TARGETDIR] 216echo [-h] 217echo. 218echo --out (-o) Specify an additional output directory for installers 219echo -x86 Build x86 installers 220echo -x64 Build x64 installers 221echo --build (-b) Incrementally build Python rather than rebuilding 222echo --skip-build (-B) Do not build Python (just do the installers) 223echo --skip-doc (-D) Do not build documentation 224echo --pgo Specify PGO command for x64 installers 225echo --skip-pgo Build x64 installers using PGO 226echo --skip-nuget Do not build Nuget packages 227echo --skip-zip Do not build embeddable package 228echo --pgo Build x64 installers using PGO 229echo --download Specify the full download URL for MSIs 230echo --test Specify the test directory to run the installer tests 231echo -h Display this help information 232echo. 233echo If no architecture is specified, all architectures will be built. 234echo If --test is not specified, the installer tests are not run. 235echo. 236echo For the --pgo option, any Python command line can be used as well as the 237echo following shortcuts: 238echo Shortcut Description 239echo default Test suite with --pgo 240echo default2 2x test suite with --pgo and randomized test order 241echo default10 10x test suite with --pgo and randomized test order 242echo pybench pybench script 243echo. 244echo The following substitutions will be applied to the download URL: 245echo Variable Description Example 246echo {version} version number 3.5.0 247echo {arch} architecture amd64, win32 248echo {releasename} release name a1, b2, rc3 (or blank for final) 249echo {msi} MSI filename core.msi 250