blob: cfbc4a29377755c9373cffd5d39a18d837329dfe [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
Steve Dower940f6a82015-10-31 12:17:11 -070041echo. --test-marker Enable the test marker within the build.
Zachary Ware67323432015-09-02 13:21:19 -050042exit /b 127
Zachary Ware4c9c8482015-04-13 11:59:54 -050043
Zachary Ware67323432015-09-02 13:21:19 -050044:Run
Zachary Ware4c9c8482015-04-13 11:59:54 -050045setlocal
46set platf=Win32
Zachary Ware774ac372015-04-13 12:11:40 -050047set vs_platf=x86
Zachary Ware4c9c8482015-04-13 11:59:54 -050048set conf=Release
Zachary Ware774ac372015-04-13 12:11:40 -050049set target=Build
Zachary Ware4c9c8482015-04-13 11:59:54 -050050set dir=%~dp0
Zachary Ware774ac372015-04-13 12:11:40 -050051set parallel=/m
52set verbose=/nologo /v:m
Zachary Ware6250df82015-06-09 23:16:52 -050053set kill=
Zachary Ware4c9c8482015-04-13 11:59:54 -050054
55:CheckOpts
Zachary Ware67323432015-09-02 13:21:19 -050056if "%~1"=="-h" goto Usage
Steve Dowere1f68052015-07-20 21:34:45 -070057if "%~1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts
58if "%~1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts
59if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts
60if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts
61if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts
Steve Dowere1f68052015-07-20 21:34:45 -070062if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
63if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts
64if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts
65if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts
Steve Dower940f6a82015-10-31 12:17:11 -070066if "%~1"=="--test-marker" (set UseTestMarker=true) & shift & goto CheckOpts
Steve Dowere1f68052015-07-20 21:34:45 -070067if "%~1"=="-V" shift & goto Version
Zachary Wareb27f3c32015-09-03 23:43:54 -050068rem These use the actual property names used by MSBuild. We could just let
69rem them in through the environment, but we specify them on the command line
70rem anyway for visibility so set defaults after this
Zachary Warea6deff22015-09-04 01:10:23 -050071if "%~1"=="-e" (set IncludeExternals=true) & shift & goto CheckOpts
Zachary Wareb27f3c32015-09-03 23:43:54 -050072if "%~1"=="--no-ssl" (set IncludeSSL=false) & shift & goto CheckOpts
73if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
74
75if "%IncludeExternals%"=="" set IncludeExternals=false
76if "%IncludeSSL%"=="" set IncludeSSL=true
77if "%IncludeTkinter%"=="" set IncludeTkinter=true
Zachary Ware4c9c8482015-04-13 11:59:54 -050078
Zachary Warea6deff22015-09-04 01:10:23 -050079if "%IncludeExternals%"=="true" call "%dir%get_externals.bat"
80
Steve Dowere1f68052015-07-20 21:34:45 -070081if "%platf%"=="x64" (set vs_platf=x86_amd64)
Zachary Ware774ac372015-04-13 12:11:40 -050082
83rem Setup the environment
84call "%dir%env.bat" %vs_platf% >nul
85
Steve Dowere1f68052015-07-20 21:34:45 -070086if "%kill%"=="true" (
Zachary Ware67323432015-09-02 13:21:19 -050087 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 -050088)
89
Zachary Ware774ac372015-04-13 12:11:40 -050090rem Call on MSBuild to do the work, echo the command.
91rem Passing %1-9 is not the preferred option, but argument parsing in
92rem batch is, shall we say, "lackluster"
93echo on
Zachary Wareb27f3c32015-09-03 23:43:54 -050094msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
95 /p:Configuration=%conf% /p:Platform=%platf%^
96 /p:IncludeExternals=%IncludeExternals%^
97 /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^
Steve Dower940f6a82015-10-31 12:17:11 -070098 /p:UseTestMarker=%UseTestMarker%^
Zachary Wareb27f3c32015-09-03 23:43:54 -050099 %1 %2 %3 %4 %5 %6 %7 %8 %9
Steve Dower49437492015-07-08 20:18:44 -0700100
101@goto :eof
102
103:Version
104rem Display the current build version information
105msbuild "%dir%python.props" /t:ShowVersionInfo /v:m /nologo %1 %2 %3 %4 %5 %6 %7 %8 %9