blob: 6ca628b1010963f492575d80e708518fa04a08fa [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
21echo. -m Enable parallel build (enabled by default)
22echo. -M Disable parallel build
23echo. -v Increased output messages
24echo. -k Attempt to kill any running Pythons before building (usually done
25echo. automatically by the pythoncore project)
26echo.
27echo.Available arguments:
28echo. -c Release ^| Debug ^| PGInstrument ^| PGUpdate
29echo. Set the configuration (default: Release)
30echo. -p x64 ^| Win32
31echo. Set the platform (default: Win32)
32echo. -t Build ^| Rebuild ^| Clean ^| CleanAll
33echo. Set the target manually
34exit /b 127
Zachary Ware4c9c8482015-04-13 11:59:54 -050035
Zachary Ware67323432015-09-02 13:21:19 -050036:Run
Zachary Ware4c9c8482015-04-13 11:59:54 -050037setlocal
38set platf=Win32
Zachary Ware774ac372015-04-13 12:11:40 -050039set vs_platf=x86
Zachary Ware4c9c8482015-04-13 11:59:54 -050040set conf=Release
Zachary Ware774ac372015-04-13 12:11:40 -050041set target=Build
Zachary Ware4c9c8482015-04-13 11:59:54 -050042set dir=%~dp0
Zachary Ware774ac372015-04-13 12:11:40 -050043set parallel=/m
44set verbose=/nologo /v:m
Zachary Ware6250df82015-06-09 23:16:52 -050045set kill=
Zachary Ware4c9c8482015-04-13 11:59:54 -050046
47:CheckOpts
Zachary Ware67323432015-09-02 13:21:19 -050048if "%~1"=="-h" goto Usage
Steve Dowere1f68052015-07-20 21:34:45 -070049if "%~1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts
50if "%~1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts
51if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts
52if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts
53if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts
54if "%~1"=="-e" call "%dir%get_externals.bat" & shift & goto CheckOpts
55if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
56if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts
57if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts
58if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts
59if "%~1"=="-V" shift & goto Version
Zachary Ware4c9c8482015-04-13 11:59:54 -050060
Steve Dowere1f68052015-07-20 21:34:45 -070061if "%platf%"=="x64" (set vs_platf=x86_amd64)
Zachary Ware774ac372015-04-13 12:11:40 -050062
63rem Setup the environment
64call "%dir%env.bat" %vs_platf% >nul
65
Steve Dowere1f68052015-07-20 21:34:45 -070066if "%kill%"=="true" (
Zachary Ware67323432015-09-02 13:21:19 -050067 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 -050068)
69
Zachary Ware774ac372015-04-13 12:11:40 -050070rem Call on MSBuild to do the work, echo the command.
71rem Passing %1-9 is not the preferred option, but argument parsing in
72rem batch is, shall we say, "lackluster"
73echo on
74msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose% /p:Configuration=%conf% /p:Platform=%platf% %1 %2 %3 %4 %5 %6 %7 %8 %9
Steve Dower49437492015-07-08 20:18:44 -070075
76@goto :eof
77
78:Version
79rem Display the current build version information
80msbuild "%dir%python.props" /t:ShowVersionInfo /v:m /nologo %1 %2 %3 %4 %5 %6 %7 %8 %9