@@ -24,6 +24,8 @@ echo. -M Disable parallel build (disabled by default)
2424echo . -v Increased output messages
2525echo . -k Attempt to kill any running Pythons before building (usually done
2626echo . automatically by the pythoncore project)
27+ echo . --pgo Build with Profile-Guided Optimization. This flag
28+ echo . overrides -c and -d
2729echo .
2830echo .Available flags to avoid building certain modules.
2931echo .These flags have no effect if '-e' is not given:
@@ -38,6 +40,8 @@ echo. -p x64 ^| Win32
3840echo . Set the platform (default: Win32)
3941echo . -t Build ^ | Rebuild ^ | Clean ^ | CleanAll
4042echo . Set the target manually
43+ echo . --pgo-job The job to use for PGO training; implies --pgo
44+ echo . (default: " -m test.regrtest --pgo" )
4145exit /b 127
4246
4347:Run
@@ -50,6 +54,12 @@ set dir=%~dp0
5054set parallel =
5155set verbose = /nologo /v:m
5256set kill =
57+ set do_pgo =
58+ set pgo_job = -m test.regrtest --pgo
59+ set on_64_bit = true
60+
61+ rem This may not be 100% accurate, but close enough.
62+ if " %ProgramFiles(x86)% " == " " (set on_64_bit=false)
5363
5464:CheckOpts
5565if " %~1 " == " -h" goto Usage
@@ -62,6 +72,8 @@ if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
6272if " %~1 " == " -M" (set parallel=) & shift & goto CheckOpts
6373if " %~1 " == " -v" (set verbose=/v:n) & shift & goto CheckOpts
6474if " %~1 " == " -k" (set kill=true) & shift & goto CheckOpts
75+ if " %~1 " == " --pgo" (set do_pgo=true) & shift & goto CheckOpts
76+ if " %~1 " == " --pgo-job" (set do_pgo=true) & (set pgo_job=%~2 ) & shift & shift & goto CheckOpts
6577rem These use the actual property names used by MSBuild. We could just let
6678rem them in through the environment, but we specify them on the command line
6779rem anyway for visibility so set defaults after this
@@ -77,15 +89,49 @@ if "%IncludeBsddb%"=="" set IncludeBsddb=true
7789
7890if " %IncludeExternals% " == " true" call " %dir% get_externals.bat"
7991
80- if " %platf% " == " x64" (set vs_platf=x86_amd64)
92+ if " %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+ )
81106
82107rem Setup the environment
83108call " %dir% env.bat" %vs_platf% > nul
84109
85- if " %kill% " == " true" (
86- msbuild /v:m /nologo /target:KillPython " %dir% \pythoncore.vcxproj" /p:Configuration=%conf% /p:Platform=%platf% /p:KillPython=true
110+ if " %kill% " == " true" call :Kill
111+
112+ if " %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
87122)
123+ goto Build
124+
125+ :Kill
126+ echo on
127+ msbuild " %dir% \pythoncore.vcxproj" /t:KillPython %verbose% ^
128+ /p:Configuration=%conf% /p:Platform=%platf% ^
129+ /p:KillPython=true
130+
131+ @ echo off
132+ goto :eof
88133
134+ :Build
89135rem Call on MSBuild to do the work, echo the command.
90136rem Passing %1-9 is not the preferred option, but argument parsing in
91137rem batch is, shall we say, "lackluster"
@@ -96,3 +142,6 @@ msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
96142 /p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter% ^
97143 /p:IncludeBsddb=%IncludeBsddb% ^
98144 %1 %2 %3 %4 %5 %6 %7 %8 %9
145+
146+ @ echo off
147+ goto :eof
0 commit comments