echo. -v Increased output messages\r
echo. -k Attempt to kill any running Pythons before building (usually done\r
echo. automatically by the pythoncore project)\r
+echo. --pgo Build with Profile-Guided Optimization. This flag\r
+echo. overrides -c and -d\r
echo.\r
echo.Available flags to avoid building certain modules.\r
echo.These flags have no effect if '-e' is not given:\r
echo. Set the platform (default: Win32)\r
echo. -t Build ^| Rebuild ^| Clean ^| CleanAll\r
echo. Set the target manually\r
+echo. --pgo-job The job to use for PGO training; implies --pgo\r
+echo. (default: "-m test.regrtest --pgo")\r
exit /b 127\r
\r
:Run\r
set parallel=\r
set verbose=/nologo /v:m\r
set kill=\r
+set do_pgo=\r
+set pgo_job=-m test.regrtest --pgo\r
+set on_64_bit=true\r
+\r
+rem This may not be 100% accurate, but close enough.\r
+if "%ProgramFiles(x86)%"=="" (set on_64_bit=false)\r
\r
:CheckOpts\r
if "%~1"=="-h" goto Usage\r
if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts\r
if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts\r
if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts\r
+if "%~1"=="--pgo" (set do_pgo=true) & shift & goto CheckOpts\r
+if "%~1"=="--pgo-job" (set do_pgo=true) & (set pgo_job=%~2) & shift & shift & goto CheckOpts\r
rem These use the actual property names used by MSBuild. We could just let\r
rem them in through the environment, but we specify them on the command line\r
rem anyway for visibility so set defaults after this\r
\r
if "%IncludeExternals%"=="true" call "%dir%get_externals.bat"\r
\r
-if "%platf%"=="x64" (set vs_platf=x86_amd64)\r
+if "%platf%"=="x64" (\r
+ if "%on_64_bit%"=="true" (\r
+ rem This ought to always be correct these days...\r
+ set vs_platf=amd64\r
+ ) else (\r
+ if "%do_pgo%"=="true" (\r
+ echo.ERROR: Cannot cross-compile with PGO\r
+ echo. 32bit operating system detected, if this is incorrect,\r
+ echo. make sure the ProgramFiles(x86^) environment variable is set\r
+ exit /b 1\r
+ )\r
+ set vs_platf=x86_amd64\r
+ )\r
+)\r
\r
rem Setup the environment\r
call "%dir%env.bat" %vs_platf% >nul\r
\r
-if "%kill%"=="true" (\r
- msbuild /v:m /nologo /target:KillPython "%dir%\pythoncore.vcxproj" /p:Configuration=%conf% /p:Platform=%platf% /p:KillPython=true\r
+if "%kill%"=="true" call :Kill\r
+\r
+if "%do_pgo%"=="true" (\r
+ set conf=PGInstrument\r
+ call :Build\r
+ del /s "%dir%\*.pgc"\r
+ del /s "%dir%\..\Lib\*.pyc"\r
+ echo on\r
+ call "%dir%\..\python.bat" %pgo_job%\r
+ @echo off\r
+ call :Kill\r
+ set conf=PGUpdate\r
)\r
+goto Build\r
+\r
+:Kill\r
+echo on\r
+msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^\r
+ /p:Configuration=%conf% /p:Platform=%platf%^\r
+ /p:KillPython=true\r
+\r
+@echo off\r
+goto :eof\r
\r
+:Build\r
rem Call on MSBuild to do the work, echo the command.\r
rem Passing %1-9 is not the preferred option, but argument parsing in\r
rem batch is, shall we say, "lackluster"\r
/p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^\r
/p:IncludeBsddb=%IncludeBsddb%^\r
%1 %2 %3 %4 %5 %6 %7 %8 %9\r
+\r
+@echo off\r
+goto :eof\r
@echo off\r
-rem A batch program to build PGO (Profile guided optimization) by first\r
-rem building instrumented binaries, then running the testsuite, and\r
-rem finally building the optimized code.\r
-rem Note, after the first instrumented run, one can just keep on\r
-rem building the PGUpdate configuration while developing.\r
+echo.DeprecationWarning:\r
+echo. This script is deprecated, use `build.bat --pgo` instead.\r
+echo.\r
\r
-setlocal\r
-set platf=Win32\r
-set parallel=/m\r
-set dir=%~dp0\r
-\r
-rem use the performance testsuite. This is quick and simple\r
-set job1="%dir%..\tools\pybench\pybench.py" -n 1 -C 1 --with-gc\r
-set path1="%dir%..\tools\pybench"\r
-\r
-rem or the whole testsuite for more thorough testing\r
-set job2="%dir%..\lib\test\regrtest.py"\r
-set path2="%dir%..\lib"\r
-\r
-set job=%job1%\r
-set clrpath=%path1%\r
-\r
-:CheckOpts\r
-if "%1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts\r
-if "%1"=="-2" (set job=%job2%) & (set clrpath=%path2%) & shift & goto CheckOpts\r
-if "%1"=="-M" (set parallel=) & shift & goto CheckOpts\r
-\r
-\r
-rem We cannot cross compile PGO builds, as the optimization needs to be run natively\r
-set vs_platf=x86\r
-set PGO=%dir%win32-pgo\r
-\r
-if "%platf%"=="x64" (set vs_platf=amd64) & (set PGO=%dir%amd64-pgo)\r
-rem Setup the environment\r
-call "%dir%env.bat" %vs_platf%\r
-\r
-\r
-rem build the instrumented version\r
-msbuild "%dir%pcbuild.proj" %parallel% /t:Build /p:Configuration=PGInstrument /p:Platform=%platf% %1 %2 %3 %4 %5 %6 %7 %8 %9\r
-\r
-rem remove .pyc files, .pgc files and execute the job\r
-"%PGO%\python.exe" "%dir%rmpyc.py" %clrpath%\r
-del "%PGO%\*.pgc"\r
-"%PGO%\python.exe" %job%\r
-\r
-rem build optimized version\r
-msbuild "%dir%pcbuild.proj" %parallel% /t:Build /p:Configuration=PGUpdate /p:Platform=%platf% %1 %2 %3 %4 %5 %6 %7 %8 %9\r
+call "%~dp0build.bat" --pgo %*\r