@@ -25,6 +25,9 @@ echo. -M Disable parallel build
25
25
echo . -v Increased output messages
26
26
echo . -k Attempt to kill any running Pythons before building (usually done
27
27
echo . 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.
28
31
echo .
29
32
echo .Available flags to avoid building certain modules.
30
33
echo .These flags have no effect if '-e' is not given:
@@ -38,7 +41,8 @@ echo. -p x64 ^| Win32
38
41
echo . Set the platform (default: Win32)
39
42
echo . -t Build ^ | Rebuild ^ | Clean ^ | CleanAll
40
43
echo . 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" )
42
46
exit /b 127
43
47
44
48
:Run
@@ -51,6 +55,12 @@ set dir=%~dp0
51
55
set parallel = /m
52
56
set verbose = /nologo /v:m
53
57
set 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)
54
64
55
65
:CheckOpts
56
66
if " %~1 " == " -h" goto Usage
@@ -63,6 +73,8 @@ if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
63
73
if " %~1 " == " -M" (set parallel=) & shift & goto CheckOpts
64
74
if " %~1 " == " -v" (set verbose=/v:n) & shift & goto CheckOpts
65
75
if " %~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
66
78
if " %~1 " == " --test-marker" (set UseTestMarker=true) & shift & goto CheckOpts
67
79
if " %~1 " == " -V" shift & goto Version
68
80
rem These use the actual property names used by MSBuild. We could just let
@@ -78,15 +90,49 @@ if "%IncludeTkinter%"=="" set IncludeTkinter=true
78
90
79
91
if " %IncludeExternals% " == " true" call " %dir% get_externals.bat"
80
92
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
+ )
82
107
83
108
rem Setup the environment
84
109
call " %dir% env.bat" %vs_platf% > nul
85
110
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
88
123
)
124
+ goto Build
89
125
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
90
136
rem Call on MSBuild to do the work, echo the command.
91
137
rem Passing %1-9 is not the preferred option, but argument parsing in
92
138
rem batch is, shall we say, "lackluster"
@@ -98,7 +144,8 @@ msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
98
144
/p:UseTestMarker=%UseTestMarker% ^
99
145
%1 %2 %3 %4 %5 %6 %7 %8 %9
100
146
101
- @ goto :eof
147
+ @ echo off
148
+ goto :eof
102
149
103
150
:Version
104
151
rem Display the current build version information
0 commit comments