diff --git a/.github/workflows/extension.yml b/.github/workflows/extension.yml index 81aabdb..3fce5ab 100644 --- a/.github/workflows/extension.yml +++ b/.github/workflows/extension.yml @@ -45,7 +45,7 @@ on: options: ['on', 'off', 'both'] description: 'Test opcache mode' required: false - default: 'on' + default: 'off' jobs: get-extension-matrix: runs-on: ubuntu-latest diff --git a/.github/workflows/pecl.yml b/.github/workflows/pecl.yml index 1a9ad37..88dfcdb 100644 --- a/.github/workflows/pecl.yml +++ b/.github/workflows/pecl.yml @@ -82,6 +82,8 @@ jobs: build-directory: C:\build env: artifact-naming-scheme: pecl + auto-detect-args: true + auto-detect-libs: true artifacts: runs-on: ubuntu-latest diff --git a/README.md b/README.md index de66dc6..275b1fb 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Build PHP for a specific version, architecture and thread safety. - name: Build PHP uses: php/php-windows-builder/php@v1 with: - php-version: '8.3.2' + php-version: '8.4.1' arch: x64 ts: nts ``` @@ -38,7 +38,7 @@ jobs: - name: Build uses: php/php-windows-builder/php@v1 with: - php-version: '8.3.2' + php-version: '8.4.1' arch: ${{ matrix.arch }} ts: ${{ matrix.ts }} ``` @@ -58,7 +58,7 @@ Build a PHP extension for a specific version. uses: php/php-windows-builder/extension@v1 with: extension-url: https://github.com/xdebug/xdebug - extension-ref: '3.3.1' + extension-ref: '3.3.2' php-version: '8.3' ts: nts arch: x64 @@ -78,7 +78,7 @@ Build a PHP extension for a specific version. - `build-directory` (optional) - The directory to build the extension in, defaults to the user's temporary directory. - `run-tests` (optional) - Run the extension tests. Defaults to `true`. - `test-runner` (optional) - The test runner to use. Defaults to `run-tests.php`. -- `test-opcache-mode` (optional) - Run tests with opcache `on`, `off` or `both`. Defaults to `on`. +- `test-opcache-mode` (optional) - Run tests with opcache `on`, `off` or `both`. Defaults to `off`. - `auth-token` (optional) - Authentication token to use in case the extension is hosted on a private repository. Instead of having to configure all the inputs for the extension action, you can use the `extension-matrix` action to get the matrix of jobs with different input configurations. @@ -97,8 +97,8 @@ jobs: uses: php/php-windows-builder/extension-matrix@v1 with: extension-url: https://github.com/xdebug/xdebug - extension-ref: '3.3.1' - php-version-list: '8.3, 8.4' + extension-ref: '3.3.2' + php-version-list: '8.2, 8.3' arch-list: 'x64, x86' ts-list: 'nts, ts' ``` @@ -136,6 +136,7 @@ It will also check if a GitHub hosted Windows runner is available with the requi | 8.1 | 2019 (vs16) | windows-2019, github-hosted | | 8.2 | 2019 (vs16) | windows-2019, github-hosted | | 8.3 | 2019 (vs16) | windows-2019, github-hosted | +| 8.4 | 2022 (vs17) | windows-2022, github-hosted | ## Release diff --git a/extension-matrix/config/vs.json b/extension-matrix/config/vs.json index 19fc4f8..1d6a655 100644 --- a/extension-matrix/config/vs.json +++ b/extension-matrix/config/vs.json @@ -47,7 +47,6 @@ "8.4": { "vs": "2022", "os": "windows-2022", - "type": "github-hosted", - "dev": true + "type": "github-hosted" } } diff --git a/extension/BuildPhpExtension/BuildPhpExtension.psd1 b/extension/BuildPhpExtension/BuildPhpExtension.psd1 index a937d28..29aa572 100644 --- a/extension/BuildPhpExtension/BuildPhpExtension.psd1 +++ b/extension/BuildPhpExtension/BuildPhpExtension.psd1 @@ -73,13 +73,16 @@ 'Add-OciSdk', 'Add-OdbcCli', 'Add-Package', + 'Add-Patches', 'Add-Path', 'Add-PhpDependencies', 'Add-StepLog', + 'Get-ArgumentFromConfig', 'Get-BuildDirectory', 'Get-Extension', 'Get-ExtensionConfig', 'Get-ExtensionSource', + 'Get-LibrariesFromConfig', 'Get-OlderVsVersion', 'Get-PeclLibraryZip', 'Get-PhpBuild', diff --git a/extension/BuildPhpExtension/config/stubs/apcu.composer.json b/extension/BuildPhpExtension/config/stubs/apcu.composer.json deleted file mode 100644 index 83e2b04..0000000 --- a/extension/BuildPhpExtension/config/stubs/apcu.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-apcu" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/ast.composer.json b/extension/BuildPhpExtension/config/stubs/ast.composer.json deleted file mode 100644 index f0ff8fd..0000000 --- a/extension/BuildPhpExtension/config/stubs/ast.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-ast" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/csv.composer.json b/extension/BuildPhpExtension/config/stubs/csv.composer.json deleted file mode 100644 index a262331..0000000 --- a/extension/BuildPhpExtension/config/stubs/csv.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-csv" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/dbase.composer.json b/extension/BuildPhpExtension/config/stubs/dbase.composer.json deleted file mode 100644 index 577108e..0000000 --- a/extension/BuildPhpExtension/config/stubs/dbase.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-dbase" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/dio.composer.json b/extension/BuildPhpExtension/config/stubs/dio.composer.json deleted file mode 100644 index 51edae8..0000000 --- a/extension/BuildPhpExtension/config/stubs/dio.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-dio" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/igbinary.composer.json b/extension/BuildPhpExtension/config/stubs/igbinary.composer.json deleted file mode 100644 index b8b59b4..0000000 --- a/extension/BuildPhpExtension/config/stubs/igbinary.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-igbinary" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/maxminddb.composer.json b/extension/BuildPhpExtension/config/stubs/maxminddb.composer.json deleted file mode 100644 index 72a6f78..0000000 --- a/extension/BuildPhpExtension/config/stubs/maxminddb.composer.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "require": { - "libmaxminddb": "*" - }, - "php-ext": { - "configure-options": [ - { - "name": "with-maxminddb" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/memcache.composer.json b/extension/BuildPhpExtension/config/stubs/memcache.composer.json deleted file mode 100644 index d6d0d76..0000000 --- a/extension/BuildPhpExtension/config/stubs/memcache.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-memcache" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/parle.composer.json b/extension/BuildPhpExtension/config/stubs/parle.composer.json index b15e2b9..417fa40 100644 --- a/extension/BuildPhpExtension/config/stubs/parle.composer.json +++ b/extension/BuildPhpExtension/config/stubs/parle.composer.json @@ -5,7 +5,7 @@ "name": "enable-parle=shared" }, { - "name": "disable-parle-utf32" + "name": "disable-parle-utf32" } ] } diff --git a/extension/BuildPhpExtension/config/stubs/pcov.composer.json b/extension/BuildPhpExtension/config/stubs/pcov.composer.json deleted file mode 100644 index 7cd7a89..0000000 --- a/extension/BuildPhpExtension/config/stubs/pcov.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-pcov" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/pdo_sqlsrv.composer.json b/extension/BuildPhpExtension/config/stubs/pdo_sqlsrv.composer.json deleted file mode 100644 index ad9cc2a..0000000 --- a/extension/BuildPhpExtension/config/stubs/pdo_sqlsrv.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "with-pdo-sqlsrv" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/phalcon.composer.json b/extension/BuildPhpExtension/config/stubs/phalcon.composer.json index 394958c..6ffe918 100644 --- a/extension/BuildPhpExtension/config/stubs/phalcon.composer.json +++ b/extension/BuildPhpExtension/config/stubs/phalcon.composer.json @@ -1,6 +1,6 @@ { "require": { - "ext-psr": "*" + "ext-psr": "*" }, "php-ext": { "configure-options": [ diff --git a/extension/BuildPhpExtension/config/stubs/psr.composer.json b/extension/BuildPhpExtension/config/stubs/psr.composer.json deleted file mode 100644 index 81d88e4..0000000 --- a/extension/BuildPhpExtension/config/stubs/psr.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-psr" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/stomp.composer.json b/extension/BuildPhpExtension/config/stubs/scoutapm.composer.json similarity index 63% rename from extension/BuildPhpExtension/config/stubs/stomp.composer.json rename to extension/BuildPhpExtension/config/stubs/scoutapm.composer.json index 5378f09..a69af3f 100644 --- a/extension/BuildPhpExtension/config/stubs/stomp.composer.json +++ b/extension/BuildPhpExtension/config/stubs/scoutapm.composer.json @@ -1,11 +1,11 @@ { "require": { - "openssl": "*" + "libcurl": "*" }, "php-ext": { "configure-options": [ { - "name": "enable-stomp" + "name": "enable-scoutapm" } ] } diff --git a/extension/BuildPhpExtension/config/stubs/simdjson.composer.json b/extension/BuildPhpExtension/config/stubs/simdjson.composer.json deleted file mode 100644 index dd8e774..0000000 --- a/extension/BuildPhpExtension/config/stubs/simdjson.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-simdjson" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/sqlsrv.composer.json b/extension/BuildPhpExtension/config/stubs/sqlsrv.composer.json deleted file mode 100644 index 443a957..0000000 --- a/extension/BuildPhpExtension/config/stubs/sqlsrv.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-sqlsrv" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/timezonedb.composer.json b/extension/BuildPhpExtension/config/stubs/timezonedb.composer.json deleted file mode 100644 index a4fe4b7..0000000 --- a/extension/BuildPhpExtension/config/stubs/timezonedb.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-timezonedb" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/uopz.composer.json b/extension/BuildPhpExtension/config/stubs/uopz.composer.json deleted file mode 100644 index 66e885a..0000000 --- a/extension/BuildPhpExtension/config/stubs/uopz.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-uopz" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/xlswriter.composer.json b/extension/BuildPhpExtension/config/stubs/xlswriter.composer.json deleted file mode 100644 index f395f95..0000000 --- a/extension/BuildPhpExtension/config/stubs/xlswriter.composer.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "require": { - "zlib": "*" - }, - "php-ext": { - "configure-options": [ - { - "name": "with-xlswriter" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/yaconf.composer.json b/extension/BuildPhpExtension/config/stubs/yaconf.composer.json deleted file mode 100644 index 5889d3d..0000000 --- a/extension/BuildPhpExtension/config/stubs/yaconf.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-yaconf" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/yaf.composer.json b/extension/BuildPhpExtension/config/stubs/yaf.composer.json deleted file mode 100644 index a2719f6..0000000 --- a/extension/BuildPhpExtension/config/stubs/yaf.composer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "php-ext": { - "configure-options": [ - { - "name": "enable-yaf" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/yaml.composer.json b/extension/BuildPhpExtension/config/stubs/yaml.composer.json deleted file mode 100644 index 65a9784..0000000 --- a/extension/BuildPhpExtension/config/stubs/yaml.composer.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "require": { - "libyaml": "*" - }, - "php-ext": { - "configure-options": [ - { - "name": "with-yaml" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/stubs/yar.composer.json b/extension/BuildPhpExtension/config/stubs/yar.composer.json deleted file mode 100644 index 5a3400d..0000000 --- a/extension/BuildPhpExtension/config/stubs/yar.composer.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "require": { - "libcurl": "*", - "libssh2": "*", - "nghttp2": "*", - "openssl": "*" - }, - "php-ext": { - "configure-options": [ - { - "name": "enable-yar" - } - ] - } -} \ No newline at end of file diff --git a/extension/BuildPhpExtension/config/vs.json b/extension/BuildPhpExtension/config/vs.json index 086b8f1..7d6bc8f 100644 --- a/extension/BuildPhpExtension/config/vs.json +++ b/extension/BuildPhpExtension/config/vs.json @@ -25,7 +25,7 @@ }, "vs17": { "major": 14, - "minor": 39 + "minor": 42 } } } diff --git a/extension/BuildPhpExtension/patches/base58.ps1 b/extension/BuildPhpExtension/patches/base58.ps1 new file mode 100644 index 0000000..e280bef --- /dev/null +++ b/extension/BuildPhpExtension/patches/base58.ps1 @@ -0,0 +1 @@ +Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jasny/base58-php-ext/refs/heads/master/config.w32" -OutFile "config.w32" diff --git a/extension/BuildPhpExtension/patches/crypto.ps1 b/extension/BuildPhpExtension/patches/crypto.ps1 new file mode 100644 index 0000000..bd302e0 --- /dev/null +++ b/extension/BuildPhpExtension/patches/crypto.ps1 @@ -0,0 +1,2 @@ +Invoke-WebRequest -Uri "https://raw.githubusercontent.com/bukka/php-crypto/4516e22160a32ea09b2e547ceebd9a009fc6b597/crypto_cipher.c" -OutFile "crypto_cipher.c" +Invoke-WebRequest -Uri "https://raw.githubusercontent.com/bukka/php-crypto/4516e22160a32ea09b2e547ceebd9a009fc6b597/crypto_hash.c" -OutFile "crypto_hash.c" diff --git a/extension/BuildPhpExtension/private/Add-Dependencies.ps1 b/extension/BuildPhpExtension/private/Add-Dependencies.ps1 index 9d0e95f..18acf70 100644 --- a/extension/BuildPhpExtension/private/Add-Dependencies.ps1 +++ b/extension/BuildPhpExtension/private/Add-Dependencies.ps1 @@ -19,6 +19,7 @@ Function Add-Dependencies { process { Add-PhpDependencies -Config $Config Add-ExtensionDependencies -Config $Config + Add-Path -PathItem (Join-Path (Get-Location).Path ../deps/bin) Add-BuildTools -Config $Config Add-Extensions -Config $Config -Prefix $Prefix } diff --git a/extension/BuildPhpExtension/private/Add-Extension.ps1 b/extension/BuildPhpExtension/private/Add-Extension.ps1 index 8c906e4..f30b937 100644 --- a/extension/BuildPhpExtension/private/Add-Extension.ps1 +++ b/extension/BuildPhpExtension/private/Add-Extension.ps1 @@ -35,10 +35,12 @@ Function Add-Extension { } } } + $configW32Content = [string](Get-Content -Path "config.w32") + $argument = Get-ArgumentFromConfig $Extension $configW32Content $bat_content = @() $bat_content += "" $bat_content += "call phpize 2>&1" - $bat_content += "call configure --with-php-build=`"..\deps`" $($Config.options) --with-mp=`"disable`" --with-prefix=$Prefix 2>&1" + $bat_content += "call configure --with-php-build=`"..\deps`" $argument --with-mp=`"disable`" --with-prefix=$Prefix 2>&1" $bat_content += "nmake /nologo 2>&1" $bat_content += "exit %errorlevel%" Set-Content -Encoding "ASCII" -Path $Extension-task.bat -Value $bat_content diff --git a/extension/BuildPhpExtension/private/Add-Patches.ps1 b/extension/BuildPhpExtension/private/Add-Patches.ps1 new file mode 100644 index 0000000..4f80583 --- /dev/null +++ b/extension/BuildPhpExtension/private/Add-Patches.ps1 @@ -0,0 +1,29 @@ +Function Add-Patches { + <# + .SYNOPSIS + Add patches to the extension. + .PARAMETER Extension + The extension name. + #> + [OutputType()] + param( + [Parameter(Mandatory = $true, Position=0, HelpMessage='Extension')] + [ValidateNotNull()] + [ValidateLength(1, [int]::MaxValue)] + [string] $Extension + ) + begin { + } + process { + # Apply patches only for php/php-windows-builder and shivammathur/php-windows-builder + if($null -ne $env:GITHUB_REPOSITORY) { + if($env:GITHUB_REPOSITORY -eq 'php/php-windows-builder' -or $env:GITHUB_REPOSITORY -eq 'shivammathur/php-windows-builder') { + if(Test-Path -PATH $PSScriptRoot\..\patches\$Extension.ps1) { + . $PSScriptRoot\..\patches\$Extension.ps1 + } + } + } + } + end { + } +} \ No newline at end of file diff --git a/extension/BuildPhpExtension/private/Add-PhpDependencies.ps1 b/extension/BuildPhpExtension/private/Add-PhpDependencies.ps1 index 0a6d1ea..cf10fe6 100644 --- a/extension/BuildPhpExtension/private/Add-PhpDependencies.ps1 +++ b/extension/BuildPhpExtension/private/Add-PhpDependencies.ps1 @@ -17,14 +17,24 @@ Function Add-PhpDependencies { Add-StepLog "Adding libraries (core)" } $phpBaseUrl = 'https://downloads.php.net/~windows/php-sdk/deps' + $phpTrunkBaseUrl = "https://downloads.php.net/~windows/php-sdk/deps/$($Config.vs_version)/$($Config.arch)" $phpSeries = Invoke-WebRequest -Uri "$phpBaseUrl/series/packages-$($Config.php_version)-$($Config.vs_version)-$($Config.arch)-staging.txt" -UseBasicParsing + $phpTrunk = Invoke-WebRequest -Uri $phpTrunkBaseUrl -UseBasicParsing foreach ($library in $Config.php_libraries) { try { - $matches = $phpSeries.Content | Select-String -Pattern "(^|\n)$library.*" - if ($matches.Count -eq 0) { + $matchesFound = $phpSeries.Content | Select-String -Pattern "(^|\n)$library.*" + if ($matchesFound.Count -eq 0) { + foreach ($file in $phpTrunk.Links.Href) { + if ($file -match "^$library") { + $matchesFound = $file | Select-String -Pattern '.*' + break + } + } + } + if ($matchesFound.Count -eq 0) { throw "Failed to find $library" } - $file = $matches.Matches[0].Value.Trim() + $file = $matchesFound.Matches[0].Value.Trim() Invoke-WebRequest "$phpBaseUrl/$($Config.vs_version)/$($Config.arch)/$file" -OutFile $library Expand-Archive $library "../deps" Add-BuildLog tick "$library" "Added $($file -replace '\.zip$')" diff --git a/extension/BuildPhpExtension/private/Get-ArgumentFromConfig.ps1 b/extension/BuildPhpExtension/private/Get-ArgumentFromConfig.ps1 new file mode 100644 index 0000000..b268de5 --- /dev/null +++ b/extension/BuildPhpExtension/private/Get-ArgumentFromConfig.ps1 @@ -0,0 +1,50 @@ +Function Get-ArgumentFromConfig { + <# + .SYNOPSIS + Get the Libraries from the config.w32 file + .PARAMETER Extension + Extension Name + .PARAMETER ConfigW32Content + config.w32 content + #> + [OutputType()] + param ( + [Parameter(Mandatory = $true, Position=0, HelpMessage='Extension Name')] + [string] $Extension, + [Parameter(Mandatory = $true, Position=1, HelpMessage='config.w32 content')] + [string] $ConfigW32Content + ) + begin { + } + process { + $buildArgPrefix = $null; + $dashedExtension = $Extension -replace "_", "-" + if($configW32Content.contains("ARG_ENABLE(`"$dashedExtension`"") -or $configW32Content.contains("ARG_ENABLE('$dashedExtension'")) { + $buildArgPrefix = "enable" + } elseif($configW32Content.contains("ARG_WITH(`"$dashedExtension`"") -or $configW32Content.contains("ARG_WITH('$dashedExtension'")) { + $buildArgPrefix = "with" + } elseif($configW32Content.contains("ARG_ENABLE(`"$extension`"") -or $configW32Content.contains("ARG_ENABLE('$extension'")) { + $buildArgPrefix = "enable" + $dashedExtension = $Extension + } elseif($configW32Content.contains("ARG_WITH(`"$extension`"") -or $configW32Content.contains("ARG_WITH('$extension'")) { + $buildArgPrefix = "with" + $dashedExtension = $Extension + } + + $argValue=''; + if($ConfigW32Content.Contains("PHP_$($Extension.ToUpper())_SHARED")) { + $argValue = "shared" + } + + $arg='' + if($null -ne $buildArgPrefix) { + $arg="--$buildArgPrefix-$dashedExtension" + } + if($argValue -ne '') { + $arg="$arg=$argValue" + } + return $arg + } + end { + } +} \ No newline at end of file diff --git a/extension/BuildPhpExtension/private/Get-Extension.ps1 b/extension/BuildPhpExtension/private/Get-Extension.ps1 index 2fd14ca..30c48e2 100644 --- a/extension/BuildPhpExtension/private/Get-Extension.ps1 +++ b/extension/BuildPhpExtension/private/Get-Extension.ps1 @@ -51,6 +51,14 @@ function Get-Extension { } } + $patches = $False + if(Test-Path -PATH $PSScriptRoot\..\patches\$extension.ps1) { + if((Get-Content $PSScriptRoot\..\patches\$extension.ps1).Contains('config.w32')) { + Add-Patches $extension + $patches = $True + } + } + $configW32 = Get-ChildItem (Get-Location).Path -Recurse -Filter "config.w32" -ErrorAction SilentlyContinue if($null -eq $configW32) { throw "No config.w32 found" @@ -74,13 +82,8 @@ function Get-Extension { } } - # Apply patches only for php/php-windows-builder and shivammathur/php-windows-builder - if($null -ne $env:GITHUB_REPOSITORY) { - if($env:GITHUB_REPOSITORY -eq 'php/php-windows-builder' -or $env:GITHUB_REPOSITORY -eq 'shivammathur/php-windows-builder') { - if(Test-Path -PATH $PSScriptRoot\..\patches\$name.ps1) { - . $PSScriptRoot\..\patches\$name.ps1 - } - } + if(!$patches) { + Add-Patches $name } Add-BuildLog tick $name "Fetched $name extension" return $name diff --git a/extension/BuildPhpExtension/private/Get-ExtensionConfig.ps1 b/extension/BuildPhpExtension/private/Get-ExtensionConfig.ps1 index 69e9fdf..4810ced 100644 --- a/extension/BuildPhpExtension/private/Get-ExtensionConfig.ps1 +++ b/extension/BuildPhpExtension/private/Get-ExtensionConfig.ps1 @@ -124,6 +124,42 @@ Function Get-ExtensionConfig { } } + $configW32Content = [string](Get-Content -Path "config.w32") + if($configW32Content.contains('PATH_PROG')) { + [regex]::Matches($configW32Content, 'PATH_PROG\(([''"])([^''"]+)\1') | ForEach-Object { + $config.build_tools += $_.Groups[2].Value + } + } + if($configW32Content.contains('PYTHONHOME')) { + $config.build_tools += "python" + } + + if($env:AUTO_DETECT_ARGS -eq 'true') { + $argument = Get-ArgumentFromConfig $Extension $configW32Content + $argumentKey = $argument.Split("=")[0] + if($null -ne $argument -and -not($config.options.contains($argumentKey))) { + $config.options += " $argument" + } + } + + if($env:AUTO_DETECT_LIBS -eq 'true') { + $detectedLibraries = Get-LibrariesFromConfig $Extension $VsVersion $Arch $configW32Content + if($null -ne $detectedLibraries) { + $LibrariesList = $Libraries + $Libraries = $detectedLibraries.Split(" ") + $LibrariesList | ForEach-Object { + $libraryName = $_ + $_ -Match '^(.+?)-\d|' | Out-Null + if($Matches.Count -gt 1) { + $libraryName = $Matches[1] + } + if (-not(($Libraries -Join ' ').Contains($libraryName))) { + $Libraries += $_ + } + } + } + } + if($Libraries.Count -gt 0) { $phpSeries = Invoke-WebRequest -Uri "https://downloads.php.net/~windows/php-sdk/deps/$VsVersion/$Arch" $extensionSeries = Invoke-WebRequest -Uri "https://downloads.php.net/~windows/pecl/deps" @@ -172,16 +208,6 @@ Function Get-ExtensionConfig { } } - $configW32Content = [string](Get-Content -Path "config.w32") - if($configW32Content.contains('PATH_PROG')) { - [regex]::Matches($configW32Content, 'PATH_PROG\(([''"])([^''"]+)\1') | ForEach-Object { - $config.build_tools += $_.Groups[2].Value - } - } - if($configW32Content.contains('PYTHONHOME')) { - $config.build_tools += "python" - } - $config.build_directory = if ($Arch -eq "x64") { "x64\" } else { "" } $config.build_directory += "Release" if ($Ts -eq "ts") { $config.build_directory += "_TS" } diff --git a/extension/BuildPhpExtension/private/Get-LibrariesFromConfig.ps1 b/extension/BuildPhpExtension/private/Get-LibrariesFromConfig.ps1 new file mode 100644 index 0000000..ac2c9e1 --- /dev/null +++ b/extension/BuildPhpExtension/private/Get-LibrariesFromConfig.ps1 @@ -0,0 +1,128 @@ +Function Get-LibrariesFromConfig { + <# + .SYNOPSIS + Get the Libraries from the config.w32 file + .PARAMETER Extension + Extension + .PARAMETER VsVersion + Visual Studio Version + .PARAMETER Arch + Architecture + .PARAMETER ConfigW32Content + config.w32 content + #> + [OutputType()] + param ( + [Parameter(Mandatory = $true, Position=0, HelpMessage='Extension')] + [string] $Extension, + [Parameter(Mandatory = $true, Position=1, HelpMessage='Visual Studio Version')] + [string] $VsVersion, + [Parameter(Mandatory = $true, Position=2, HelpMessage='Architecture')] + [string] $Arch, + [Parameter(Mandatory = $true, Position=3, HelpMessage='config.w32 content')] + [string] $ConfigW32Content + ) + begin { + $jsonPath = [System.IO.Path]::Combine($PSScriptRoot, '..\config\vs.json') + } + process { + $jsonData = ( + Invoke-WebRequest -Uri "https://downloads.php.net/~windows/pecl/deps/libmapping.json" + ).Content | ConvertFrom-Json + + $phpSeries = (Invoke-WebRequest -Uri "https://downloads.php.net/~windows/php-sdk/deps/$VsVersion/$Arch").Content.ToLower() + + Function Find-Library { + param ( + [Parameter(Mandatory=$true, Position=0)] + [string]$MatchString, + [Parameter(Mandatory=$true, Position=1)] + [string[]]$VsVersions + ) + foreach ($vsVersion in $VsVersions) { + foreach ($vsVersionData in $JsonData.PSObject.Properties) { + if($vsVersionData.Name -eq $VsVersion) { + foreach ($archData in $vsVersionData.Value.PSObject.Properties) { + if($archData.Name -eq $Arch) { + foreach ($libs in $archData.Value.PSObject.Properties) { + if ($libs.Value -match ($MatchString.Replace('*', '.*'))) { + $libs.Name -Match '^(.+?)-\d' | Out-Null + if(!$phpSeries.contains($matches[1].ToLower())) { + $libs.Name -Match '^(.+?-\d)' | Out-Null + } + return $matches[1] + } + } + } + } + } + } + } + return $null + } + + $jsonContent = Get-Content -Path $jsonPath -Raw + $VsConfig = ConvertFrom-Json -InputObject $jsonContent + $VsVersions = @($VsVersion) + $VsVersions += $($VsConfig.vs | Get-Member -MemberType *Property).Name | Where-Object { + # vs15 and above builds are compatible. + ($_ -lt $VsVersion -and $_ -ge "vc15") + } + + $foundItems = @() + $libraryFilesFound = @() + [regex]::Matches($ConfigW32Content, 'CHECK_LIB\(["'']([^"'']+)["'']|["'']([^"'']+.lib)["'']|(\w+\.lib)') | ForEach-Object { + $_.Groups[1].Value.Split(';') + ($_.Groups[2].Value -Split '[^\w\.]') + ($_.Groups[3].Value -Split '[^\w\.]') | ForEach-Object { + $libraryFilesFound += $_ + } + } + $libraryFilesFound | Select-Object -Unique | ForEach-Object { + if($_) { + switch ($_) { + libeay32.lib { $library = "openssl" } + ssleay32.lib { $library = "openssl" } + Default { $library = Find-Library $_ $VsVersions } + } + if($library -and (-not($foundItems.Contains($library)))) { + $foundItems += $library.ToLower() + } + } + } + + # Exceptions + # Remove libsasl if the extension is mongodb + if($Extension -eq "mongodb") { + $foundItems = $foundItems | Where-Object {$_ -notmatch "libsasl.*"} + } + # Add zlib if the extension is memcached + if($Extension -eq "memcached") { + $foundItems += "zlib" + } + + $highestVersions = @{} + + foreach ($item in $foundItems) { + if ($item -match '^(.*?)-(\d+)$') { + $libraryName, $version = $matches[1], $matches[2] + if (-not $highestVersions.ContainsKey($libraryName) -or $highestVersions[$libraryName] -lt $version) { + $highestVersions[$libraryName] = $version + } + } else { + $highestVersions[$item] = -1 + } + } + + $finalItems = @() + foreach ($library in $highestVersions.Keys) { + if ($highestVersions[$library] -eq -1) { + $finalItems += $library + } else { + $finalItems += "$library-" + $highestVersions[$library] + } + } + + return $finalItems + } + end { + } +} \ No newline at end of file diff --git a/extension/action.yml b/extension/action.yml index 93e9a26..7f916eb 100644 --- a/extension/action.yml +++ b/extension/action.yml @@ -42,7 +42,7 @@ inputs: test-opcache-mode: description: Test opcache mode required: false - default: 'on' + default: 'off' build-directory: description: Directory to build the extension in required: false @@ -66,6 +66,8 @@ runs: TEST_OPCACHE_MODE: ${{inputs.test-opcache-mode}} BUILD_DIRECTORY: ${{inputs.build-directory}} AUTH_TOKEN: ${{inputs.auth-token}} + AUTO_DETECT_ARGS: ${{env.auto-detect-args}} + AUTO_DETECT_LIBS: ${{env.auto-detect-libs}} run: | Import-Module ${{ github.action_path }}\BuildPhpExtension -Force Invoke-PhpBuildExtension -ExtensionUrl "${{inputs.extension-url}}" `