blob: 7183a842f5cd4e033a5abda2249af4eb3a820285 [file] [log] [blame]
Steve Dowerbb240872015-02-05 22:08:48 -08001@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
Steve Dower50564552015-02-07 15:42:53 -080025set TESTTARGETDIR=
Steve Dowerbb240872015-02-05 22:08:48 -080026
27
28:CheckOpts
29if "%1" EQU "-c" (set CERTNAME=%~2) && shift && shift && goto CheckOpts
30if "%1" EQU "-o" (set OUTDIR=%~2) && shift && shift && goto CheckOpts
31if "%1" EQU "-D" (set SKIPDOC=1) && shift && goto CheckOpts
32if "%1" EQU "-B" (set SKIPBUILD=1) && shift && goto CheckOpts
33if "%1" EQU "--download" (set DOWNLOAD_URL=%~2) && shift && shift && goto CheckOpts
Steve Dower50564552015-02-07 15:42:53 -080034if "%1" EQU "--test" (set TESTTARGETDIR=%~2) && shift && shift && goto CheckOpts
Steve Dowerbb240872015-02-05 22:08:48 -080035if "%1" EQU "-b" (set TARGET=Build) && shift && goto CheckOpts
36if '%1' EQU '-x86' (set BUILDX86=1) && shift && goto CheckOpts
37if '%1' EQU '-x64' (set BUILDX64=1) && shift && goto CheckOpts
38
39if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1)
40
41:builddoc
42if "%SKIPBUILD%" EQU "1" goto skipdoc
43if "%SKIPDOC%" EQU "1" goto skipdoc
44
45call "%D%..\..\doc\make.bat" htmlhelp
46if errorlevel 1 goto :eof
47:skipdoc
48
Steve Dower268f3de2015-02-06 09:02:54 -080049where hg >nul 2>nul
50if errorlevel 1 echo Cannot find hg on PATH & exit /B 1
51
Steve Dowerbb240872015-02-05 22:08:48 -080052where dlltool 2>nul >"%TEMP%\dlltool.loc"
53if errorlevel 1 dir "%D%..\..\externals\dlltool.exe" /s/b > "%TEMP%\dlltool.loc"
54if errorlevel 1 echo Cannot find binutils on PATH or in externals & exit /B 1
55set /P DLLTOOL= < "%TEMP%\dlltool.loc"
56set PATH=%PATH%;%DLLTOOL:~,-12%
57set DLLTOOL=
58del "%TEMP%\dlltool.loc"
59
60
61if defined BUILDX86 (
62 call :build x86
63 if errorlevel 1 exit /B
64)
65
66if defined BUILDX64 (
67 call :build x64
68 if errorlevel 1 exit /B
69)
70
Steve Dower50564552015-02-07 15:42:53 -080071if defined TESTTARGETDIR (
72 call "%D%testrelease.bat" -t "%TESTTARGETDIR%"
73)
74
Steve Dowerbb240872015-02-05 22:08:48 -080075exit /B 0
76
77:build
78@setlocal
79@echo off
80
81if "%1" EQU "x86" (
82 call "%PCBUILD%env.bat" x86
83 set BUILD=%PCBUILD%win32\
84 set BUILD_PLAT=Win32
85 set OUTDIR_PLAT=win32
86 set OBJDIR_PLAT=x86
87 set RELEASE_URI=%RELEASE_URI_X86%
88) ELSE (
89 call "%PCBUILD%env.bat" x86_amd64
90 set BUILD=%PCBUILD%amd64\
91 set BUILD_PLAT=x64
92 set OUTDIR_PLAT=amd64
93 set OBJDIR_PLAT=x64
94 set RELEASE_URI=%RELEASE_URI_X64%
95)
96
97echo on
98if exist "%BUILD%en-us" (
99 echo Deleting %BUILD%en-us
100 rmdir /q/s "%BUILD%en-us"
101 if errorlevel 1 exit /B
102)
103
104echo on
105if exist "%D%obj\Release_%OBJDIR_PLAT%" (
106 echo Deleting "%D%obj\Release_%OBJDIR_PLAT%"
107 rmdir /q/s "%D%obj\Release_%OBJDIR_PLAT%"
108 if errorlevel 1 exit /B
109)
110
111if not "%CERTNAME%" EQU "" (
112 set CERTOPTS="/p:SigningCertificate=%CERTNAME%"
113) else (
114 set CERTOPTS=
115)
116
117if not "%SKIPBUILD%" EQU "1" (
118 call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -d -t %TARGET% %CERTOPTS%
119 if errorlevel 1 exit /B
120 call "%PCBUILD%build.bat" -p %BUILD_PLAT% -t %TARGET% %CERTOPTS%
121 if errorlevel 1 exit /B
122 @rem build.bat turns echo back on, so we disable it again
123 @echo off
124)
125
126"%BUILD%python.exe" "%D%get_wix.py"
127
128set BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI%
129msbuild "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true
130if errorlevel 1 exit /B
131msbuild "%D%bundle\releaseweb.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=false
132if errorlevel 1 exit /B
133
134if not "%OUTDIR%" EQU "" (
135 mkdir "%OUTDIR%\%OUTDIR_PLAT%"
136 copy /Y "%BUILD%en-us\*.cab" "%OUTDIR%\%OUTDIR_PLAT%"
137 copy /Y "%BUILD%en-us\*.exe" "%OUTDIR%\%OUTDIR_PLAT%"
138 copy /Y "%BUILD%en-us\*.msi" "%OUTDIR%\%OUTDIR_PLAT%"
139)
140