Skip to content

Commit 583e2df

Browse files
committed
Add support to use toolset in php-sdk-binary-tools
1 parent 33c0582 commit 583e2df

File tree

6 files changed

+38
-19
lines changed

6 files changed

+38
-19
lines changed

extension-matrix/config/vs.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
"type": "self-hosted"
1111
},
1212
"7.2": {
13-
"vs": "2017",
14-
"os": "windows-2016",
15-
"type": "self-hosted"
13+
"vs": "2019",
14+
"os": "windows-2019",
15+
"type": "github-hosted"
1616
},
1717
"7.3": {
18-
"vs": "2017",
19-
"os": "windows-2016",
20-
"type": "self-hosted"
18+
"vs": "2019",
19+
"os": "windows-2019",
20+
"type": "github-hosted"
2121
},
2222
"7.4": {
23-
"vs": "2017",
24-
"os": "windows-2016",
25-
"type": "self-hosted"
23+
"vs": "2019",
24+
"os": "windows-2019",
25+
"type": "github-hosted"
2626
},
2727
"8.0": {
2828
"vs": "2019",

extension/BuildPhpExtension/private/Add-BuildRequirements.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ function Add-BuildRequirements {
1414
Extension Thread Safety
1515
.PARAMETER VsVersion
1616
Visual Studio version
17+
.PARAMETER VsToolset
18+
Visual Studio toolset
1719
#>
1820
[OutputType()]
1921
param (
@@ -40,7 +42,11 @@ function Add-BuildRequirements {
4042
[Parameter(Mandatory = $true, Position=5, HelpMessage='Visual Studio version')]
4143
[ValidateNotNull()]
4244
[ValidateLength(1, [int]::MaxValue)]
43-
[string] $VsVersion
45+
[string] $VsVersion,
46+
[Parameter(Mandatory = $true, Position=6, HelpMessage='Visual Studio toolset')]
47+
[ValidateNotNull()]
48+
[ValidateLength(1, [int]::MaxValue)]
49+
[string] $VsToolset
4450
)
4551
begin {
4652
}
@@ -51,7 +57,8 @@ function Add-BuildRequirements {
5157
-PhpVersion $PhpVersion `
5258
-Arch $Arch `
5359
-Ts $Ts `
54-
-VsVersion $VsVersion
60+
-VsVersion $VsVersion `
61+
-VsToolset $VsToolset
5562
$prefix = Get-PhpBuild -Config $config
5663
Get-PhpDevelBuild -Config $config
5764
Add-Dependencies -Config $config -Prefix $prefix

extension/BuildPhpExtension/private/Get-ExtensionConfig.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Function Get-ExtensionConfig {
1414
Extension Thread Safety
1515
.PARAMETER VsVersion
1616
Visual Studio version
17+
.PARAMETER VsToolset
18+
Visual Studio toolset
1719
#>
1820
[OutputType()]
1921
param(
@@ -40,7 +42,11 @@ Function Get-ExtensionConfig {
4042
[Parameter(Mandatory = $true, Position=5, HelpMessage='Visual Studio version')]
4143
[ValidateNotNull()]
4244
[ValidateLength(1, [int]::MaxValue)]
43-
[string] $VsVersion
45+
[string] $VsVersion,
46+
[Parameter(Mandatory = $true, Position=6, HelpMessage='Visual Studio toolset')]
47+
[ValidateNotNull()]
48+
[ValidateLength(1, [int]::MaxValue)]
49+
[string] $VsToolset
4450
)
4551
begin {
4652
}
@@ -62,6 +68,7 @@ Function Get-ExtensionConfig {
6268
arch = $Arch
6369
ts = $Ts
6470
vs_version = $VsVersion
71+
vs_toolset = $VsToolset
6572
options = @()
6673
php_libraries = @()
6774
extension_libraries = @()

extension/BuildPhpExtension/private/Get-VsVersion.ps1

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,25 @@ function Get-VsVersion {
2525
throw "vswhere is not available"
2626
}
2727
$MSVCDirectory = vswhere -latest -find "VC\Tools\MSVC"
28-
$toolset = $null
28+
$selectedToolset = $null
29+
$minor = $null
2930
foreach ($toolset in (Get-ChildItem $MSVCDirectory)) {
3031
$toolsetMajorVersion, $toolsetMinorVersion = $toolset.Name.split(".")[0,1]
3132
$requiredVs = $VsConfig.vs.$VsVersion
3233
if ($requiredVs.major -eq $toolsetMajorVersion -and ($null -eq $requiredVs.minor -or $toolsetMinorVersion -le $requiredVs.minor)) {
33-
$toolset = $toolset.Name
34-
break
34+
if($null -eq $minor -or $toolsetMinorVersion -gt $minor)
35+
{
36+
$selectedToolset = $toolset.Name.Trim()
37+
$minor = $toolsetMinorVersion
38+
}
3539
}
3640
}
37-
if (-not $toolset) {
41+
if (-not $selectedToolset) {
3842
throw "toolset not available"
3943
}
4044
return [PSCustomObject]@{
4145
vs = $VsVersion
42-
toolset = $toolset
46+
toolset = $selectedToolset
4347
}
4448
}
4549
end {

extension/BuildPhpExtension/private/Invoke-Build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Function Invoke-Build {
3131
$Config.vs_version,
3232
$Config.arch
3333
) -join "-")
34-
& $builder -t $task | Tee-Object -FilePath "build-$suffix.txt"
34+
& $builder -s $Config.vs_toolset -t $task | Tee-Object -FilePath "build-$suffix.txt"
3535
}
3636
end {
3737
}

extension/BuildPhpExtension/public/Invoke-PhpBuildExtension.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ function Invoke-PhpBuildExtension {
5858
-PhpVersion $PhpVersion `
5959
-Arch $Arch `
6060
-Ts $Ts `
61-
-VsVersion $VsData.vs
61+
-VsVersion $VsData.vs `
62+
-VsToolset $VsData.toolset
6263

6364
Invoke-Build -Config $config
6465

0 commit comments

Comments
 (0)