Skip to content

Commit 3f13765

Browse files
committed
Add support for oci extensions
1 parent c85638c commit 3f13765

File tree

8 files changed

+76
-14
lines changed

8 files changed

+76
-14
lines changed

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', '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', 'Get-ExtensionConfig', 'Add-Extensions', 'Get-PhpBuild', '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 = '*'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"require": {
3+
"instantclient": "*"
4+
},
5+
"php-ext": {
6+
"configure-options": [
7+
{
8+
"name": "with-oci8-19=../deps,shared"
9+
}
10+
]
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"require": {
3+
"instantclient": "*"
4+
},
5+
"php-ext": {
6+
"configure-options": [
7+
{
8+
"name": "with-pdo-oci=../deps,shared"
9+
}
10+
]
11+
}
12+
}

extension/BuildPhpExtension/private/Add-ExtensionDependencies.ps1

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,20 @@ Function Add-ExtensionDependencies {
1414
}
1515
process {
1616
$Config.extension_libraries | ForEach-Object {
17-
$url = "https://downloads.php.net/~windows/pecl/deps/$_"
18-
Invoke-WebRequest -Uri $url -OutFile $_ -UseBasicParsing
19-
Expand-Archive -Path $_ -DestinationPath "..\deps"
20-
$libName = $_.split('-')[0]
21-
if(Test-Path "..\deps\LICENSE") {
22-
Rename-Item -Path "..\deps\LICENSE" -NewName "LICENSE.$libName"
17+
switch ($_)
18+
{
19+
instantclient {
20+
Add-OciSdk -Config $Config
21+
}
22+
Default {
23+
$url = "https://downloads.php.net/~windows/pecl/deps/$_"
24+
Invoke-WebRequest -Uri $url -OutFile $_ -UseBasicParsing
25+
Expand-Archive -Path $_ -DestinationPath "..\deps"
26+
$libName = $_.split('-')[0]
27+
if(Test-Path "..\deps\LICENSE") {
28+
Rename-Item -Path "..\deps\LICENSE" -NewName "LICENSE.$libName"
29+
}
30+
}
2331
}
2432
}
2533
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Function Add-OciSdk {
2+
<#
3+
.SYNOPSIS
4+
Add sdk for OCI extensions.
5+
.PARAMETER Config
6+
The directory to add to PATH.
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+
$suffix = if ($Config.arch -eq "x64") {"windows"} else {"nt"}
17+
$url = "https://download.oracle.com/otn_software/nt/instantclient/instantclient-sdk-$suffix.zip"
18+
Invoke-WebRequest $url -OutFile "instantclient-sdk.zip"
19+
Expand-Archive -Path "instantclient-sdk.zip" -DestinationPath "../deps"
20+
Copy-Item ../deps/instantclient_*/sdk/* -Destination "../deps" -Recurse -Force
21+
}
22+
end {
23+
}
24+
}

extension/BuildPhpExtension/private/Add-Package.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ function Add-Package {
7070
if($arch -eq 'x64') {
7171
$arch = 'x86_64'
7272
}
73-
$artifact = "php_$($Config.name)-$($Config.ref)-$($Config.php_version)-$($Config.ts)-$($Config.vs_version)-$arch"
73+
$artifact = "php_$($Config.package_name)-$($Config.ref)-$($Config.php_version)-$($Config.ts)-$($Config.vs_version)-$arch"
7474
@("php_$($Config.name).dll", "php_$($Config.name).pdb") | ForEach-Object {
7575
$extension = $_.Split('.')[1]
7676
if(Test-Path -Path $_) {
7777
Move-Item -Path $_ -Destination "$artifact.$extension" -Force
7878
}
7979
}
8080
} else {
81-
$artifact = "php_$($Config.name)-$($Config.ref)-$($Config.php_version)-$($Config.ts)-$($Config.vs_version)-$arch"
81+
$artifact = "php_$($Config.package_name)-$($Config.ref)-$($Config.php_version)-$($Config.ts)-$($Config.vs_version)-$arch"
8282
}
8383

8484
7z a -sdel "$artifact.zip" *

extension/BuildPhpExtension/private/Get-Extension.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ function Get-Extension {
5858
Copy-Item -Path "${subDirectory}\*" -Destination $currentDirectory -Recurse -Force
5959
Remove-Item -Path $subDirectory -Recurse -Force
6060
}
61-
$configW32Content = [string](Get-Content -Path "config.w32")
62-
$extensionLine = $configW32Content | Select-String -Pattern '\s+(ZEND_)?EXTENSION\(' | Select-Object -First 1
61+
$configW32Content = Get-Content -Path "config.w32"
62+
$extensionLine = $configW32Content | Select-String -Pattern '\s+(ZEND_)?EXTENSION\(' | Select-Object -Last 1
6363
if($null -eq $extensionLine) {
6464
throw "No extension found in config.w32"
6565
}
6666
$name = ($extensionLine -replace '.*EXTENSION\(([^,]+),.*', '$1') -replace '["'']', ''
67-
if ($configW32Content -match ($([regex]::Escape($name)) + '\s*=\s*["''](.+?)["'']')) {
67+
if($name.Contains('oci8')) {
68+
$name = 'oci8_19'
69+
} elseif ([string]$configW32Content -match ($([regex]::Escape($name)) + '\s*=\s*["''](.+?)["'']')) {
6870
$name = $matches[1]
6971
}
7072

extension/BuildPhpExtension/private/Get-ExtensionConfig.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Function Get-ExtensionConfig {
6363
}
6464
$config = [PSCustomObject]@{
6565
name = $Extension
66+
package_name = $Extension
6667
ref = $ref
6768
php_version = $PhpVersion
6869
arch = $Arch
@@ -77,13 +78,16 @@ Function Get-ExtensionConfig {
7778
docs = @()
7879
build_directory = ""
7980
}
81+
if($Extension.Contains("oci8")) {
82+
$config.package_name = "oci8"
83+
}
8084
$composerJson = $null
8185
if(Test-Path composer.json) {
8286
$composerJson = Get-Content composer.json -Raw | ConvertFrom-Json
8387
}
8488
if($null -eq $composerJson -or $null -eq $composerJson."php-ext") {
85-
if (Test-Path $PSScriptRoot\..\config\stubs\$Extension.composer.json) {
86-
Copy-Item $PSScriptRoot\..\config\stubs\$Extension.composer.json composer.json
89+
if (Test-Path $PSScriptRoot\..\config\stubs\${config.package_name}.composer.json) {
90+
Copy-Item $PSScriptRoot\..\config\stubs\${config.package_name}.composer.json composer.json
8791
}
8892
} else {
8993
$composerJson."php-ext"."configure-options" | ForEach-Object {

0 commit comments

Comments
 (0)