Skip to content

Commit 5d1ed07

Browse files
committed
Improve applying patches
1 parent 26c58bc commit 5d1ed07

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

extension/BuildPhpExtension/BuildPhpExtension.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
'Add-OciSdk',
7474
'Add-OdbcCli',
7575
'Add-Package',
76+
'Add-Patches',
7677
'Add-Path',
7778
'Add-PhpDependencies',
7879
'Add-StepLog',
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Function Add-Patches {
2+
<#
3+
.SYNOPSIS
4+
Add patches to the extension.
5+
.PARAMETER Extension
6+
The extension name.
7+
#>
8+
[OutputType()]
9+
param(
10+
[Parameter(Mandatory = $true, Position=0, HelpMessage='Extension')]
11+
[ValidateNotNull()]
12+
[ValidateLength(1, [int]::MaxValue)]
13+
[string] $Extension
14+
)
15+
begin {
16+
}
17+
process {
18+
# Apply patches only for php/php-windows-builder and shivammathur/php-windows-builder
19+
if($null -ne $env:GITHUB_REPOSITORY) {
20+
if($env:GITHUB_REPOSITORY -eq 'php/php-windows-builder' -or $env:GITHUB_REPOSITORY -eq 'shivammathur/php-windows-builder') {
21+
if(Test-Path -PATH $PSScriptRoot\..\patches\$Extension.ps1) {
22+
. $PSScriptRoot\..\patches\$Extension.ps1
23+
}
24+
}
25+
}
26+
}
27+
end {
28+
}
29+
}

extension/BuildPhpExtension/private/Get-Extension.ps1

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ function Get-Extension {
5151
}
5252
}
5353

54+
$patches = $False
55+
if(Test-Path -PATH $PSScriptRoot\..\patches\$extension.ps1) {
56+
if((Get-Content $PSScriptRoot\..\patches\$extension.ps1).Contains('config.w32')) {
57+
Add-Patches $extension
58+
$patches = $True
59+
}
60+
}
61+
5462
$configW32 = Get-ChildItem (Get-Location).Path -Recurse -Filter "config.w32" -ErrorAction SilentlyContinue
5563
if($null -eq $configW32) {
5664
throw "No config.w32 found"
@@ -74,13 +82,8 @@ function Get-Extension {
7482
}
7583
}
7684

77-
# Apply patches only for php/php-windows-builder and shivammathur/php-windows-builder
78-
if($null -ne $env:GITHUB_REPOSITORY) {
79-
if($env:GITHUB_REPOSITORY -eq 'php/php-windows-builder' -or $env:GITHUB_REPOSITORY -eq 'shivammathur/php-windows-builder') {
80-
if(Test-Path -PATH $PSScriptRoot\..\patches\$name.ps1) {
81-
. $PSScriptRoot\..\patches\$name.ps1
82-
}
83-
}
85+
if(!$patches) {
86+
Add-Patches $name
8487
}
8588
Add-BuildLog tick $name "Fetched $name extension"
8689
return $name

0 commit comments

Comments
 (0)