Skip to content

Commit c4a2a37

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

File tree

4 files changed

+94
-10
lines changed

4 files changed

+94
-10
lines changed

.github/workflows/build.ps1

Lines changed: 42 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
}
@@ -25,5 +63,8 @@ Copy-Item "$dname\php_$env:PHP_EXT.dll" "php_$env:PHP_EXT.dll"
2563

2664
$ini = New-Item "C:\php\bin\php.ini" -Force
2765
Add-Content $ini "extension_dir=C:\php\bin\ext"
66+
if (Test-Path 'C:\php\bin\ext\php_apcu.dll') {
67+
Add-Content $ini 'extension=php_apcu.dll'
68+
}
2869
Add-Content $ini "extension=php_openssl.dll"
2970
Add-Content $ini "extension=php_$env:PHP_EXT.dll"

.github/workflows/install.ps1

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,53 @@ 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+
}
84+
85+
# PECL apuc
86+
if (('' -ne $env:PECL_APCU) -and ('8.2' -ne $env:PHP_VER) -and ('8.3' -ne $env:PHP_VER)) {
87+
$apcu_version = '5.1.21'
88+
89+
$ts_part = 'ts'
90+
if ('nts' -eq $env:TS) {
91+
$ts_part = 'nts'
92+
}
93+
94+
$bname = "php_apcu-$apcu_version-$env:PHP_VER-$ts_part-$env:VS-$env:ARCH.zip"
95+
96+
echo "Download: https://windows.php.net/downloads/pecl/releases/apcu/$apcu_version/$bname"
97+
Invoke-WebRequest "https://windows.php.net/downloads/pecl/releases/apcu/$apcu_version/$bname" -OutFile "C:\php\$bname"
98+
Expand-Archive "C:\php\$bname" 'C:\php\bin\ext'
99+
100+
$bname = "v$apcu_version.zip"
101+
102+
echo "Download: https://github.com/krakjoe/apcu/archive/refs/tags/$bname"
103+
Invoke-WebRequest "https://github.com/krakjoe/apcu/archive/refs/tags/$bname" -OutFile "C:\php\$bname"
104+
Expand-Archive "C:\php\$bname" 'C:\php'
105+
106+
if (-not (Test-Path 'C:\php\devel\include\ext\apcu')) {
107+
[void](New-Item 'C:\php\devel\include\ext\apcu' -ItemType 'directory')
108+
}
109+
110+
Move-Item "C:\php\apcu-$apcu_version\php_apc.h" 'C:\php\devel\include\ext\apcu\php_apc.h'
111+
Move-Item "C:\php\apcu-$apcu_version\apc.h" 'C:\php\devel\include\ext\apcu\apc.h'
112+
Move-Item "C:\php\apcu-$apcu_version\apc_api.h" 'C:\php\devel\include\ext\apcu\apc_api.h'
113+
Move-Item "C:\php\apcu-$apcu_version\apc_cache.h" 'C:\php\devel\include\ext\apcu\apc_cache.h'
114+
Move-Item "C:\php\apcu-$apcu_version\apc_globals.h" 'C:\php\devel\include\ext\apcu\apc_globals.h'
115+
Move-Item "C:\php\apcu-$apcu_version\apc_iterator.h" 'C:\php\devel\include\ext\apcu\apc_iterator.h'
116+
Move-Item "C:\php\apcu-$apcu_version\apc_lock.h" 'C:\php\devel\include\ext\apcu\apc_lock.h'
117+
Move-Item "C:\php\apcu-$apcu_version\apc_mutex.h" 'C:\php\devel\include\ext\apcu\apc_mutex.h'
118+
Move-Item "C:\php\apcu-$apcu_version\apc_sma.h" 'C:\php\devel\include\ext\apcu\apc_sma.h'
119+
Move-Item "C:\php\apcu-$apcu_version\apc_serializer.h" 'C:\php\devel\include\ext\apcu\apc_serializer.h'
120+
Move-Item "C:\php\apcu-$apcu_version\apc_stack.h" 'C:\php\devel\include\ext\apcu\apc_stack.h'
121+
Move-Item "C:\php\apcu-$apcu_version\apc_windows_srwlock_kernel.h" 'C:\php\devel\include\ext\apcu\apc_windows_srwlock_kernel.h'
122+
Move-Item "C:\php\apcu-$apcu_version\apc_arginfo.h" 'C:\php\devel\include\ext\apcu\apc_arginfo.h'
123+
Move-Item "C:\php\apcu-$apcu_version\php_apc_legacy_arginfo.h" 'C:\php\devel\include\ext\apcu\php_apc_legacy_arginfo.h'
124+
}

.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)