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