blob: b39f13e083290c573e8b5a27662c6cd689efbd9f [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
47where dlltool 2>nul >"%TEMP%\dlltool.loc"
48if errorlevel 1 dir "%D%..\..\externals\dlltool.exe" /s/b > "%TEMP%\dlltool.loc"
49if errorlevel 1 echo Cannot find binutils on PATH or in externals & exit /B 1
50set /P DLLTOOL= < "%TEMP%\dlltool.loc"
51set PATH=%PATH%;%DLLTOOL:~,-12%
52set DLLTOOL=
53del "%TEMP%\dlltool.loc"
54
55
56if defined BUILDX86 (
57 call :build x86
58 if errorlevel 1 exit /B
59)
60
61if defined BUILDX64 (
62 call :build x64
63 if errorlevel 1 exit /B
64)
65
66exit /B 0
67
68:build
69@setlocal
70@echo off
71
72if "%1" EQU "x86" (
73 call "%PCBUILD%env.bat" x86
74 set BUILD=%PCBUILD%win32\
75 set BUILD_PLAT=Win32
76 set OUTDIR_PLAT=win32
77 set OBJDIR_PLAT=x86
78 set RELEASE_URI=%RELEASE_URI_X86%
79) ELSE (
80 call "%PCBUILD%env.bat" x86_amd64
81 set BUILD=%PCBUILD%amd64\
82 set BUILD_PLAT=x64
83 set OUTDIR_PLAT=amd64
84 set OBJDIR_PLAT=x64
85 set RELEASE_URI=%RELEASE_URI_X64%
86)
87
88echo on
89if exist "%BUILD%en-us" (
90 echo Deleting %BUILD%en-us
91 rmdir /q/s "%BUILD%en-us"
92 if errorlevel 1 exit /B
93)
94
95echo on
96if exist "%D%obj\Release_%OBJDIR_PLAT%" (
97 echo Deleting "%D%obj\Release_%OBJDIR_PLAT%"
98 rmdir /q/s "%D%obj\Release_%OBJDIR_PLAT%"
99 if errorlevel 1 exit /B
100)
101
102if not "%CERTNAME%" EQU "" (
103 set CERTOPTS="/p:SigningCertificate=%CERTNAME%"
104) else (
105 set CERTOPTS=
106)
107
108if not "%SKIPBUILD%" EQU "1" (
109 call "%PCBUILD%build.bat" -e -p %BUILD_PLAT% -d -t %TARGET% %CERTOPTS%
110 if errorlevel 1 exit /B
111 call "%PCBUILD%build.bat" -p %BUILD_PLAT% -t %TARGET% %CERTOPTS%
112 if errorlevel 1 exit /B
113 @rem build.bat turns echo back on, so we disable it again
114 @echo off
115)
116
117"%BUILD%python.exe" "%D%get_wix.py"
118
119set BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI%
120msbuild "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true
121if errorlevel 1 exit /B
122msbuild "%D%bundle\releaseweb.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=false
123if errorlevel 1 exit /B
124
125if not "%OUTDIR%" EQU "" (
126 mkdir "%OUTDIR%\%OUTDIR_PLAT%"
127 copy /Y "%BUILD%en-us\*.cab" "%OUTDIR%\%OUTDIR_PLAT%"
128 copy /Y "%BUILD%en-us\*.exe" "%OUTDIR%\%OUTDIR_PLAT%"
129 copy /Y "%BUILD%en-us\*.msi" "%OUTDIR%\%OUTDIR_PLAT%"
130)
131