blob: 30f209f2ae386040198ebe54e8ec06ae23b066f5 [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
69if "%~1"=="-e" (set IncludeExternals=true) & call "%dir%get_externals.bat" & shift & goto CheckOpts
70if "%~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
Steve Dowere1f68052015-07-20 21:34:45 -070077if "%platf%"=="x64" (set vs_platf=x86_amd64)
Zachary Ware774ac372015-04-13 12:11:40 -050078
79rem Setup the environment
80call "%dir%env.bat" %vs_platf% >nul
81
Steve Dowere1f68052015-07-20 21:34:45 -070082if "%kill%"=="true" (
Zachary Ware67323432015-09-02 13:21:19 -050083 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 -050084)
85
Zachary Ware774ac372015-04-13 12:11:40 -050086rem Call on MSBuild to do the work, echo the command.
87rem Passing %1-9 is not the preferred option, but argument parsing in
88rem batch is, shall we say, "lackluster"
89echo on
Zachary Wareb27f3c32015-09-03 23:43:54 -050090msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
91 /p:Configuration=%conf% /p:Platform=%platf%^
92 /p:IncludeExternals=%IncludeExternals%^
93 /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^
94 %1 %2 %3 %4 %5 %6 %7 %8 %9
Steve Dower49437492015-07-08 20:18:44 -070095
96@goto :eof
97
98:Version
99rem Display the current build version information
100msbuild "%dir%python.props" /t:ShowVersionInfo /v:m /nologo %1 %2 %3 %4 %5 %6 %7 %8 %9