Skip to content

Commit 2156d96

Browse files
authored
bpo-42336: Improve PCbuild batch files (pythonGH-23275)
1 parent 07f2ade commit 2156d96

File tree

9 files changed

+60
-24
lines changed

9 files changed

+60
-24
lines changed

.azure-pipelines/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
matrix:
105105
win32:
106106
arch: win32
107-
buildOpt:
107+
buildOpt: '-p Win32'
108108
testRunTitle: '$(Build.SourceBranchName)-win32'
109109
testRunPlatform: win32
110110
win64:

.azure-pipelines/pr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
matrix:
105105
win32:
106106
arch: win32
107-
buildOpt:
107+
buildOpt: '-p Win32'
108108
testRunTitle: '$(System.PullRequest.TargetBranch)-win32'
109109
testRunPlatform: win32
110110
win64:

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- name: Display build info
6060
run: .\python.bat -m test.pythoninfo
6161
- name: Tests
62-
run: .\PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
62+
run: .\PCbuild\rt.bat -p Win32 -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
6363

6464
build_win_amd64:
6565
name: 'Windows (x64)'
@@ -73,7 +73,7 @@ jobs:
7373
- name: Display build info
7474
run: .\python.bat -m test.pythoninfo
7575
- name: Tests
76-
run: .\PCbuild\rt.bat -x64 -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
76+
run: .\PCbuild\rt.bat -p x64 -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
7777

7878
build_macos:
7979
name: 'macOS'

PCbuild/build.bat

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ echo.Available arguments:
4646
echo. -c Release ^| Debug ^| PGInstrument ^| PGUpdate
4747
echo. Set the configuration (default: Release)
4848
echo. -p x64 ^| Win32 ^| ARM ^| ARM64
49-
echo. Set the platform (default: Win32)
49+
echo. Set the platform (default: x64)
5050
echo. -t Build ^| Rebuild ^| Clean ^| CleanAll
5151
echo. Set the target manually
5252
echo. --pgo-job The job to use for PGO training; implies --pgo
@@ -55,7 +55,7 @@ exit /b 127
5555

5656
:Run
5757
setlocal
58-
set platf=Win32
58+
set platf=x64
5959
set conf=Release
6060
set target=Build
6161
set dir=%~dp0

PCbuild/env.bat

+16-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,19 @@ rem 'v110', 'v120' or 'v140') to the build script.
99

1010
echo Build environments: x86, amd64, x86_amd64
1111
echo.
12-
set VSTOOLS=%VS140COMNTOOLS%
13-
if "%VSTOOLS%"=="" set VSTOOLS=%VS120COMNTOOLS%
14-
if "%VSTOOLS%"=="" set VSTOOLS=%VS110COMNTOOLS%
15-
if "%VSTOOLS%"=="" set VSTOOLS=%VS100COMNTOOLS%
16-
call "%VSTOOLS%..\..\VC\vcvarsall.bat" %*
12+
set _ARGS=%*
13+
if NOT DEFINED _ARGS set _ARGS=amd64
14+
15+
if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto :skip_vswhere
16+
set VSTOOLS=
17+
for /F "tokens=*" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64') DO @(set VSTOOLS=%%i\VC\Auxiliary\Build\vcvarsall.bat)
18+
if not defined VSTOOLS goto :skip_vswhere
19+
call "%VSTOOLS%" %_ARGS%
20+
exit /B 0
21+
22+
:skip_vswhere
23+
if not defined VSTOOLS set VSTOOLS=%VS140COMNTOOLS%
24+
if not defined VSTOOLS set VSTOOLS=%VS120COMNTOOLS%
25+
if not defined VSTOOLS set VSTOOLS=%VS110COMNTOOLS%
26+
if not defined VSTOOLS set VSTOOLS=%VS100COMNTOOLS%
27+
call "%VSTOOLS%..\..\VC\vcvarsall.bat" %_ARGS%

PCbuild/env.ps1

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$pcbuild = $script:MyInvocation.MyCommand.Path | Split-Path -parent;
2+
& cmd /K "$pcbuild\env.bat" $args

PCbuild/idle.bat

+15-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,24 @@ rem Usage: idle [-d]
44
rem -d Run Debug build (python_d.exe). Else release build.
55

66
setlocal
7-
set exe=win32\python
7+
set PCBUILD=%~dp0
8+
set exedir=%PCBUILD%\amd64
9+
set exe=python
810
PATH %PATH%;..\externals\tcltk\bin
911

10-
if "%1"=="-d" (set exe=%exe%_d) & shift
12+
:CheckOpts
13+
if "%1"=="-d" (set exe=%exe%_d) & shift & goto :CheckOpts
14+
if "%1"=="-p" (call :SetExeDir %2) & shift & shift & goto :CheckOpts
1115

12-
set cmd=%exe% ../Lib/idlelib/idle.py %1 %2 %3 %4 %5 %6 %7 %8 %9
16+
set cmd=%exedir%\%exe% %PCBUILD%\..\Lib\idlelib\idle.py %1 %2 %3 %4 %5 %6 %7 %8 %9
1317

