Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [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.
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 7 |
|
Steve Dower | c4b7600 | 2015-10-01 15:18:53 -0700 | [diff] [blame] | 8 | rem These two will ensure that your release can be installed
|
| 9 | rem alongside an official Python release, by modifying the GUIDs used
|
| 10 | rem for all components.
|
| 11 | rem
|
| 12 | rem The following substitutions will be applied to the release URI:
|
| 13 | rem Variable Description Example
|
| 14 | rem {arch} architecture amd64, win32
|
| 15 | set RELEASE_URI=http://www.python.org/{arch}
|
| 16 |
|
| 17 | rem This is the URL that will be used to download installation files.
|
| 18 | rem The files available from the default URL *will* conflict with your
|
| 19 | rem installer. Trust me, you don't want them, even if it seems like a
|
| 20 | rem good idea.
|
| 21 | rem
|
| 22 | rem The following substitutions will be applied to the download URL:
|
| 23 | rem Variable Description Example
|
| 24 | rem {version} version number 3.5.0
|
| 25 | rem {arch} architecture amd64, win32
|
| 26 | rem {releasename} release name a1, b2, rc3 (or blank for final)
|
| 27 | rem {msi} MSI filename core.msi
|
| 28 | set DOWNLOAD_URL=https://www.python.org/ftp/python/{version}/{arch}{releasename}/{msi}
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 29 |
|
| 30 | set D=%~dp0
|
| 31 | set PCBUILD=%D%..\..\PCBuild\
|
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 32 | set EXTERNALS=%D%..\..\externals\windows-installer\
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 33 |
|
| 34 | set BUILDX86=
|
| 35 | set BUILDX64=
|
| 36 | set TARGET=Rebuild
|
| 37 | set TESTTARGETDIR=
|
Steve Dower | 4468bed | 2016-11-14 16:13:56 -0800 | [diff] [blame] | 38 | set PGO=-m test -q --pgo
|
Steve Dower | fcf622e | 2016-10-27 12:08:45 -0700 | [diff] [blame] | 39 | set BUILDNUGET=1
|
| 40 | set BUILDZIP=1
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 41 |
|
| 42 |
|
| 43 | :CheckOpts
|
| 44 | if "%1" EQU "-h" goto Help
|
| 45 | if "%1" EQU "-c" (set CERTNAME=%~2) && shift && shift && goto CheckOpts
|
| 46 | if "%1" EQU "--certificate" (set CERTNAME=%~2) && shift && shift && goto CheckOpts
|
| 47 | if "%1" EQU "-o" (set OUTDIR=%~2) && shift && shift && goto CheckOpts
|
| 48 | if "%1" EQU "--out" (set OUTDIR=%~2) && shift && shift && goto CheckOpts
|
| 49 | if "%1" EQU "-D" (set SKIPDOC=1) && shift && goto CheckOpts
|
| 50 | if "%1" EQU "--skip-doc" (set SKIPDOC=1) && shift && goto CheckOpts
|
| 51 | if "%1" EQU "-B" (set SKIPBUILD=1) && shift && goto CheckOpts
|
| 52 | if "%1" EQU "--skip-build" (set SKIPBUILD=1) && shift && goto CheckOpts
|
| 53 | if "%1" EQU "--download" (set DOWNLOAD_URL=%~2) && shift && shift && goto CheckOpts
|
| 54 | if "%1" EQU "--test" (set TESTTARGETDIR=%~2) && shift && shift && goto CheckOpts
|
| 55 | if "%1" EQU "-b" (set TARGET=Build) && shift && goto CheckOpts
|
| 56 | if "%1" EQU "--build" (set TARGET=Build) && shift && goto CheckOpts
|
| 57 | if "%1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts
|
| 58 | if "%1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts
|
Steve Dower | 148827c | 2015-10-14 10:40:09 -0700 | [diff] [blame] | 59 | if "%1" EQU "--pgo" (set PGO=%~2) && shift && shift && goto CheckOpts
|
Steve Dower | 22d0698 | 2016-09-06 19:38:15 -0700 | [diff] [blame] | 60 | if "%1" EQU "--skip-pgo" (set PGO=) && shift && goto CheckOpts
|
Steve Dower | fcf622e | 2016-10-27 12:08:45 -0700 | [diff] [blame] | 61 | if "%1" EQU "--skip-nuget" (set BUILDNUGET=) && shift && goto CheckOpts
|
| 62 | if "%1" EQU "--skip-zip" (set BUILDZIP=) && shift && goto CheckOpts
|
Steve Dower | 148827c | 2015-10-14 10:40:09 -0700 | [diff] [blame] | 63 |
|
| 64 | if "%1" NEQ "" echo Invalid option: "%1" && exit /B 1
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 65 |
|
| 66 | if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1)
|
| 67 |
|
Steve Dower | d3e1e9d | 2017-03-03 21:32:17 -0800 | [diff] [blame^] | 68 | if not exist "%GIT%" where git > "%TEMP%\git.loc" 2> nul && set /P GIT= < "%TEMP%\git.loc" & del "%TEMP%\git.loc"
|
| 69 | if not exist "%GIT%" echo Cannot find Git on PATH && exit /B 1
|
Steve Dower | 190dbd9 | 2016-12-03 11:18:53 -0800 | [diff] [blame] | 70 |
|
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 71 | call "%D%get_externals.bat"
|
| 72 |
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 73 | :builddoc
|
| 74 | if "%SKIPBUILD%" EQU "1" goto skipdoc
|
| 75 | if "%SKIPDOC%" EQU "1" goto skipdoc
|
| 76 |
|
| 77 | if not defined PYTHON where py -q || echo Cannot find py on path and PYTHON is not set. && exit /B 1
|
| 78 | if not defined SPHINXBUILD where sphinx-build -q || echo Cannot find sphinx-build on path and SPHINXBUILD is not set. && exit /B 1
|
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 79 |
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 80 | call "%D%..\..\doc\make.bat" htmlhelp
|
| 81 | if errorlevel 1 goto :eof
|
| 82 | :skipdoc
|
| 83 |
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 84 | where dlltool /q && goto skipdlltoolsearch
|
| 85 | set _DLLTOOL_PATH=
|
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 86 | where /R "%EXTERNALS%\" dlltool > "%TEMP%\dlltool.loc" 2> nul && set /P _DLLTOOL_PATH= < "%TEMP%\dlltool.loc" & del "%TEMP%\dlltool.loc"
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 87 | if not exist "%_DLLTOOL_PATH%" echo Cannot find binutils on PATH or in external && exit /B 1
|
| 88 | for %%f in (%_DLLTOOL_PATH%) do set PATH=%PATH%;%%~dpf
|
| 89 | set _DLLTOOL_PATH=
|
| 90 | :skipdlltoolsearch
|
| 91 |
|
| 92 | if defined BUILDX86 (
|
| 93 | call :build x86
|
| 94 | if errorlevel 1 exit /B
|
| 95 | )
|
| 96 |
|
| 97 | if defined BUILDX64 (
|
Steve Dower | 148827c | 2015-10-14 10:40:09 -0700 | [diff] [blame] | 98 | call :build x64 "%PGO%"
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 99 | if errorlevel 1 exit /B
|
| 100 | )
|
| 101 |
|
| 102 | if defined TESTTARGETDIR (
|
| 103 | call "%D%testrelease.bat" -t "%TESTTARGETDIR%"
|
| 104 | )
|
| 105 |
|
| 106 | exit /B 0
|
| 107 |
|
| 108 | :build
|
| 109 | @setlocal
|
| 110 | @echo off
|
| 111 |
|
| 112 | if "%1" EQU "x86" (
|
Steve Dower | 2a1f30f | 2016-09-09 14:21:24 -0700 | [diff] [blame] | 113 | set PGO=
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 114 | set BUILD=%PCBUILD%win32\
|
| 115 | set BUILD_PLAT=Win32
|
| 116 | set OUTDIR_PLAT=win32
|
| 117 | set OBJDIR_PLAT=x86
|
Steve Dower | 148827c | 2015-10-14 10:40:09 -0700 | [diff] [blame] | 118 | ) else (
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 119 | set BUILD=%PCBUILD%amd64\
|
Steve Dower | e7da2f8 | 2016-09-11 20:19:35 -0700 | [diff] [blame] | 120 | set PGO=%~2
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 121 | set BUILD_PLAT=x64
|
| 122 | set OUTDIR_PLAT=amd64
|
| 123 | set OBJDIR_PLAT=x64
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 124 | )
|
| 125 |
|
| 126 | if exist "%BUILD%en-us" (
|
| 127 | echo Deleting %BUILD%en-us
|
| 128 | rmdir /q/s "%BUILD%en-us"
|
| 129 | if errorlevel 1 exit /B
|
| 130 | )
|
| 131 |
|
Steve Dower | 02a4018 | 2016-11-22 11:48:52 -0800 | [diff] [blame] | 132 | if exist "%D%obj\Debug_%OBJDIR_PLAT%" (
|
| 133 | echo Deleting "%D%obj\Debug_%OBJDIR_PLAT%"
|
| 134 | rmdir /q/s "%D%obj\Debug_%OBJDIR_PLAT%"
|
| 135 | if errorlevel 1 exit /B
|
| 136 | )
|
| 137 |
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 138 | if 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 |
|
| 144 | if not "%CERTNAME%" EQU "" (
|
| 145 | set CERTOPTS="/p:SigningCertificate=%CERTNAME%"
|
| 146 | ) else (
|
| 147 | set CERTOPTS=
|
| 148 | )
|
Steve Dower | de40e12 | 2016-11-14 17:51:42 -0800 | [diff] [blame] | 149 | if not "%PGO%" EQU "" (
|
| 150 | set PGOOPTS=--pgo-job "%PGO%"
|
| 151 | ) else (
|
| 152 | set PGOOPTS=
|
| 153 | )
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 154 | if not "%SKIPBUILD%" EQU "1" (
|
Steve Dower | 02a4018 | 2016-11-22 11:48:52 -0800 | [diff] [blame] | 155 | @echo call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -t %TARGET% %PGOOPTS% %CERTOPTS%
|
| 156 | @call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -t %TARGET% %PGOOPTS% %CERTOPTS%
|
| 157 | @if errorlevel 1 exit /B
|
| 158 | @rem build.bat turns echo back on, so we disable it again
|
| 159 | @echo off
|
| 160 |
|
| 161 | @echo call "%PCBUILD%build.bat" -d -e -p %BUILD_PLAT% -t %TARGET%
|
| 162 | @call "%PCBUILD%build.bat" -d -e -p %BUILD_PLAT% -t %TARGET%
|
Steve Dower | 148827c | 2015-10-14 10:40:09 -0700 | [diff] [blame] | 163 | @if errorlevel 1 exit /B
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 164 | @rem build.bat turns echo back on, so we disable it again
|
| 165 | @echo off
|
| 166 | )
|
| 167 |
|
Steve Dower | 4468bed | 2016-11-14 16:13:56 -0800 | [diff] [blame] | 168 | call "%PCBUILD%env.bat"
|
Steve Dower | ec1f28a | 2016-10-10 16:19:06 -0700 | [diff] [blame] | 169 | if "%OUTDIR_PLAT%" EQU "win32" (
|
| 170 | msbuild "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI%
|
| 171 | if errorlevel 1 exit /B
|
| 172 | ) else if not exist "%PCBUILD%win32\en-us\launcher.msi" (
|
| 173 | msbuild "%D%launcher\launcher.wixproj" /p:Platform=x86 %CERTOPTS% /p:ReleaseUri=%RELEASE_URI%
|
| 174 | if errorlevel 1 exit /B
|
| 175 | )
|
| 176 |
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 177 | set BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI%
|
| 178 | msbuild "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true
|
| 179 | if errorlevel 1 exit /B
|
| 180 | msbuild "%D%bundle\releaseweb.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=false
|
| 181 | if errorlevel 1 exit /B
|
| 182 |
|
Steve Dower | fcf622e | 2016-10-27 12:08:45 -0700 | [diff] [blame] | 183 | if defined BUILDZIP (
|
Steve Dower | 190dbd9 | 2016-12-03 11:18:53 -0800 | [diff] [blame] | 184 | msbuild "%D%make_zip.proj" /t:Build %BUILDOPTS% %CERTOPTS% /p:OutputPath="%BUILD%en-us"
|
Steve Dower | fcf622e | 2016-10-27 12:08:45 -0700 | [diff] [blame] | 185 | if errorlevel 1 exit /B
|
| 186 | )
|
| 187 |
|
| 188 | if defined BUILDNUGET (
|
| 189 | msbuild "%D%..\nuget\make_pkg.proj" /t:Build /p:Configuration=Release /p:Platform=%1 /p:OutputPath="%BUILD%en-us"
|
| 190 | if errorlevel 1 exit /B
|
| 191 | )
|
Steve Dower | f70fdd2 | 2015-04-14 18:34:04 -0400 | [diff] [blame] | 192 |
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 193 | if not "%OUTDIR%" EQU "" (
|
| 194 | mkdir "%OUTDIR%\%OUTDIR_PLAT%"
|
Steve Dower | fcf622e | 2016-10-27 12:08:45 -0700 | [diff] [blame] | 195 | mkdir "%OUTDIR%\%OUTDIR_PLAT%\binaries"
|
| 196 | mkdir "%OUTDIR%\%OUTDIR_PLAT%\symbols"
|
| 197 | robocopy "%BUILD%en-us" "%OUTDIR%\%OUTDIR_PLAT%" /XF "*.wixpdb"
|
| 198 | robocopy "%BUILD%\" "%OUTDIR%\%OUTDIR_PLAT%\binaries" *.exe *.dll *.pyd /XF "_test*" /XF "*_d.*" /XF "_freeze*" /XF "tcl*" /XF "tk*" /XF "*_test.*"
|
| 199 | robocopy "%BUILD%\" "%OUTDIR%\%OUTDIR_PLAT%\symbols" *.pdb /XF "_test*" /XF "*_d.*" /XF "_freeze*" /XF "tcl*" /XF "tk*" /XF "*_test.*"
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 200 | )
|
| 201 |
|
| 202 | exit /B 0
|
| 203 |
|
| 204 | :Help
|
Steve Dower | fcf622e | 2016-10-27 12:08:45 -0700 | [diff] [blame] | 205 | echo buildrelease.bat [--out DIR] [-x86] [-x64] [--certificate CERTNAME] [--build] [--pgo COMMAND]
|
Steve Dower | 43d2b26 | 2016-10-27 12:12:24 -0700 | [diff] [blame] | 206 | echo [--skip-build] [--skip-doc] [--skip-nuget] [--skip-zip] [--skip-pgo]
|
Steve Dower | fcf622e | 2016-10-27 12:08:45 -0700 | [diff] [blame] | 207 | echo [--download DOWNLOAD URL] [--test TARGETDIR]
|
Steve Dower | 148827c | 2015-10-14 10:40:09 -0700 | [diff] [blame] | 208 | echo [-h]
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 209 | echo.
|
| 210 | echo --out (-o) Specify an additional output directory for installers
|
| 211 | echo -x86 Build x86 installers
|
| 212 | echo -x64 Build x64 installers
|
| 213 | echo --build (-b) Incrementally build Python rather than rebuilding
|
| 214 | echo --skip-build (-B) Do not build Python (just do the installers)
|
| 215 | echo --skip-doc (-D) Do not build documentation
|
Steve Dower | 22d0698 | 2016-09-06 19:38:15 -0700 | [diff] [blame] | 216 | echo --pgo Specify PGO command for x64 installers
|
Steve Dower | 4468bed | 2016-11-14 16:13:56 -0800 | [diff] [blame] | 217 | echo --skip-pgo Build x64 installers without using PGO
|
Steve Dower | fcf622e | 2016-10-27 12:08:45 -0700 | [diff] [blame] | 218 | echo --skip-nuget Do not build Nuget packages
|
| 219 | echo --skip-zip Do not build embeddable package
|
Steve Dower | c4b7600 | 2015-10-01 15:18:53 -0700 | [diff] [blame] | 220 | echo --download Specify the full download URL for MSIs
|
Zachary Ware | 774ac37 | 2015-04-13 12:11:40 -0500 | [diff] [blame] | 221 | echo --test Specify the test directory to run the installer tests
|
| 222 | echo -h Display this help information
|
| 223 | echo.
|
| 224 | echo If no architecture is specified, all architectures will be built.
|
| 225 | echo If --test is not specified, the installer tests are not run.
|
Steve Dower | c4b7600 | 2015-10-01 15:18:53 -0700 | [diff] [blame] | 226 | echo.
|
Steve Dower | 4468bed | 2016-11-14 16:13:56 -0800 | [diff] [blame] | 227 | echo For the --pgo option, any Python command line can be used, or 'default' to
|
| 228 | echo use the default task (-m test --pgo).
|
Steve Dower | 148827c | 2015-10-14 10:40:09 -0700 | [diff] [blame] | 229 | echo.
|
Steve Dower | c4b7600 | 2015-10-01 15:18:53 -0700 | [diff] [blame] | 230 | echo The following substitutions will be applied to the download URL:
|
| 231 | echo Variable Description Example
|
| 232 | echo {version} version number 3.5.0
|
| 233 | echo {arch} architecture amd64, win32
|
| 234 | echo {releasename} release name a1, b2, rc3 (or blank for final)
|
| 235 | echo {msi} MSI filename core.msi
|