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.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. -r Target Rebuild instead of Build 18echo. -d Set the configuration to Debug 19echo. -e Build external libraries fetched by get_externals.bat 20echo. Extension modules that depend on external libraries will not attempt 21echo. to build if this flag is not present 22echo. -m Enable parallel build 23echo. -M Disable parallel build (disabled by default) 24echo. -v Increased output messages 25echo. -k Attempt to kill any running Pythons before building (usually done 26echo. automatically by the pythoncore project) 27echo. --pgo Build with Profile-Guided Optimization. This flag 28echo. overrides -c and -d 29echo. 30echo.Available flags to avoid building certain modules. 31echo.These flags have no effect if '-e' is not given: 32echo. --no-ssl Do not attempt to build _ssl 33echo. --no-tkinter Do not attempt to build Tkinter 34echo. --no-bsddb Do not attempt to build _bsddb 35echo. 36echo.Available arguments: 37echo. -c Release ^| Debug ^| PGInstrument ^| PGUpdate 38echo. Set the configuration (default: Release) 39echo. -p x64 ^| Win32 40echo. Set the platform (default: Win32) 41echo. -t Build ^| Rebuild ^| Clean ^| CleanAll 42echo. Set the target manually 43echo. --pgo-job The job to use for PGO training; implies --pgo 44echo. (default: "-m test.regrtest --pgo") 45exit /b 127 46 47:Run 48setlocal 49set platf=Win32 50set vs_platf=x86 51set conf=Release 52set target=Build 53set dir=%~dp0 54set parallel= 55set verbose=/nologo /v:m 56set kill= 57set do_pgo= 58set pgo_job=-m test.regrtest --pgo 59set on_64_bit=true 60 61rem This may not be 100% accurate, but close enough. 62if "%ProgramFiles(x86)%"=="" (set on_64_bit=false) 63 64:CheckOpts 65if "%~1"=="-h" goto Usage 66if "%~1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts 67if "%~1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts 68if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts 69if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts 70if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts 71if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts 72if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts 73if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts 74if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts 75if "%~1"=="--pgo" (set do_pgo=true) & shift & goto CheckOpts 76if "%~1"=="--pgo-job" (set do_pgo=true) & (set pgo_job=%~2) & shift & shift & goto CheckOpts 77rem These use the actual property names used by MSBuild. We could just let 78rem them in through the environment, but we specify them on the command line 79rem anyway for visibility so set defaults after this 80if "%~1"=="-e" (set IncludeExternals=true) & shift & goto CheckOpts 81if "%~1"=="--no-ssl" (set IncludeSSL=false) & shift & goto CheckOpts 82if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts 83if "%~1"=="--no-bsddb" (set IncludeBsddb=false) & shift & goto CheckOpts 84 85if "%IncludeExternals%"=="" set IncludeExternals=false 86if "%IncludeSSL%"=="" set IncludeSSL=true 87if "%IncludeTkinter%"=="" set IncludeTkinter=true 88if "%IncludeBsddb%"=="" set IncludeBsddb=true 89 90if "%IncludeExternals%"=="true" call "%dir%get_externals.bat" 91 92if "%platf%"=="x64" ( 93 if "%on_64_bit%"=="true" ( 94 rem This ought to always be correct these days... 95 set vs_platf=amd64 96 ) else ( 97 if "%do_pgo%"=="true" ( 98 echo.ERROR: Cannot cross-compile with PGO 99 echo. 32bit operating system detected, if this is incorrect, 100 echo. make sure the ProgramFiles(x86^) environment variable is set 101 exit /b 1 102 ) 103 set vs_platf=x86_amd64 104 ) 105) 106 107rem Setup the environment 108call "%dir%env.bat" %vs_platf% >nul 109 110if "%kill%"=="true" call :Kill 111 112if "%do_pgo%"=="true" ( 113 set conf=PGInstrument 114 call :Build 115 del /s "%dir%\*.pgc" 116 del /s "%dir%\..\Lib\*.pyc" 117 echo on 118 call "%dir%\..\python.bat" %pgo_job% 119 @echo off 120 call :Kill 121 set conf=PGUpdate 122) 123goto Build 124 125:Kill 126echo on 127msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^ 128 /p:Configuration=%conf% /p:Platform=%platf%^ 129 /p:KillPython=true 130 131@echo off 132goto :eof 133 134:Build 135rem Call on MSBuild to do the work, echo the command. 136rem Passing %1-9 is not the preferred option, but argument parsing in 137rem batch is, shall we say, "lackluster" 138echo on 139msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^ 140 /p:Configuration=%conf% /p:Platform=%platf%^ 141 /p:IncludeExternals=%IncludeExternals%^ 142 /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^ 143 /p:IncludeBsddb=%IncludeBsddb%^ 144 %1 %2 %3 %4 %5 %6 %7 %8 %9 145 146@echo off 147goto :eof 148