1418
echo on
1519
%cmd%
20+
exit /B %LASTERRORCODE%
21+
22+
:SetExeDir
23+
if /I %1 EQU Win32 (set exedir=%PCBUILD%\win32)
24+
if /I %1 EQU x64 (set exedir=%PCBUILD%\amd64)
25+
if /I %1 EQU ARM (set exedir=%PCBUILD%\arm32)
26+
if /I %1 EQU ARM64 (set exedir=%PCBUILD%\arm64)
27+
exit /B 0

PCbuild/prepare_libffi.bat

+6-7
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ echo Based on https://github.com/libffi/libffi/blob/master/.appveyor.yml
2222
echo.
2323
echo.
2424
echo.Available flags:
25-
echo. -x64 build for x64
26-
echo. -x86 build for x86
27-
echo. -arm32 build for arm32
28-
echo. -arm64 build for arm64
25+
echo. -x64 enable x64 build
26+
echo. -x86 enable x86 build
27+
echo. -arm32 enable arm32 build
28+
echo. -arm64 enable arm64 build
2929
echo. -? this help
3030
echo. --install-cygwin install cygwin to c:\cygwin
3131
exit /b 127
@@ -44,6 +44,7 @@ set INSTALL_CYGWIN=
4444
if "%1"=="" goto :CheckOptsDone
4545
if /I "%1"=="-x64" (set BUILD_X64=1) & shift & goto :CheckOpts
4646
if /I "%1"=="-x86" (set BUILD_X86=1) & shift & goto :CheckOpts
47+
if /I "%1"=="-win32" (set BUILD_X86=1) & shift & goto :CheckOpts
4748
if /I "%1"=="-arm32" (set BUILD_ARM32=1) & shift & goto :CheckOpts
4849
if /I "%1"=="-arm64" (set BUILD_ARM64=1) & shift & goto :CheckOpts
4950
if /I "%1"=="-pdb" (set BUILD_PDB=-g) & shift & goto :CheckOpts
@@ -67,9 +68,7 @@ setlocal
6768
if NOT DEFINED SH if exist c:\cygwin\bin\sh.exe set SH=c:\cygwin\bin\sh.exe
6869

6970
if NOT DEFINED VCVARSALL (
70-
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" (
71-
set VCVARSALL="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
72-
)
71+
for /F "tokens=*" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64') DO @(set VCVARSALL="%%i\VC\Auxiliary\Build\vcvarsall.bat")
7372
)
7473
if ^%VCVARSALL:~0,1% NEQ ^" SET VCVARSALL="%VCVARSALL%"
7574

PCbuild/rt.bat

+15-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ rem -O Run python.exe or python_d.exe (see -d) with -O.
66
rem -q "quick" -- normally the tests are run twice, the first time
77
rem after deleting all the .pyc files reachable from Lib/.
88
rem -q runs the tests just once, and without deleting .pyc files.
9-
rem -x64 Run the 64-bit build of python (or python_d if -d was specified)
10-
rem When omitted, uses %PREFIX% if set or the 32-bit build
9+
rem -p <Win32|x64|ARM|ARM64> or -win32, -x64, -arm32, -arm64
10+
rem Run the specified architecture of python (or python_d if -d
11+
rem was specified). If omitted, uses %PREFIX% if set or 64-bit.
1112
rem All leading instances of these switches are shifted off, and
1213
rem whatever remains (up to 9 arguments) is passed to regrtest.py.
1314
rem For example,
@@ -38,12 +39,14 @@ set exe=
3839
if "%1"=="-O" (set dashO=-O) & shift & goto CheckOpts
3940
if "%1"=="-q" (set qmode=yes) & shift & goto CheckOpts
4041
if "%1"=="-d" (set suffix=_d) & shift & goto CheckOpts
42+
if "%1"=="-win32" (set prefix=%pcbuild%win32) & shift & goto CheckOpts
4143
if "%1"=="-x64" (set prefix=%pcbuild%amd64) & shift & goto CheckOpts
4244
if "%1"=="-arm64" (set prefix=%pcbuild%arm64) & shift & goto CheckOpts
4345
if "%1"=="-arm32" (set prefix=%pcbuild%arm32) & shift & goto CheckOpts
46+
if "%1"=="-p" (call :SetPlatform %~2) & shift & shift & goto CheckOpts
4447
if NOT "%1"=="" (set regrtestargs=%regrtestargs% %1) & shift & goto CheckOpts
4548

46-
if not defined prefix set prefix=%pcbuild%win32
49+
if not defined prefix set prefix=%pcbuild%amd64
4750
set exe=%prefix%\python%suffix%.exe
4851
set cmd="%exe%" %dashO% -u -Wd -E -bb -m test %regrtestargs%
4952
if defined qmode goto Qmode
@@ -60,6 +63,15 @@ echo on
6063

6164
echo About to run again without deleting .pyc first:
6265
pause
66+
goto Qmode
67+
68+
:SetPlatform
69+
if /I %1 EQU Win32 (set prefix=%pcbuild%win32) & exit /B 0
70+
if /I %1 EQU x64 (set prefix=%pcbuild%amd64) & exit /B 0
71+
if /I %1 EQU ARM64 (set prefix=%pcbuild%arm64) & exit /B 0
72+
if /I %1 EQU ARM (set prefix=%pcbuild%arm32) & exit /B 0
73+
echo Invalid platform "%1"
74+
exit /B 1
6375

6476
:Qmode
6577
echo on

0 commit comments

Comments
 (0)