Skip to content

Commit 9c3bf94

Browse files
committed
Add support to build extensions on PHP 8.4
1 parent 6b8fa15 commit 9c3bf94

File tree

8 files changed

+67
-36
lines changed

8 files changed

+67
-36
lines changed

extension-matrix/config/vs.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,11 @@
4343
"vs": "2019",
4444
"os": "windows-2019",
4545
"type": "github-hosted"
46+
},
47+
"8.4": {
48+
"vs": "2022",
49+
"os": "windows-2022",
50+
"type": "github-hosted",
51+
"dev": true
4652
}
4753
}

extension-matrix/src/php-versions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function compare_versions_using_composer() {
6666
local composer_json=$2
6767
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
6868
vs_json="$SCRIPT_DIR"/../config/vs.json
69-
php_versions=$(jq -r 'keys | join(",")' "$vs_json")
69+
php_versions=$(jq -r 'to_entries | map(select(.value.dev != true)) | map(.key) | join(",")' "$vs_json")
7070
constraint=$(jq -r .require.php "$composer_json")
7171
php "$SCRIPT_DIR"/semver/semver.phar composer.json "$constraint" "$php_versions"
7272
}
@@ -76,7 +76,7 @@ function compare_versions_using_package_xml() {
7676
local package_xml=$2
7777
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
7878
vs_json="$SCRIPT_DIR"/../config/vs.json
79-
php_versions=$(jq -r 'keys | join(",")' "$vs_json")
79+
php_versions=$(jq -r 'to_entries | map(select(.value.dev != true)) | map(.key) | join(",")' "$vs_json")
8080
php "$SCRIPT_DIR"/semver/semver.phar package.xml "$package_xml" "$php_versions"
8181
}
8282

extension/BuildPhpExtension/BuildPhpExtension.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
# NestedModules = @()
6161

6262
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
63-
FunctionsToExport = 'Invoke-PhpBuildExtension', 'Add-BuildRequirements', 'Add-Path', 'Get-PhpSdk', 'Add-Dependencies', 'Add-PhpDependencies', 'Get-VsVersion', 'Add-Extension', 'Get-Extension', 'Get-BuildDirectory', 'Get-ExtensionSource', 'Add-ExtensionDependencies', 'Add-BuildTools', 'Add-OciSdk', 'Add-OdbcCli', 'Get-ExtensionConfig', 'Add-Extensions', 'Get-PhpBuild', 'Invoke-Build', 'Invoke-Tests', 'Add-Package', 'Get-PhpDevelBuild', 'Get-OlderVsVersion', 'Get-PeclLibraryZip'
63+
FunctionsToExport = 'Invoke-PhpBuildExtension', 'Add-BuildRequirements', 'Add-Path', 'Get-PhpSdk', 'Add-Dependencies', 'Add-PhpDependencies', 'Get-VsVersion', 'Add-Extension', 'Get-Extension', 'Get-BuildDirectory', 'Get-ExtensionSource', 'Add-ExtensionDependencies', 'Add-BuildTools', 'Add-OciSdk', 'Add-OdbcCli', 'Get-ExtensionConfig', 'Add-Extensions', 'Get-PhpBuild', 'Get-PhpBuildDetails', 'Invoke-Build', 'Invoke-Tests', 'Add-Package', 'Get-PhpDevelBuild', 'Get-OlderVsVersion', 'Get-PeclLibraryZip'
6464

6565
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
6666
CmdletsToExport = '*'

