@@ -25,6 +25,9 @@ echo. -M Disable parallel build
2525echo . -v Increased output messages
2626echo . -k Attempt to kill any running Pythons before building (usually done
2727echo . automatically by the pythoncore project)
28+ echo . --pgo Build with Profile-Guided Optimization. This flag
29+ echo . overrides -c and -d
30+ echo . --test-marker Enable the test marker within the build.
2831echo .
2932echo .Available flags to avoid building certain modules.
3033echo .These flags have no effect if '-e' is not given:
@@ -38,7 +41,8 @@ echo. -p x64 ^| Win32
3841echo . Set the platform (default: Win32)
3942echo . -t Build ^ | Rebuild ^ | Clean ^ | CleanAll
4043echo . Set the target manually
41- echo . --test-marker Enable the test marker within the build.
44+ echo . --pgo-job The job to use for PGO training; implies --pgo
45+ echo . (default: " -m test --pgo" )
4246exit /b 127
4347
4448:Run
@@ -51,6 +55,12 @@ set dir=%~dp0
5155set parallel = /m
5256set verbose = /nologo /v:m
5357set kill =
58+ set do_pgo =
59+ set pgo_job = -m test --pgo
60+ set on_64_bit = true
61+
62+ rem This may not be 100% accurate, but close enough.
63+ if " %ProgramFiles(x86)% " == " " (set on_64_bit=false)
5464
5565:CheckOpts
5666if " %~1 " == " -h" goto Usage
@@ -63,6 +73,8 @@ if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
6373if " %~1 " == " -M" (set parallel=) & shift & goto CheckOpts
6474if " %~1 " == " -v" (set verbose=/v:n) & shift & goto CheckOpts
6575if " %~1 " == " -k" (set kill=true) & shift & goto CheckOpts
76+ if " %~1 " == " --pgo" (set do_pgo=true) & shift & goto CheckOpts
77+ if " %~1 " == " --pgo-job" (set do_pgo=true) & (set pgo_job=%~2 ) & shift & shift & goto CheckOpts
6678if " %~1 " == " --test-marker" (set UseTestMarker=true) & shift & goto CheckOpts
6779if " %~1 " == " -V" shift & goto Version
6880rem These use the actual property names used by MSBuild. We could just let
@@ -78,15 +90,49 @@ if "%IncludeTkinter%"=="" set IncludeTkinter=true
7890
7991if " %IncludeExternals% " == " true" call " %dir% get_externals.bat"
8092
81- if " %platf% " == " x64" (set vs_platf=x86_amd64)
93+ if " %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+ )
82107
83108rem Setup the environment
84109call " %dir% env.bat" %vs_platf% > nul
85110
86- if " %kill% " == " true" (
87- msbuild /v:m /nologo /target:KillPython " %dir% \pythoncore.vcxproj" /p:Configuration=%conf% /p:Platform=%platf% /p:KillPython=true
111+ if " %kill% " == " true" call :Kill
112+
113+ if " %do_pgo% " == " true" (
114+ set conf = PGInstrument
115+ call :Build
116+ del /s " %dir% \*.pgc"
117+ del /s " %dir% \..\Lib\*.pyc"
118+ echo on
119+ call " %dir% \..\python.bat" %pgo_job%
120+ @ echo off
121+ call :Kill
122+ set conf = PGUpdate
88123)
124+ goto Build
89125
126+ :Kill
127+ echo on
128+ msbuild " %dir% \pythoncore.vcxproj" /t:KillPython %verbose% ^
129+ /p:Configuration=%conf% /p:Platform=%platf% ^
130+ /p:KillPython=true
131+
132+ @ echo off
133+ goto :eof
134+
135+ :Build
90136rem Call on MSBuild to do the work, echo the command.
91137rem Passing %1-9 is not the preferred option, but argument parsing in
92138rem batch is, shall we say, "lackluster"
@@ -98,7 +144,8 @@ msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
98144 /p:UseTestMarker=%UseTestMarker% ^
99145 %1 %2 %3 %4 %5 %6 %7 %8 %9
100146
101- @ goto :eof
147+ @ echo off
148+ goto :eof
102149
103150:Version
104151rem Display the current build version information
0 commit comments