blob: 2c41fb21eb2de24a49ee8a02df9a630afd617562 [file] [log] [blame]
Zachary Ware4c9c8482015-04-13 11:59:54 -05001@echo off
Zachary Ware67323432015-09-02 13:21:19 -05002goto Run
3:Usage
4echo.%~nx0 [flags and arguments] [quoted MSBuild options]
5echo.
6echo.Build CPython from the command line. Requires the appropriate
7echo.version(s) of Microsoft Visual Studio to be installed (see readme.txt).
8echo.Also requires Subversion (svn.exe) to be on PATH if the '-e' flag is
9echo.given.
10echo.
11echo.After the flags recognized by this script, up to 9 arguments to be passed
12echo.directly to MSBuild may be passed. If the argument contains an '=', the
13echo.entire argument must be quoted (e.g. `%~nx0 "/p:PlatformToolset=v100"`)
14echo.
15echo.Available flags:
16echo. -h Display this help message
17echo. -V Display version information for the current build
18echo. -r Target Rebuild instead of Build
19echo. -d Set the configuration to Debug
20echo. -e Build external libraries fetched by get_externals.bat
Zachary Wareb27f3c32015-09-03 23:43:54 -050021echo. Extension modules that depend on external libraries will not attempt
22echo. to build if this flag is not present
Zachary Ware67323432015-09-02 13:21:19 -050023echo. -m Enable parallel build (enabled by default)
24echo. -M Disable parallel build
25echo. -v Increased output messages
26echo. -k Attempt to kill any running Pythons before building (usually done
27echo. automatically by the pythoncore project)
28echo.
Zachary Wareb27f3c32015-09-03 23:43:54 -050029echo.Available flags to avoid building certain modules.
30echo.These flags have no effect if '-e' is not given:
31echo. --no-ssl Do not attempt to build _ssl
32echo. --no-tkinter Do not attempt to build Tkinter
33echo.
Zachary Ware67323432015-09-02 13:21:19 -050034echo.Available arguments:
35echo. -c Release ^| Debug ^| PGInstrument ^| PGUpdate
36echo. Set the configuration (default: Release)
37echo. -p x64 ^| Win32
38echo. Set the platform (default: Win32)
39echo. -t Build ^| Rebuild ^| Clean ^| CleanAll
40echo. Set the target manually
41exit /b 127
Zachary Ware4c9c8482015-04-13 11:59:54 -050042
Zachary Ware67323432015-09-02 13:21:19 -050043:Run
Zachary Ware4c9c8482015-04-13 11:59:54 -050044setlocal
45set platf=Win32
Zachary Ware774ac372015-04-13 12:11:40 -050046set vs_platf=x86
Zachary Ware4c9c8482015-04-13 11:59:54 -050047set conf=Release
Zachary Ware774ac372015-04-13 12:11:40 -050048set target=Build
Zachary Ware4c9c8482015-04-13 11:59:54 -050049set dir=%~dp0
Zachary Ware774ac372015-04-13 12:11:40 -050050set parallel=/m
51set verbose=/nologo /v:m
Zachary Ware6250df82015-06-09 23:16:52 -050052set kill=
Zachary Ware4c9c8482015-04-13 11:59:54 -050053
54:CheckOpts
Zachary Ware67323432015-09-02 13:21:19 -050055if "%~1"=="-h" goto Usage
Steve Dowere1f68052015-07-20 21:34:45 -070056if "%~1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts
57if "%~1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts
58if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts
59if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts
60if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts
Steve Dowere1f68052015-07-20 21:34:45 -070061if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
62if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts
63if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts
64if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts
65if "%~1"=="-V" shift & goto Version
Zachary Wareb27f3c32015-09-03 23:43:54 -050066rem These use the actual property names used by MSBuild. We could just let
67rem them in through the environment, but we specify them on the command line
68rem anyway for visibility so set defaults after this
Zachary Warea6deff22015-09-04 01:10:23 -050069if "%~1"=="-e" (set IncludeExternals=true) & shift & goto CheckOpts
Zachary Wareb27f3c32015-09-03 23:43:54 -050070if "%~1"=="--no-ssl" (set IncludeSSL=false) & shift & goto CheckOpts
71if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
72
73if "%IncludeExternals%"=="" set IncludeExternals=false
74if "%IncludeSSL%"=="" set IncludeSSL=true
75if "%IncludeTkinter%"=="" set IncludeTkinter=true
Zachary Ware4c9c8482015-04-13 11:59:54 -050076
Zachary Warea6deff22015-09-04 01:10:23 -050077if "%IncludeExternals%"=="true" call "%dir%get_externals.bat"
78
Steve Dowere1f68052015-07-20 21:34:45 -070079if "%platf%"=="x64" (set vs_platf=x86_amd64)
Zachary Ware774ac372015-04-13 12:11:40 -050080
81rem Setup the environment
82call "%dir%env.bat" %vs_platf% >nul
83
Steve Dowere1f68052015-07-20 21:34:45 -070084if "%kill%"=="true" (
Zachary Ware67323432015-09-02 13:21:19 -050085 msbuild /v:m /nologo /target:KillPython "%dir%\pythoncore.vcxproj" /p:Configuration=%conf% /p:Platform=%platf% /p:KillPython=true
Zachary Ware6250df82015-06-09 23:16:52 -050086)
87
Zachary Ware774ac372015-04-13 12:11:40 -050088rem Call on MSBuild to do the work, echo the command.
89rem Passing %1-9 is not the preferred option, but argument parsing in
90rem batch is, shall we say, "lackluster"
91echo on
Zachary Wareb27f3c32015-09-03 23:43:54 -050092msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
93 /p:Configuration=%conf% /p:Platform=%platf%^
94 /p:IncludeExternals=%IncludeExternals%^
95 /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^
96 %1 %2 %3 %4 %5 %6 %7 %8 %9
Steve Dower49437492015-07-08 20:18:44 -070097
98@goto :eof
99
100:Version
101rem Display the current build version information
102msbuild "%dir%python.props" /t:ShowVersionInfo /v:m /nologo %1 %2 %3 %4 %5 %6 %7 %8 %9