Skip to content

Commit 4748e42

Browse files
committed
Switch to windows-2022 for building PHP
Add missing VS components if needed
1 parent 398bf88 commit 4748e42

File tree

12 files changed

+148
-22
lines changed

12 files changed

+148
-22
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
matrix:
2020
arch: [x64, x86]
2121
ts: [nts, ts]
22-
runs-on: ${{ (inputs.php-version > '8.4' || inputs.php-version=='master') && 'windows-2022' || 'windows-2019' }}
22+
runs-on: windows-2022
2323
steps:
2424
- name: Checkout
2525
uses: actions/checkout@v4

extension/BuildPhpExtension/private/Add-VS.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ function Add-Vs {
4242

4343
if ($vsInst) {
4444
[string]$channel = $vsInst.installationVersion.Split('.')[0]
45-
if ($vsInst.catalog.productId -match '(Enterprise|Professional|Community)$' ) {
45+
$productId = $null
46+
if ($vsInst.catalog -and $vsInst.catalog.PSObject.Properties['productId']) {
47+
$productId = $vsInst.catalog.productId
48+
} elseif ($vsInst.PSObject.Properties['productId']) {
49+
$productId = $vsInst.productId
50+
}
51+
if ($productId -match '(Enterprise|Professional|Community)$' ) {
4652
$exe = "vs_$($Matches[1].ToLower()).exe"
4753
} else {
4854
$exe = 'vs_buildtools.exe'
@@ -58,7 +64,7 @@ function Add-Vs {
5864
--quiet --wait --norestart --nocache `
5965
@componentArgs 2>&1 | ForEach-Object { Write-Host $_ }
6066
} else {
61-
$channel = $VsVersion -replace '/D', ''
67+
$channel = $VsVersion -replace '\D', ''
6268
$exe = 'vs_buildtools.exe'
6369
$installerUrl = "https://aka.ms/vs/$channel/release/$exe"
6470
$installerPath = Join-Path $env:TEMP $exe

php/BuildPhp/BuildPhp.psd1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@
6464
# Private functions
6565
'Add-BuildRequirements',
6666
'Add-TestRequirements',
67+
'Add-Vs',
6768
'Get-OciSdk',
6869
'Get-PhpBuild',
6970
'Get-PhpSdk',
7071
'Get-PhpSrc',
7172
'Get-PhpTestPack',
7273
'Get-TestSettings',
7374
'Get-TestsList'
75+
'Get-VsVersionHelper',
7476
'Get-VsVersion',
7577
'Set-PhpIniForTests'
7678

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--without-analyzer" "--enable-pgi" %*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--without-analyzer" "--enable-pgi" %*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--without-analyzer" "--enable-pgi" %*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--without-analyzer" "--enable-pgi" %*

php/BuildPhp/config/vs.json

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,60 @@
11
{
2-
"7.0": "vc14",
3-
"7.1": "vc14",
4-
"7.2": "vc15",
5-
"7.3": "vc15",
6-
"7.4": "vc15",
7-
"8.0": "vs16",
8-
"8.1": "vs16",
9-
"8.2": "vs16",
10-
"8.3": "vs16",
11-
"8.4": "vs17",
12-
"master": "vs17"
2+
"php": {
3+
"7.1": "vc14",
4+
"7.2": "vc15",
5+
"7.3": "vc15",
6+
"7.4": "vc15",
7+
"8.0": "vs16",
8+
"8.1": "vs16",
9+
"8.2": "vs16",
10+
"8.3": "vs16",
11+
"8.4": "vs17",
12+
"master": "vs17"
13+
},
14+
"vs" : {
15+
"vc14": {
16+
"major": 14,
17+
"minorMin": 0,
18+
"minorMax": 9,
19+
"components": [
20+
"Microsoft.VisualStudio.Component.CoreBuildTools",
21+
"Microsoft.VisualStudio.Component.VC.140",
22+
"Microsoft.VisualStudio.Component.VC.ATL",
23+
"Microsoft.VisualStudio.Component.Windows10SDK.19041"
24+
]
25+
},
26+
"vc15": {
27+
"major": 14,
28+
"minorMin": 10,
29+
"minorMax": 19,
30+
"components": [
31+
"Microsoft.VisualStudio.Component.CoreBuildTools",
32+
"Microsoft.VisualStudio.Component.VC.v141.x86.x64",
33+
"Microsoft.VisualStudio.Component.VC.ATL",
34+
"Microsoft.VisualStudio.Component.Windows10SDK.19041"
35+
]
36+
},
37+
"vs16": {
38+
"major": 14,
39+
"minorMin": 20,
40+
"minorMax": 29,
41+
"components": [
42+
"Microsoft.VisualStudio.Component.CoreBuildTools",
43+
"Microsoft.VisualStudio.ComponentGroup.VC.Tools.142.x86.x64",
44+
"Microsoft.VisualStudio.Component.VC.ATL",
45+
"Microsoft.VisualStudio.Component.Windows10SDK.19041"
46+
]
47+
},
48+
"vs17": {
49+
"major": 14,
50+
"minorMin": 30,
51+
"minorMax": null,
52+
"components": [
53+
"Microsoft.VisualStudio.Component.CoreBuildTools",
54+
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
55+
"Microsoft.VisualStudio.Component.VC.ATL",
56+
"Microsoft.VisualStudio.Component.Windows10SDK.19041"
57+
]
58+
}
59+
}
1360
}

php/BuildPhp/private/Add-VS.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ function Add-Vs {
3838

3939
if ($vsInst) {
4040
[string]$channel = $vsInst.installationVersion.Split('.')[0]
41-
if ($vsInst.catalog.productId -match '(Enterprise|Professional|Community)$' ) {
41+
$productId = $null
42+
if ($vsInst.catalog -and $vsInst.catalog.PSObject.Properties['productId']) {
43+
$productId = $vsInst.catalog.productId
44+
} elseif ($vsInst.PSObject.Properties['productId']) {
45+
$productId = $vsInst.productId
46+
}
47+
if ($productId -match '(Enterprise|Professional|Community)$' ) {
4248
$exe = "vs_$($Matches[1].ToLower()).exe"
4349
} else {
4450
$exe = 'vs_buildtools.exe'

php/BuildPhp/private/Get-VsVersion.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,20 @@ function Get-VsVersion {
1717
}
1818
process {
1919
$jsonContent = Get-Content -Path $jsonPath -Raw
20-
$versions = ConvertFrom-Json -InputObject $jsonContent
21-
if($PhpVersion -eq 'master') { $key = 'master'; } else { $key = $PhpVersion.Substring(0, 3); }
22-
return $($versions.$key)
20+
$VsConfig = ConvertFrom-Json -InputObject $jsonContent
21+
if($PhpVersion -eq 'master') { $majorMinor = 'master'; } else { $majorMinor = $PhpVersion.Substring(0, 3); }
22+
$VsVersion = $($VsConfig.php.$majorMinor)
23+
$selectedToolset = $null
24+
try {
25+
$selectedToolset = Get-VsVersionHelper -VsVersion $VsVersion -VsConfig $VsConfig
26+
} catch {
27+
Add-Vs -VsVersion $VsVersion -VsConfig $VsConfig
28+
$selectedToolset = Get-VsVersionHelper -VsVersion $VsVersion -VsConfig $VsConfig
29+
}
30+
return [PSCustomObject]@{
31+
vs = $VsVersion
32+
toolset = $selectedToolset
33+
}
2334
}
2435
end {
2536
}

0 commit comments

Comments
 (0)