| 1 |
@echo off |
| 2 |
goto Run |
| 3 |
:Usage |
| 4 |
echo.%~nx0 [flags and arguments] [quoted MSBuild options] |
| 5 |
echo. |
| 6 |
echo.Build CPython from the command line. Requires the appropriate |
| 7 |
echo.version(s) of Microsoft Visual Studio to be installed (see readme.txt). |
| 8 |
echo. |
| 9 |
echo.After the flags recognized by this script, up to 9 arguments to be passed |
| 10 |
echo.directly to MSBuild may be passed. If the argument contains an '=', the |
| 11 |
echo.entire argument must be quoted (e.g. `%~nx0 "/p:PlatformToolset=v100"`). |
| 12 |
echo.Alternatively you can put extra flags for MSBuild in a file named |
| 13 |
echo.`msbuild.rsp` in the `PCbuild` directory, one flag per line. This file |
| 14 |
echo.will be picked automatically by MSBuild. Flags put in this file does not |
| 15 |
echo.need to be quoted. You can still use environment variables inside the |
| 16 |
echo.response file. |
| 17 |
echo. |
| 18 |
echo.Available flags: |
| 19 |
echo. -h Display this help message |
| 20 |
echo. -r Target Rebuild instead of Build |
| 21 |
echo. -d Set the configuration to Debug |
| 22 |
echo. -e Build external libraries fetched by get_externals.bat |
| 23 |
echo. Extension modules that depend on external libraries will not attempt |
| 24 |
echo. to build if this flag is not present |
| 25 |
echo. -m Enable parallel build |
| 26 |
echo. -M Disable parallel build (disabled by default) |
| 27 |
echo. -v Increased output messages |
| 28 |
echo. -k Attempt to kill any running Pythons before building (usually done |
| 29 |
echo. automatically by the pythoncore project) |
| 30 |
echo. --pgo Build with Profile-Guided Optimization. This flag |
| 31 |
echo. overrides -c and -d |
| 32 |
echo. |
| 33 |
echo.Available flags to avoid building certain modules. |
| 34 |
echo.These flags have no effect if '-e' is not given: |
| 35 |
echo. --no-ssl Do not attempt to build _ssl |
| 36 |
echo. --no-tkinter Do not attempt to build Tkinter |
| 37 |
echo. --no-bsddb Do not attempt to build _bsddb |
| 38 |
echo. |
| 39 |
echo.Available arguments: |
| 40 |
echo. -c Release ^| Debug ^| PGInstrument ^| PGUpdate |
| 41 |
echo. Set the configuration (default: Release) |
| 42 |
echo. -p x64 ^| Win32 |
| 43 |
echo. Set the platform (default: Win32) |
| 44 |
echo. -t Build ^| Rebuild ^| Clean ^| CleanAll |
| 45 |
echo. Set the target manually |
| 46 |
echo. --pgo-job The job to use for PGO training; implies --pgo |
| 47 |
echo. (default: "-m test.regrtest --pgo") |
| 48 |
exit /b 127 |
| 49 |
|
| 50 |
:Run |
| 51 |
setlocal |
| 52 |
set platf=Win32 |
| 53 |
set conf=Release |
| 54 |
set target=Build |
| 55 |
set dir=%~dp0 |
| 56 |
set parallel= |
| 57 |
set verbose=/nologo /v:m |
| 58 |
set kill= |
| 59 |
set do_pgo= |
| 60 |
set pgo_job=-m test.regrtest --pgo |
| 61 |
|
| 62 |
:CheckOpts |
| 63 |
if "%~1"=="-h" goto Usage |
| 64 |
if "%~1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts |
| 65 |
if "%~1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts |
| 66 |
if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts |
| 67 |
if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts |
| 68 |
if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts |
| 69 |
if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts |
| 70 |
if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts |
| 71 |
if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts |
| 72 |
if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts |
| 73 |
if "%~1"=="--pgo" (set do_pgo=true) & shift & goto CheckOpts |
| 74 |
if "%~1"=="--pgo-job" (set do_pgo=true) & (set pgo_job=%~2) & shift & shift & goto CheckOpts |
| 75 |
rem These use the actual property names used by MSBuild. We could just let |
| 76 |
rem them in through the environment, but we specify them on the command line |
| 77 |
rem anyway for visibility so set defaults after this |
| 78 |
if "%~1"=="-e" (set IncludeExternals=true) & shift & goto CheckOpts |
| 79 |
if "%~1"=="--no-ssl" (set IncludeSSL=false) & shift & goto CheckOpts |
| 80 |
if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts |
| 81 |
if "%~1"=="--no-bsddb" (set IncludeBsddb=false) & shift & goto CheckOpts |
| 82 |
|
| 83 |
if "%IncludeExternals%"=="" set IncludeExternals=false |
| 84 |
if "%IncludeSSL%"=="" set IncludeSSL=true |
| 85 |
if "%IncludeTkinter%"=="" set IncludeTkinter=true |
| 86 |
if "%IncludeBsddb%"=="" set IncludeBsddb=true |
| 87 |
|
| 88 |
if "%IncludeExternals%"=="true" call "%dir%get_externals.bat" |
| 89 |
|
| 90 |
if "%do_pgo%" EQU "true" if "%platf%" EQU "x64" ( |
| 91 |
if "%PROCESSOR_ARCHITEW6432%" NEQ "AMD64" if "%PROCESSOR_ARCHITECTURE%" NEQ "AMD64" ( |
| 92 |
echo.ERROR: Cannot cross-compile with PGO |
| 93 |
echo. 32bit operating system detected. Ensure your PROCESSOR_ARCHITECTURE |
| 94 |
echo. and PROCESSOR_ARCHITEW6432 environment variables are correct. |
| 95 |
exit /b 1 |
| 96 |
) |
| 97 |
) |
| 98 |
|
| 99 |
if "%GIT%" EQU "" set GIT=git |
| 100 |
if exist "%GIT%" set GITProperty=/p:GIT="%GIT%" |
| 101 |
|
| 102 |
rem Setup the environment |
| 103 |
call "%dir%find_msbuild.bat" %MSBUILD% |
| 104 |
if ERRORLEVEL 1 (call "%dir%env.bat" && set MSBUILD=msbuild) |
| 105 |
|
| 106 |
if "%kill%"=="true" call :Kill |
| 107 |
|
| 108 |
if "%do_pgo%"=="true" ( |
| 109 |
set conf=PGInstrument |
| 110 |
call :Build %1 %2 %3 %4 %5 %6 %7 %8 %9 |
| 111 |
del /s "%dir%\*.pgc" |
| 112 |
del /s "%dir%\..\Lib\*.pyc" |
| 113 |
echo on |
| 114 |
call "%dir%\..\python.bat" %pgo_job% |
| 115 |
@echo off |
| 116 |
call :Kill |
| 117 |
set conf=PGUpdate |
| 118 |
set target=Build |
| 119 |
) |
| 120 |
goto Build |
| 121 |
|
| 122 |
:Kill |
| 123 |
echo on |
| 124 |
%MSBUILD% "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^ |
| 125 |
/p:Configuration=%conf% /p:Platform=%platf%^ |
| 126 |
/p:KillPython=true |
| 127 |
|
| 128 |
@echo off |
| 129 |
goto :eof |
| 130 |
|
| 131 |
:Build |
| 132 |
rem Call on MSBuild to do the work, echo the command. |
| 133 |
rem Passing %1-9 is not the preferred option, but argument parsing in |
| 134 |
rem batch is, shall we say, "lackluster" |
| 135 |
echo on |
| 136 |
%MSBUILD% "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^ |
| 137 |
/p:Configuration=%conf% /p:Platform=%platf%^ |
| 138 |
/p:IncludeExternals=%IncludeExternals%^ |
| 139 |
/p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^ |
| 140 |
/p:IncludeBsddb=%IncludeBsddb% %GITProperty%^ |
| 141 |
%1 %2 %3 %4 %5 %6 %7 %8 %9 |
| 142 |
|
| 143 |
@echo off |
| 144 |
goto :eof |