blob: 25f450866afdc4bbde6024293e5b72eebf38397d [file] [log] [blame]
Zachary Ware774ac372015-04-13 12:11:40 -05001@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.
7rem
8rem The first two will ensure that your release can be installed
9rem alongside an official Python release, while the second specifies
10rem the URL that will be used to download installation files. The
11rem files available from this URL *will* conflict with your installer.
12rem Trust me, you don't want them, even if it seems like a good idea.
13
14set RELEASE_URI_X86=http://www.python.org/win32
15set RELEASE_URI_X64=http://www.python.org/amd64
16set DOWNLOAD_URL_BASE=https://www.python.org/ftp/python
17set DOWNLOAD_URL=
18
19set D=%~dp0
20set PCBUILD=%D%..\..\PCBuild\
21
22set BUILDX86=
23set BUILDX64=
24set TARGET=Rebuild
25set TESTTARGETDIR=
26
27
28:CheckOpts
29if "%1" EQU "-h" goto Help
30if "%1" EQU "-c" (set CERTNAME=%~2) && shift && shift && goto CheckOpts
31if "%1" EQU "--certificate" (set CERTNAME=%~2) && shift && shift && goto CheckOpts
32if "%1" EQU "-o" (set OUTDIR=%~2) && shift && shift && goto CheckOpts
33if "%1" EQU "--out" (set OUTDIR=%~2) && shift && shift && goto CheckOpts
34if "%1" EQU "-D" (set SKIPDOC=1) && shift && goto CheckOpts
35if "%1" EQU "--skip-doc" (set SKIPDOC=1) && shift && goto CheckOpts
36if "%1" EQU "-B" (set SKIPBUILD=1) && shift && goto CheckOpts
37if "%1" EQU "--skip-build" (set SKIPBUILD=1) && shift && goto CheckOpts
38if "%1" EQU "--download" (set DOWNLOAD_URL=%~2) && shift && shift && goto CheckOpts
39if "%1" EQU "--test" (set TESTTARGETDIR=%~2) && shift && shift && goto CheckOpts
40if "%1" EQU "-b" (set TARGET=Build) && shift && goto CheckOpts
41if "%1" EQU "--build" (set TARGET=Build) && shift && goto CheckOpts
42if "%1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts
43if "%1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts
44
45if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1)
46
47:builddoc
48if "%SKIPBUILD%" EQU "1" goto skipdoc
49if "%SKIPDOC%" EQU "1" goto skipdoc
50
51if not defined PYTHON where py -q || echo Cannot find py on path and PYTHON is not set. && exit /B 1
52if not defined SPHINXBUILD where sphinx-build -q || echo Cannot find sphinx-build on path and SPHINXBUILD is not set. && exit /B 1
53call "%D%..\..\doc\make.bat" htmlhelp
54if errorlevel 1 goto :eof
55:skipdoc
56
57where hg /q || echo Cannot find Mercurial on PATH && exit /B 1
58
59where dlltool /q && goto skipdlltoolsearch
60set _DLLTOOL_PATH=
61where /R "%D%..\..\externals" dlltool > "%TEMP%\dlltool.loc" 2> nul && set /P _DLLTOOL_PATH= < "%TEMP%\dlltool.loc" & del "%TEMP%\dlltool.loc"
62if not exist "%_DLLTOOL_PATH%" echo Cannot find binutils on PATH or in external && exit /B 1
63for %%f in (%_DLLTOOL_PATH%) do set PATH=%PATH%;%%~dpf
64set _DLLTOOL_PATH=
65:skipdlltoolsearch
66
67if defined BUILDX86 (
68 call :build x86
69 if errorlevel 1 exit /B
70)
71
72if defined BUILDX64 (
73 call :build x64
74 if errorlevel 1 exit /B
75)
76
77if defined TESTTARGETDIR (
78 call "%D%testrelease.bat" -t "%TESTTARGETDIR%"
79)
80
81exit /B 0
82
83:build
84@setlocal
85@echo off
86
87if "%1" EQU "x86" (
88 call "%PCBUILD%env.bat" x86
89 set BUILD=%PCBUILD%win32\
90 set BUILD_PLAT=Win32
91 set OUTDIR_PLAT=win32
92 set OBJDIR_PLAT=x86
93 set RELEASE_URI=%RELEASE_URI_X86%
94) ELSE (
95 call "%PCBUILD%env.bat" x86_amd64
96 set BUILD=%PCBUILD%amd64\
97 set BUILD_PLAT=x64
98 set OUTDIR_PLAT=amd64
99 set OBJDIR_PLAT=x64
100 set RELEASE_URI=%RELEASE_URI_X64%
101)
102
103if exist "%BUILD%en-us" (
104 echo Deleting %BUILD%en-us
105 rmdir /q/s "%BUILD%en-us"
106 if errorlevel 1 exit /B
107)
108
109if exist "%D%obj\Release_%OBJDIR_PLAT%" (
110 echo Deleting "%D%obj\Release_%OBJDIR_PLAT%"
111 rmdir /q/s "%D%obj\Release_%OBJDIR_PLAT%"
112 if errorlevel 1 exit /B
113)
114
115if not "%CERTNAME%" EQU "" (
116 set CERTOPTS="/p:SigningCertificate=%CERTNAME%"
117) else (
118 set CERTOPTS=
119)
120
121if not "%SKIPBUILD%" EQU "1" (
122 call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -d -t %TARGET% %CERTOPTS%
123 if errorlevel 1 exit /B
124 call "%PCBUILD%build.bat" -p %BUILD_PLAT% -t %TARGET% %CERTOPTS%
125 if errorlevel 1 exit /B
126 @rem build.bat turns echo back on, so we disable it again
127 @echo off
128)
129
130"%BUILD%python.exe" "%D%get_wix.py"
131
132set BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI%
133msbuild "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true
134if errorlevel 1 exit /B
135msbuild "%D%bundle\releaseweb.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=false
136if errorlevel 1 exit /B
137
138if not "%OUTDIR%" EQU "" (
139 mkdir "%OUTDIR%\%OUTDIR_PLAT%"
140 copy /Y "%BUILD%en-us\*.cab" "%OUTDIR%\%OUTDIR_PLAT%"
141 copy /Y "%BUILD%en-us\*.exe" "%OUTDIR%\%OUTDIR_PLAT%"
142 copy /Y "%BUILD%en-us\*.msi" "%OUTDIR%\%OUTDIR_PLAT%"
143 copy /Y "%BUILD%en-us\*.msu" "%OUTDIR%\%OUTDIR_PLAT%"
144)
145
146exit /B 0
147
148:Help
149echo buildrelease.bat [--out DIR] [-x86] [-x64] [--certificate CERTNAME] [--build] [--skip-build]
150echo [--skip-doc] [--download DOWNLOAD URL] [--test TARGETDIR] [-h]
151echo.
152echo --out (-o) Specify an additional output directory for installers
153echo -x86 Build x86 installers
154echo -x64 Build x64 installers
155echo --build (-b) Incrementally build Python rather than rebuilding
156echo --skip-build (-B) Do not build Python (just do the installers)
157echo --skip-doc (-D) Do not build documentation
158echo --download Specify the full download URL for MSIs (should include {2})
159echo --test Specify the test directory to run the installer tests
160echo -h Display this help information
161echo.
162echo If no architecture is specified, all architectures will be built.
163echo If --test is not specified, the installer tests are not run.
Steve Dower312cef02015-02-07 22:20:48 -0800164echo.