Skip to content

Commit 4b162b7

Browse files
committed
chore(ci): update windows script
1 parent f9fde86 commit 4b162b7

File tree

4 files changed

+50
-10
lines changed

4 files changed

+50
-10
lines changed

.github/workflows/build.ps1

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,50 @@ $ErrorActionPreference = "Stop"
22

33
$env:PATH = "C:\php\devel;C:\php\bin;C:\php\deps\bin;$env:PATH"
44

5+
# Toolset
6+
# $installerDir = Join-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio" 'Installer'
7+
# $vswherePath = Join-Path $installerDir 'vswhere.exe'
8+
# if (-not (Test-Path $vswherePath)) {
9+
# if (-not (Test-Path $installerDir)) {
10+
# New-Item -Path $installerDir -ItemType Directory -Force | Out-Null
11+
# }
12+
# $vsWhereUrl = 'https://github.com/microsoft/vswhere/releases/latest/download/vswhere.exe'
13+
# Invoke-WebRequest -Uri $vsWhereUrl -OutFile $vswherePath -UseBasicParsing
14+
# }
15+
# if($null -eq (Get-Command vswhere -ErrorAction SilentlyContinue)) {
16+
# throw "vswhere is not available"
17+
# }
18+
$MSVCDirectory = vswhere -latest -products * -find "VC\Tools\MSVC"
19+
$selectedToolset = $null
20+
$minor = $null
21+
foreach ($toolset in (Get-ChildItem $MSVCDirectory)) {
22+
$toolsetMajorVersion, $toolsetMinorVersion = $toolset.Name.split(".")[0,1]
23+
$major = 14
24+
switch ($env:VS) {
25+
'vs17' { $minorMin = 30; $minorMax = $null; break }
26+
'vs16' { $minorMin = 20; $minorMax = 29; break }
27+
Default { throw "VS version is not available" }
28+
}
29+
$majorVersionCheck = [int]$major -eq [int]$toolsetMajorVersion
30+
$minorLowerBoundCheck = [int]$toolsetMinorVersion -ge [int]$minorMin
31+
$minorUpperBoundCheck = ($null -eq $minorMax) -or ([int]$toolsetMinorVersion -le [int]$minorMax)
32+
if ($majorVersionCheck -and $minorLowerBoundCheck -and $minorUpperBoundCheck) {
33+
if($null -eq $minor -or [int]$toolsetMinorVersion -gt [int]$minor) {
34+
$selectedToolset = $toolset.Name.Trim()
35+
$minor = $toolsetMinorVersion
36+
}
37+
}
38+
}
39+
if (-not $selectedToolset) {
40+
throw "toolset not available"
41+
}
42+
543
$task = New-Item 'task.bat' -Force
644
Add-Content $task 'call phpize 2>&1'
745
Add-Content $task "call configure --with-php-build=C:\php\deps --enable-$env:PHP_EXT --enable-debug-pack 2>&1"
846
Add-Content $task 'nmake /nologo 2>&1'
947
Add-Content $task 'exit %errorlevel%'
10-
& "C:\php\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VS-$env:ARCH.bat" -t $task
48+
& "C:\php\php-sdk-$env:BIN_SDK_VER\phpsdk-starter.bat" -c $env:VS -a $env:ARCH -s $selectedToolset -t $task
1149
if (-not $?) {
1250
throw "building failed with errorlevel $LastExitCode"
1351
}

.github/workflows/install.ps1

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ if (-not (Test-Path "C:\php\bin")) {
7272
Expand-Archive "C:\php\$bname" "C:\php\bin"
7373
}
7474

75-
# # library dependency: "C:\php\deps"
76-
# $bname = "$env:DEP-$env:VS-$env:ARCH.zip"
77-
# if (-not (Test-Path "C:\php\$bname")) {
78-
# echo "Download: https://windows.php.net/downloads/pecl/deps/$bname"
79-
# Invoke-WebRequest "https://windows.php.net/downloads/pecl/deps/$bname" -OutFile "C:\php\$bname"
80-
# Expand-Archive "C:\php\$bname" 'C:\php\deps'
81-
# }
75+
# library dependency: "C:\php\deps"
76+
if ("$env:DEP" -ne "") {
77+
$bname = "$env:DEP-$env:VS-$env:ARCH.zip"
78+
if (-not (Test-Path "C:\php\$bname")) {
79+
echo "Download: https://windows.php.net/downloads/pecl/deps/$bname"
80+
Invoke-WebRequest "https://windows.php.net/downloads/pecl/deps/$bname" -OutFile "C:\php\$bname"
81+
Expand-Archive "C:\php\$bname" "C:\php\deps"
82+
}
83+
}

.github/workflows/test.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $ErrorActionPreference = "Stop"
33
$env:PATH = "C:\php\devel;C:\php\bin;C:\php\deps\bin;$env:PATH"
44

55
$env:TEST_PHP_EXECUTABLE = "C:\php\bin\php.exe"
6-
& $env:TEST_PHP_EXECUTABLE 'run-tests.php' --show-diff tests
6+
& $env:TEST_PHP_EXECUTABLE 'run-tests.php' --color --show-diff tests
77
if (-not $?) {
88
throw "testing failed with errorlevel $LastExitCode"
99
}

.github/workflows/windows.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
env:
99
PHP_EXT: snappy
1010
PHP_EXT_VERSION: ${{ github.event.release.tag_name }}
11-
BIN_SDK_VER: 2.3.0
11+
BIN_SDK_VER: 2.5.0
1212

1313
jobs:
1414
ci:

0 commit comments

Comments
 (0)