extension/BuildPhpExtension/config/vs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"8.0": "vs16",
88
"8.1": "vs16",
99
"8.2": "vs16",
10-
"8.3": "vs16"
10+
"8.3": "vs16",
11+
"8.4": "vs17"
1112
},
1213
"vs" : {
1314
"vc14": {

extension/BuildPhpExtension/private/Add-BuildRequirements.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ function Add-BuildRequirements {
5959
-Ts $Ts `
6060
-VsVersion $VsVersion `
6161
-VsToolset $VsToolset
62-
$prefix = Get-PhpBuild -Config $config
63-
Get-PhpDevelBuild -Config $config
62+
$buildDetails = Get-PhpBuildDetails -Config $Config
63+
$prefix = Get-PhpBuild -Config $config -BuildDetails $buildDetails
64+
Get-PhpDevelBuild -Config $config -BuildDetails $buildDetails
6465
Add-Dependencies -Config $config -Prefix $prefix
6566
return $config
6667
}

extension/BuildPhpExtension/private/Get-PhpBuild.ps1

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,26 @@ function Get-PhpBuild {
44
Get the PHP build.
55
.PARAMETER Config
66
Extension Configuration
7+
.PARAMETER BuildDetails
8+
PHP Build Details
79
#>
810
[OutputType()]
911
param (
1012
[Parameter(Mandatory = $true, Position=0, HelpMessage='Configuration for the extension')]
11-
[PSCustomObject] $Config
13+
[PSCustomObject] $Config,
14+
[Parameter(Mandatory = $true, Position=1, HelpMessage='Php Build Details')]
15+
[PSCustomObject] $BuildDetails
1216
)
1317
begin {
1418
}
1519
process {
1620
Add-Type -Assembly "System.IO.Compression.Filesystem"
17-
18-
$releaseState = if ($Config.php_version -match "[a-z]") {"qa"} else {"releases"}
19-
$baseUrl = "https://downloads.php.net/~windows/$releaseState"
20-
$fallbackBaseUrl = "https://downloads.php.net/~windows/$releaseState/archives"
21+
$phpSemver, $baseUrl = $BuildDetails.phpSemver, $BuildDetails.baseUrl
2122
$tsPart = if ($Config.ts -eq "nts") {"nts-Win32"} else {"Win32"}
22-
$releases = Invoke-WebRequest "$baseUrl/releases.json" | ConvertFrom-Json
23-
$phpSemver = $releases.$($Config.php_version).version
24-
if($null -eq $phpSemver) {
25-
$phpSemver = (Invoke-WebRequest $fallbackBaseUrl).Links |
26-
Where-Object { $_.href -match "php-($($Config.php_version).[0-9]+).*" } |
27-
ForEach-Object { $matches[1] } |
28-
Sort-Object { [System.Version]$_ } -Descending |
29-
Select-Object -First 1
30-
}
3123
$binZipFile = "php-$phpSemver-$tsPart-$($Config.vs_version)-$($Config.arch).zip"
3224
$binUrl = "$baseUrl/$binZipFile"
3325

34-
$fallBackUrl = "$fallbackBaseUrl/$binZipFile"
26+
$fallBackUrl = "$baseUrl/archives/$binZipFile"
3527

3628
if($Config.php_version -lt '7.4') {
3729
$fallBackUrl = $fallBackUrl.replace("vc", "VC")
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
function Get-PhpBuildDetails {
2+
<#
3+
.SYNOPSIS
4+
Get the PHP build Details.
5+
.PARAMETER Config
6+
Extension Configuration
7+
#>
8+
[OutputType()]
9+
param (
10+
[Parameter(Mandatory = $true, Position=0, HelpMessage='Configuration for the extension')]
11+
[PSCustomObject] $Config
12+
)
13+
begin {
14+
}
15+
process {
16+
foreach($releaseState in @("releases", "qa")) {
17+
$baseUrl = "https://downloads.php.net/~windows/$releaseState"
18+
$fallbackBaseUrl = "https://downloads.php.net/~windows/$releaseState/archives"
19+
$releases = Invoke-WebRequest "$baseUrl/releases.json" | ConvertFrom-Json
20+
$phpSemver = $releases.$($Config.php_version).version
21+
if($null -eq $phpSemver) {
22+
$phpSemver = (Invoke-WebRequest $fallbackBaseUrl).Links |
23+
Where-Object { $_.href -match "php-($($Config.php_version).[0-9]+).*" } |
24+
ForEach-Object { $matches[1] } |
25+
Sort-Object { [System.Version]$_ } -Descending |
26+
Select-Object -First 1
27+
}
28+
if($null -ne $phpSemver) {
29+
break
30+
}
31+
}
32+
return [PSCustomObject]@{
33+
phpSemver = $phpSemver
34+
baseUrl = $baseUrl
35+
}
36+
}
37+
end {
38+
}
39+
}

extension/BuildPhpExtension/private/Get-PhpDevelBuild.ps1

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,25 @@ function Get-PhpDevelBuild {
44
Get the PHP build.
55
.PARAMETER Config
66
Extension Configuration
7+
.PARAMETER BuildDetails
8+
PHP Build Details
79
#>
810
[OutputType()]
911
param (
1012
[Parameter(Mandatory = $true, Position=0, HelpMessage='Configuration for the extension')]
11-
[PSCustomObject] $Config
13+
[PSCustomObject] $Config,
14+
[Parameter(Mandatory = $true, Position=1, HelpMessage='Php Build Details')]
15+
[PSCustomObject] $BuildDetails
1216
)
1317
begin {
1418
}
1519
process {
1620
Add-Type -Assembly "System.IO.Compression.Filesystem"
17-
18-
$releaseState = if ($Config.php_version -match "[a-z]") {"qa"} else {"releases"}
19-
$baseUrl = "https://downloads.php.net/~windows/$releaseState"
20-
$fallbackBaseUrl = "https://downloads.php.net/~windows/$releaseState/archives"
21+
$phpSemver, $baseUrl = $BuildDetails.phpSemver, $BuildDetails.baseUrl
2122
$tsPart = if ($Config.ts -eq "nts") {"nts-Win32"} else {"Win32"}
22-
$releases = Invoke-WebRequest "$baseUrl/releases.json" | ConvertFrom-Json
23-
$phpSemver = $releases.$($Config.php_version).version
24-
if($null -eq $phpSemver) {
25-
$phpSemver = (Invoke-WebRequest $fallbackBaseUrl).Links |
26-
Where-Object { $_.href -match "php-($($Config.php_version).[0-9]+).*" } |
27-
ForEach-Object { $matches[1] } |
28-
Sort-Object { [System.Version]$_ } -Descending |
29-
Select-Object -First 1
30-
}
3123
$binZipFile = "php-devel-pack-$phpSemver-$tsPart-$($Config.vs_version)-$($Config.arch).zip"
3224
$binUrl = "$baseUrl/$binZipFile"
33-
$fallBackUrl = "$fallbackBaseUrl/$binZipFile"
25+
$fallBackUrl = "$baseUrl/archives/$binZipFile"
3426

3527
if($Config.php_version -lt '7.4') {
3628
$fallBackUrl = $fallBackUrl.replace("vc", "VC")

0 commit comments

Comments
 (0)