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