Add support to install extensions from shivammathur/php-extensions-windows

This commit is contained in:
Shivam Mathur 2022-12-23 18:40:56 +05:30
parent 5afd8a1842
commit e51e662ef0
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
2 changed files with 58 additions and 18 deletions

View File

@ -0,0 +1,2 @@
xdebug
pcov

View File

@ -6,8 +6,9 @@ Function Set-ExtensionPrerequisites
[ValidateNotNull()] [ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)] [ValidateLength(1, [int]::MaxValue)]
[string] [string]
$deps_dir $extension
) )
$deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch"
$deps = Get-ChildItem -Recurse -Path $deps_dir $deps = Get-ChildItem -Recurse -Path $deps_dir
if ($deps.Count -ne 0) { if ($deps.Count -ne 0) {
# Symlink dependencies instead of adding the directory to PATH ... # Symlink dependencies instead of adding the directory to PATH ...
@ -20,6 +21,41 @@ Function Set-ExtensionPrerequisites
} }
} }
# Function to enable extension.
Function Enable-Extension() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$extension
)
Enable-ExtensionDependencies $extension
Enable-PhpExtension -Extension $extension -Path $php_dir
Set-ExtensionPrerequisites $extension
Add-Log $tick $extension "Enabled"
}
# Function to add custom built PHP extension for nightly builds.
Function Add-NightlyExtension {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$extension
)
if($ts) { $ts_part = 'ts' } else { $ts_part = 'nts' }
$repo = "$github/shivammathur/php-extensions-windows"
$url = "$repo/releases/download/builds/php$version`_$ts_part`_$arch`_$extension.dll"
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile "$ext_dir\php_$extension.dll"
if(Test-Path "$ext_dir\php_$extension.dll") {
Enable-Extension $extension > $null
} else {
throw "Failed to download the $extension"
}
}
# Function to add PHP extensions. # Function to add PHP extensions.
Function Add-Extension { Function Add-Extension {
Param ( Param (
@ -52,30 +88,32 @@ Function Add-Extension {
Add-Log $tick $extension "Enabled" Add-Log $tick $extension "Enabled"
} }
default { default {
Enable-ExtensionDependencies $extension Enable-Extension $extension_info.Handle
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
Set-ExtensionPrerequisites $deps_dir
Add-Log $tick $extension "Enabled"
} }
} }
} }
else { else {
if(($version -match $nightly_versions) -and (Select-String -Path $src\configs\windows_extensions -Pattern $extension -SimpleMatch -Quiet)) {
Add-NightlyExtension $extension
} else {
# Patch till PHP 8.2 DLLs are released as stable. # Patch till PHP 8.2 DLLs are released as stable.
$minimumStability = $stability $minimumStability = $stability
if($version -eq '8.2' -and $stability -eq 'stable') { if ($version -eq '8.2' -and $stability -eq 'stable')
{
$minimumStability = 'snapshot' $minimumStability = 'snapshot'
} }
$params = @{ Extension = $extension; MinimumStability = $minimumStability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true } $params = @{ Extension = $extension; MinimumStability = $minimumStability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true }
if($extension_version -ne '') { if ($extension_version -ne '')
{
$params["Version"] = $extension_version $params["Version"] = $extension_version
} }
Install-PhpExtension @params Install-PhpExtension @params
Set-ExtensionPrerequisites $deps_dir Set-ExtensionPrerequisites $extension
}
Add-Log $tick $extension "Installed and enabled" Add-Log $tick $extension "Installed and enabled"
} }
} } catch {
catch {
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )" Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
} }
} }