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