Use manifests for Windows PHP release assets

This commit is contained in:
Shivam Mathur
2026-08-29 23:16:02 +05:30
parent 047d693cbc
commit 3cd644eeae
+26 -36
View File
@@ -167,6 +167,26 @@ Function Get-File {
} }
} }
# Function to get an asset name from the PHP builder release manifest.
Function Get-PhpReleaseAsset {
param (
[ValidateSet('php', 'debug')]
[string]$Type,
[ValidateSet('stable', 'dev')]
[string]$Stability = 'stable'
)
if($null -eq $script:php_manifest) {
$script:php_manifest = Invoke-RestMethod "$php_builder/releases/download/php$version/manifest.json"
}
$thread_safety = if($ts) { 'ts' } else { 'nts' }
$asset = $script:php_manifest.$Stability.$Type.$thread_safety.$arch
if($null -eq $asset) {
throw "Asset not found in the php$version release manifest"
}
return $asset
}
# Function to make sure printf is in PATH. # Function to make sure printf is in PATH.
Function Add-Printf { Function Add-Printf {
if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) { if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) {
@@ -261,48 +281,17 @@ Function Add-PhpConfig {
# Function to get PHP from GitHub releases cache # Function to get PHP from GitHub releases cache
Function Set-PhpCache { Function Set-PhpCache {
try { try {
try { $asset = Get-PhpReleaseAsset -Type php
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version Get-File -Url $php_builder/releases/download/php$version/$asset -FallbackUrl https://downloads.php.net/~windows/releases/archives/$asset -OutFile $php_dir\$asset
$asset = $release.assets | ForEach-Object {
if($_.name -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
return $_.name
}
} | Select-Object -Last 1
if($null -eq $asset) {
throw "Asset not found"
}
} catch {
$release = Get-File -Url $php_builder/releases/expanded_assets/php$version
$asset = $release.links.href | ForEach-Object {
if($_ -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
return $_.split('/')[-1]
}
} | Select-Object -Last 1
}
Get-File -Url $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset
Set-PhpDownloadCache -Path $php_dir CurrentUser Set-PhpDownloadCache -Path $php_dir CurrentUser
} catch { } } catch { }
} }
# Function to add debug symbols to PHP. # Function to add debug symbols to PHP.
Function Add-DebugSymbols { Function Add-DebugSymbols {
$dev = if ($version -match $nightly_versions) { '-dev' } else { '' } $stability = if ($version -match $nightly_versions) { 'dev' } else { 'stable' }
try { $asset = Get-PhpReleaseAsset -Type debug -Stability $stability
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version Get-File -Url $php_builder/releases/download/php$version/$asset -FallbackUrl https://downloads.php.net/~windows/releases/archives/$asset -OutFile $php_dir\$asset
$asset = $release.assets | ForEach-Object {
if($_.name -match "php-debug-pack-$version.[0-9]+$dev$env:PHPTS-Win32-.*-$arch.zip") {
return $_.name
}
} | Select-Object -Last 1
} catch {
$release = Get-File -Url $php_builder/releases/expanded_assets/php$version
$asset = $release.links.href | ForEach-Object {
if($_ -match "php-debug-pack-$version.[0-9]+$dev$env:PHPTS-Win32-.*-$arch.zip") {
return $_.split('/')[-1]
}
} | Select-Object -Last 1
}
Get-File -Url $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset
Expand-Archive -Path $php_dir\$asset -DestinationPath $php_dir -Force Expand-Archive -Path $php_dir\$asset -DestinationPath $php_dir -Force
Get-ChildItem -Path $php_dir -Filter php_*.pdb | Move-Item -Destination $ext_dir Get-ChildItem -Path $php_dir -Filter php_*.pdb | Move-Item -Destination $ext_dir
} }
@@ -325,6 +314,7 @@ $ext_dir = "$php_dir\ext"
$bin_dir = $php_dir $bin_dir = $php_dir
$github = 'https://github.com' $github = 'https://github.com'
$php_builder = "$github/shivammathur/php-builder-windows" $php_builder = "$github/shivammathur/php-builder-windows"
$php_manifest = $null
$current_profile = "$env:TEMP\setup-php.ps1" $current_profile = "$env:TEMP\setup-php.ps1"
$ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue'
$jit_versions = '8.[0-9]' $jit_versions = '8.[0-9]'