Skip to content

Commit 273e8b7

Browse files
committed
Switch away from php-sdk in tests
1 parent 0c90731 commit 273e8b7

File tree

4 files changed

+117
-15
lines changed

4 files changed

+117
-15
lines changed

php/BuildPhp/BuildPhp.psd1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
'Get-File',
7070
'Get-OciSdk',
7171
'Get-PhpBuild',
72+
'Get-PhpDeps',
7273
'Get-PhpSdk',
7374
'Get-PhpSrc',
7475
'Get-PhpTestPack',
@@ -77,6 +78,7 @@
7778
'Get-TestsList',
7879
'Get-VsVersion',
7980
'Get-VsVersionHelper',
81+
'Invoke-EditBin',
8082
'Set-EnchantTestEnvironment',
8183
'Set-FirebirdTestEnvironment',
8284
'Set-MsSqlTestEnvironment',

php/BuildPhp/private/Add-TestRequirements.ps1

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,19 @@ function Add-TestRequirements {
7070
[System.IO.Compression.ZipFile]::ExtractToDirectory($testZipFilePath, $testsDirectoryPath)
7171
}
7272

73-
Get-PhpSdk
7473
$FetchDeps = $False
74+
$majorMinorVersion = ($PhpVersion -split '\.')[0..1] -join '.'
7575
if($null -eq $env:DEPS_DIR) {
76-
$majorMinorVersion = ($PhpVersion -split '\.')[0..1] -join '.'
7776
$env:DEPS_DIR = "C:\deps-$majorMinorVersion-$Arch"
7877
$FetchDeps = $True
7978
}
80-
if(-not(Test-Path $env:DEPS_DIR)) {
81-
New-Item "$env:DEPS_DIR" -ItemType "directory" -Force > $null 2>&1
82-
}
83-
$branch = if ($PhpVersion -eq 'master') {'master'} else {($PhpVersion -split '\.')[0..1] -join '.'}
84-
$env:PHP_SDK_VS = $VsVersion
85-
$env:PHP_SDK_ARCH = $Arch
86-
$bat_content = @()
8779
if($FetchDeps -eq $True -or $null -eq $Env:DEPS_CACHE_HIT -or $Env:DEPS_CACHE_HIT -ne 'true') {
88-
$bat_content += "cmd /c phpsdk_deps --update --force --no-backup --branch $branch --stability staging --deps $env:DEPS_DIR"
80+
Get-PhpDeps -PhpVersion $majorMinorVersion -VsVersion $VsVersion -Arch $Arch -Destination $env:DEPS_DIR
8981
}
90-
$bat_content += "editbin /stack:8388608 $binDirectoryPath\php.exe"
91-
$bat_content += "editbin /stack:8388608 $binDirectoryPath\php-cgi.exe"
92-
Set-Content -Encoding "ASCII" -Path vs.bat -Value $bat_content
93-
& "$currentDirectory\php-sdk\phpsdk-starter.bat" -c $VsVersion -a $Arch -t vs.bat
82+
Invoke-EditBin -Exe "$binDirectoryPath\php.exe" -StackSize 8388608 -Arch $Arch
83+
Invoke-EditBin -Exe "$binDirectoryPath\php-cgi.exe" -StackSize 8388608 -Arch $Arch
9484
Add-Path "$env:DEPS_DIR\bin"
9585
}
9686
end {
9787
}
98-
}
88+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
function Get-PhpDeps {
2+
<#
3+
.SYNOPSIS
4+
Fetch specified PHP SDK deps zip packages and extract them to a destination directory.
5+
.PARAMETER Version
6+
PHP version series (e.g., 8.3 or master).
7+
.PARAMETER VsVersion
8+
Visual Studio toolset version (e.g., vs16, vs17).
9+
.PARAMETER Arch
10+
Target architecture: x86 or x64.
11+
.PARAMETER Destination
12+
Destination directory to extract the downloaded deps into.
13+
#>
14+
[CmdletBinding()]
15+
param(
16+
[Parameter(Mandatory=$true)]
17+
[ValidateNotNullOrEmpty()]
18+
[string] $PhpVersion,
19+
[Parameter(Mandatory=$true)]
20+
[ValidateNotNullOrEmpty()]
21+
[string] $VsVersion,
22+
[Parameter(Mandatory=$true)]
23+
[ValidateSet('x86','x64')]
24+
[string] $Arch,
25+
[Parameter(Mandatory=$true)]
26+
[ValidateNotNullOrEmpty()]
27+
[string] $Destination
28+
)
29+
30+
begin {
31+
$baseurl = 'https://downloads.php.net/~windows/php-sdk/deps'
32+
}
33+
process {
34+
if (-not (Test-Path -LiteralPath $Destination)) {
35+
New-Item -ItemType Directory -Force -Path $Destination | Out-Null
36+
}
37+
38+
$seriesUrl = "$baseurl/series/packages-$PhpVersion-$VsVersion-$Arch-staging.txt"
39+
Write-Verbose "Fetching series listing: $seriesUrl"
40+
$series = Invoke-WebRequest -Uri $seriesUrl -UseBasicParsing -ErrorAction Stop
41+
$lines = @()
42+
if ($series -and $series.Content) {
43+
$lines = $series.Content -split "[\r\n]+" | Where-Object { $_ -and $_.Trim().Length -gt 0 }
44+
}
45+
foreach ($line in $lines) {
46+
Write-Host "Processing package $line"
47+
$temp = New-TemporaryFile | Rename-Item -NewName { $_.Name + '.zip' } -PassThru
48+
$url = "$baseurl/$VsVersion/$Arch/$line"
49+
Invoke-WebRequest -Uri $url -UseBasicParsing -OutFile $temp.FullName -ErrorAction Stop
50+
try {
51+
Expand-Archive -LiteralPath $temp.FullName -DestinationPath $Destination -Force
52+
} catch {
53+
Add-Type -AssemblyName System.IO.Compression.FileSystem -ErrorAction SilentlyContinue
54+
[System.IO.Compression.ZipFile]::ExtractToDirectory($temp.FullName, $Destination)
55+
} finally {
56+
Remove-Item -LiteralPath $temp.FullName -Force -ErrorAction SilentlyContinue
57+
}
58+
}
59+
60+
$extra = Join-Path $Destination 'openssl.cnf'
61+
if (Test-Path -LiteralPath $extra) {
62+
$tdir = Join-Path $Destination 'template\ssl'
63+
New-Item -ItemType Directory -Force -Path $tdir | Out-Null
64+
Move-Item -LiteralPath $extra -Destination (Join-Path $tdir 'openssl.cnf') -Force
65+
}
66+
}
67+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
function Invoke-EditBin {
2+
<#
3+
.SYNOPSIS
4+
Run editbin.exe to set the stack size on an executable.
5+
.PARAMETER Exe
6+
Path to the target executable.
7+
.PARAMETER StackSize
8+
Stack size in bytes.
9+
.PARAMETER Target
10+
Target architecture subfolder under Hostx64 (x64 or x86)
11+
#>
12+
[CmdletBinding()]
13+
param(
14+
[Parameter(Mandatory=$true, Position=0, HelpMessage='Path to target executable')]
15+
[ValidateNotNullOrEmpty()]
16+
[string] $Exe,
17+
[Parameter(Mandatory=$true, Position=1, HelpMessage='Stack reserve size in bytes')]
18+
[int] $StackSize,
19+
[Parameter(Mandatory=$true, Position=2, HelpMessage='Architecture')]
20+
[ValidateSet('x64','x86')]
21+
[string] $Arch
22+
)
23+
24+
process {
25+
if (-not (Test-Path -LiteralPath $Exe)) {
26+
throw "Target executable not found: $Exe"
27+
}
28+
29+
$pattern = "C:\\Program Files\\Microsoft Visual Studio\\2022\\*\\VC\\Tools\\MSVC\\*\\bin\\Hostx64\\$Arch\\editbin.exe"
30+
$editbin = Get-ChildItem -Path $pattern -File -ErrorAction SilentlyContinue |
31+
Sort-Object { Split-Path $_.DirectoryName -Leaf } -Descending |
32+
Select-Object -First 1
33+
34+
if (-not $editbin) {
35+
throw "editbin.exe not found under VS2022 paths."
36+
}
37+
38+
& $editbin.FullName "/STACK:$StackSize" $Exe
39+
if ($LASTEXITCODE) {
40+
throw "editbin failed with exit code $LASTEXITCODE"
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)