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