[3.0] Refactor extensions (#1038)

This commit is contained in:
Jerry Ma
2026-03-20 16:05:35 +08:00
committed by GitHub
209 changed files with 5649 additions and 566 deletions

View File

@@ -46,6 +46,10 @@ on:
description: Prefer pre-built binaries (reduce build time)
type: boolean
default: true
with-suggested-libs:
description: Build with suggested libs
type: boolean
default: true
debug:
description: Show full build logs
type: boolean
@@ -86,6 +90,10 @@ on:
description: Prefer pre-built binaries (reduce build time)
type: boolean
default: true
with-suggested-libs:
description: Include suggested libs
type: boolean
default: false
debug:
description: Show full build logs
type: boolean
@@ -157,6 +165,9 @@ jobs:
if [ ${{ inputs.prefer-pre-built }} == true ]; then
DOWN_CMD="$DOWN_CMD --prefer-pre-built"
fi
if [ ${{ inputs.with-suggested-libs }} == true ]; then
BUILD_CMD="$BUILD_CMD --with-suggested-libs"
fi
if [ ${{ inputs.build-cli }} == true ]; then
BUILD_CMD="$BUILD_CMD --build-cli"
fi
@@ -202,6 +213,14 @@ jobs:
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# Upload debug logs
- if: ${{ inputs.debug && failure() }}
name: "Upload build logs on failure"
uses: actions/upload-artifact@v4
with:
name: spc-logs-${{ inputs.php-version }}-${{ inputs.os }}
path: log/*.log
# Upload cli executable
- if: ${{ inputs.build-cli == true }}
name: "Upload PHP cli SAPI"

View File

@@ -29,6 +29,10 @@ on:
description: prefer pre-built binaries (reduce build time)
type: boolean
default: true
with-suggested-libs:
description: Build with suggested libs
type: boolean
default: true
debug:
description: enable debug logs
type: boolean

6
.gitignore vendored
View File

@@ -33,6 +33,9 @@ packlib_files.txt
.php-cs-fixer.cache
.phpunit.result.cache
# doctor cache fallback (when ~/.cache/spc/ is not writable)
.spc-doctor.lock
# exclude self-runtime
/bin/*
!/bin/spc*
@@ -61,3 +64,6 @@ log/
# spc.phar
spc.phar
spc.exe
# dumped files from StaticPHP v3
/dump-*.json

View File

@@ -1,4 +1,4 @@
# static-php-cli
# StaticPHP
[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-moccasin?style=flat-square)](README.md)
[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-moccasin?style=flat-square)](README-zh.md)
@@ -6,7 +6,7 @@
[![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)
**static-php-cli** 是一个用于构建静态、独立 PHP 运行时的强大工具,支持众多流行扩展
**StaticPHP** 是一个用于构建静态编译可执行文件(包括 PHP、扩展等的强大工具
## 特性
@@ -80,7 +80,7 @@ download-options:
### 3. 静态 PHP 使用
现在您可以将 static-php-cli 构建的二进制文件复制到另一台机器上,无需依赖即可运行:
现在您可以将 StaticPHP 构建的二进制文件复制到另一台机器上,无需依赖即可运行:
```
# php-cli
@@ -97,7 +97,7 @@ buildroot/bin/php-fpm -v
## 文档
当前 README 包含基本用法。有关 static-php-cli 的所有功能,
当前 README 包含基本用法。有关 StaticPHP 的所有功能,
请访问 <https://static-php.dev>。
## 直接下载

View File

@@ -1,4 +1,4 @@
# static-php-cli
# StaticPHP
[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-moccasin?style=flat-square)](README-zh.md)
[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-moccasin?style=flat-square)](README.md)
@@ -6,8 +6,7 @@
[![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml)
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE)
**static-php-cli** is a powerful tool designed for building static, standalone PHP runtime
with popular extensions.
**StaticPHP** is a powerful tool designed for building portable executables including PHP, extensions, and more.
## Features
@@ -81,7 +80,7 @@ Run command:
### 3. Static PHP usage
Now you can copy binaries built by static-php-cli to another machine and run with no dependencies:
Now you can copy binaries built by StaticPHP to another machine and run with no dependencies:
```
# php-cli
@@ -98,7 +97,7 @@ buildroot/bin/php-fpm -v
## Documentation
The current README contains basic usage. For all the features of static-php-cli,
The current README contains basic usage. For all the features of StaticPHP,
see <https://static-php.dev> .
## Direct Download

View File

@@ -0,0 +1,9 @@
ncurses:
binary: hosted
metadata:
license-files:
- COPYING
source:
type: filelist
url: 'https://ftp.gnu.org/pub/gnu/ncurses/'
regex: '/href="(?<file>ncurses-(?<version>[^"]+)\.tar\.gz)"/'

View File

@@ -5,3 +5,7 @@ php-src:
license: PHP-3.01
source:
type: php-release
domain: 'https://www.php.net'
source-mirror:
type: php-release
domain: 'https://phpmirror.static-php.dev'

View File

@@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
use StaticPHP\Artifact\Downloader\Type\BitBucketTag;
use StaticPHP\Artifact\Downloader\Type\DownloadTypeInterface;
use StaticPHP\Artifact\Downloader\Type\FileList;
use StaticPHP\Artifact\Downloader\Type\Git;
use StaticPHP\Artifact\Downloader\Type\GitHubRelease;
use StaticPHP\Artifact\Downloader\Type\GitHubTarball;
use StaticPHP\Artifact\Downloader\Type\HostedPackageBin;
use StaticPHP\Artifact\Downloader\Type\LocalDir;
use StaticPHP\Artifact\Downloader\Type\PhpRelease;
use StaticPHP\Artifact\Downloader\Type\PIE;
use StaticPHP\Artifact\Downloader\Type\Url;
/* @return array<string, DownloadTypeInterface> */
return [
'bitbuckettag' => BitBucketTag::class,
'filelist' => FileList::class,
'git' => Git::class,
'ghrel' => GitHubRelease::class,
'ghtar' => GitHubTarball::class,
'ghtagtar' => GitHubTarball::class,
'local' => LocalDir::class,
'pie' => PIE::class,
'url' => Url::class,
'php-release' => PhpRelease::class,
'hosted' => HostedPackageBin::class,
];

View File

@@ -121,6 +121,8 @@ SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --disable
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
; EXTRA_CFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fPIE ${SPC_DEFAULT_C_FLAGS}"
; EXTRA_CXXFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CXXFLAGS="-g -fstack-protector-strong -fno-ident -fPIE ${SPC_DEFAULT_CXX_FLAGS}"
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
@@ -132,6 +134,8 @@ OPENSSLDIR=""
; build target: macho or macho (possibly we could support macho-universal in the future)
; Currently we do not support universal and cross-compilation for macOS.
SPC_TARGET=native-macos
; Whether to use brew version of llvm or system version (valid options: 'system', 'brew', default: 'system')
SPC_USE_LLVM=system
; compiler environments (default value is defined by selected toolchain)
CC=${SPC_DEFAULT_CC}
CXX=${SPC_DEFAULT_CXX}
@@ -155,5 +159,9 @@ SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
; EXTRA_CFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Werror=unknown-warning-option ${SPC_DEFAULT_C_FLAGS}"
; EXTRA_CXXFLAGS for `configure` and `make` php
SPC_CMD_VAR_PHP_MAKE_EXTRA_CXXFLAGS="-g -fstack-protector-strong -fno-ident -fpie -Werror=unknown-warning-option ${SPC_DEFAULT_CXX_FLAGS}"
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.dylib
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
; minimum compatible macOS version (LLVM vars, availability not guaranteed)
MACOSX_DEPLOYMENT_TARGET=12.0

View File

@@ -373,6 +373,15 @@
],
"static-libs-windows": [
"avif.lib"
],
"lib-depends": [
"libaom"
],
"lib-suggests": [
"libwebp",
"libjpeg",
"libxml2",
"libpng"
]
},
"libcares": {

View File

@@ -1,5 +1,152 @@
ext-bcmath:
type: php-extension
ext-bz2:
type: php-extension
depends:
- bzip2
php-extension:
arg-type@unix: with-path
arg-type@windows: with
ext-calendar:
type: php-extension
ext-ctype:
type: php-extension
ext-curl:
type: php-extension
depends:
- curl
depends@windows:
- ext-zlib
- ext-openssl
php-extension:
arg-type: with
ext-dba:
type: php-extension
suggests:
- qdbm
php-extension:
arg-type: custom
ext-dom:
type: php-extension
depends:
- libxml2
- ext-xml
php-extension:
arg-type: '--enable-dom@shared_suffix@ --with-libxml=@build_root_path@'
arg-type@windows: with
ext-exif:
type: php-extension
ext-ffi:
type: php-extension
depends@unix:
- libffi
php-extension:
arg-type@unix: '--with-ffi=@shared_suffix@ --enable-zend-signals'
arg-type@windows: with
ext-fileinfo:
type: php-extension
ext-filter:
type: php-extension
ext-ftp:
type: php-extension
suggests:
- ext-openssl
ext-gd:
type: php-extension
depends:
- zlib
- libpng
- ext-zlib
suggests:
- libavif
- libwebp
- libjpeg
- freetype
php-extension:
arg-type: custom
ext-gettext:
type: php-extension
depends:
- gettext
php-extension:
arg-type: with-path
ext-gmp:
type: php-extension
depends:
- gmp
php-extension:
arg-type: with-path
ext-iconv:
type: php-extension
depends@unix:
- libiconv
php-extension:
arg-type@unix: with-path
arg-type@windows: with
ext-intl:
type: php-extension
depends@unix:
- icu
ext-ldap:
type: php-extension
depends:
- ldap
suggests:
- gmp
- libsodium
- ext-openssl
php-extension:
arg-type: with-path
ext-libxml:
type: php-extension
depends:
- ext-xml
php-extension:
build-with-php: true
build-shared: false
arg-type: none
ext-mbregex:
type: php-extension
depends:
- onig
- ext-mbstring
php-extension:
arg-type: custom
build-shared: false
build-static: true
display-name: mbstring
ext-mbstring:
type: php-extension
php-extension:
arg-type: custom
ext-mysqli:
type: php-extension
depends:
- ext-mysqlnd
php-extension:
arg-type: with
build-with-php: true
ext-mysqlnd:
type: php-extension
depends:
- zlib
php-extension:
arg-type@unix: enable
arg-type@windows: with
build-with-php: true
ext-odbc:
type: php-extension
depends@unix:
- unixodbc
php-extension:
arg-type@unix: '--with-unixODBC@shared_path_suffix@'
ext-opcache:
type: php-extension
php-extension:
arg-type@unix: custom
arg-type@windows: enable
zend-extension: true
display-name: 'Zend Opcache'
ext-openssl:
type: php-extension
depends:
@@ -10,6 +157,185 @@ ext-openssl:
arg-type: custom
arg-type@windows: with
build-with-php: true
ext-password-argon2:
type: php-extension
depends:
- libargon2
- ext-openssl
php-extension:
arg-type: custom
display-name: ''
ext-pcntl:
type: php-extension
ext-pdo:
type: php-extension
ext-pdo_mysql:
type: php-extension
depends:
- ext-pdo
- ext-mysqlnd
php-extension:
arg-type: with
ext-pdo_odbc:
type: php-extension
depends:
- ext-pdo
- ext-odbc
depends@unix:
- unixodbc
- ext-pdo
- ext-odbc
php-extension:
arg-type: custom
ext-pdo_pgsql:
type: php-extension
depends@unix:
- ext-pdo
- ext-pgsql
- postgresql
php-extension:
arg-type@unix: with-path
arg-type@windows: '--with-pdo-pgsql=yes'
ext-pdo_sqlite:
type: php-extension
depends:
- ext-pdo
- ext-sqlite3
- sqlite
php-extension:
arg-type: with
ext-pgsql:
type: php-extension
depends@unix:
- postgresql
php-extension:
arg-type: custom
ext-phar:
type: php-extension
depends:
- zlib
ext-posix:
type: php-extension
ext-readline:
type: php-extension
depends:
- libedit
php-extension:
support:
Windows: wip
BSD: wip
arg-type: '--with-libedit --without-readline'
build-shared: false
build-static: true
ext-session:
type: php-extension
ext-shmop:
type: php-extension
php-extension:
build-with-php: true
ext-simplexml:
type: php-extension
depends:
- ext-xml
php-extension:
arg-type@unix: '--enable-simplexml@shared_suffix@ --with-libxml=@build_root_path@'
arg-type@windows: with
build-with-php: true
ext-snmp:
type: php-extension
depends:
- net-snmp
php-extension:
arg-type: with
ext-soap:
type: php-extension
depends:
- ext-xml
- ext-session
php-extension:
arg-type@unix: '--enable-soap@shared_suffix@ --with-libxml=@build_root_path@'
arg-type@windows: with
build-with-php: true
ext-sockets:
type: php-extension
ext-sodium:
type: php-extension
depends:
- libsodium
php-extension:
arg-type: with
ext-sqlite3:
type: php-extension
depends:
- sqlite
php-extension:
arg-type@unix: with-path
arg-type@windows: with
build-with-php: true
ext-sysvmsg:
type: php-extension
php-extension:
support:
Windows: 'no'
BSD: wip
ext-sysvsem:
type: php-extension
php-extension:
support:
Windows: 'no'
BSD: wip
ext-sysvshm:
type: php-extension
php-extension:
support:
BSD: wip
ext-tidy:
type: php-extension
depends:
- tidy
php-extension:
support:
Windows: wip
BSD: wip
arg-type: with-path
ext-tokenizer:
type: php-extension
php-extension:
build-with-php: true
ext-xml:
type: php-extension
depends:
- libxml2
depends@windows:
- libxml2
- ext-iconv
php-extension:
arg-type: '--enable-xml@shared_suffix@ --with-libxml=@build_root_path@'
arg-type@windows: with
build-with-php: true
ext-xmlreader:
type: php-extension
depends:
- libxml2
php-extension:
arg-type: '--enable-xmlreader@shared_suffix@ --with-libxml=@build_root_path@'
build-with-php: true
ext-xmlwriter:
type: php-extension
depends:
- libxml2
php-extension:
arg-type: '--enable-xmlwriter@shared_suffix@ --with-libxml=@build_root_path@'
build-with-php: true
ext-xsl:
type: php-extension
depends:
- libxslt
- ext-xml
- ext-dom
php-extension:
arg-type: with-path
build-with-php: true
ext-zlib:
type: php-extension
depends:

View File

@@ -2,10 +2,8 @@ ext-amqp:
type: php-extension
artifact:
source:
type: url
url: 'https://pecl.php.net/get/amqp'
extract: php-src/ext/amqp
filename: amqp.tgz
type: pecl
name: amqp
metadata:
license-files: [LICENSE]
license: PHP-3.01

View File

@@ -0,0 +1,9 @@
ext-apcu:
type: php-extension
artifact:
source:
type: pecl
name: APCu
metadata:
license-files: [LICENSE]
license: PHP-3.01

View File

@@ -0,0 +1,9 @@
ext-ast:
type: php-extension
artifact:
source:
type: pecl
name: ast
metadata:
license-files: [LICENSE]
license: BSD-3-Clause

View File

@@ -0,0 +1,13 @@
ext-brotli:
type: php-extension
artifact:
source:
type: git
extract: php-src/ext/brotli
rev: master
url: 'https://github.com/kjdev/php-ext-brotli'
metadata:
license-files: [LICENSE]
license: MIT
depends:
- brotli

View File

@@ -0,0 +1,9 @@
ext-dio:
type: php-extension
artifact:
source:
type: pecl
name: dio
metadata:
license-files: [LICENSE]
license: PHP-3.01

View File

@@ -0,0 +1,9 @@
ext-ds:
type: php-extension
artifact:
source:
type: pecl
name: ds
metadata:
license-files: [LICENSE]
license: MIT

13
config/pkg/ext/ext-ev.yml Normal file
View File

@@ -0,0 +1,13 @@
ext-ev:
type: php-extension
artifact:
source:
type: pecl
name: ev
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- ext-sockets
php-extension:
arg-type@windows: with

View File

@@ -0,0 +1,19 @@
ext-event:
type: php-extension
artifact:
source:
type: url
url: 'https://bitbucket.org/osmanov/pecl-event/get/3.1.4.tar.gz'
extract: php-src/ext/event
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- libevent
- ext-openssl
suggests:
- ext-sockets
php-extension:
support:
Windows: wip
arg-type: custom

View File

@@ -0,0 +1,9 @@
ext-excimer:
type: php-extension
artifact:
source:
type: pecl
name: excimer
metadata:
license-files: [LICENSE]
license: PHP-3.01

View File

@@ -3,3 +3,5 @@ ext-glfw:
artifact: glfw
depends:
- glfw
php-extension:
arg-type@unix: '--enable-glfw --with-glfw-dir=@build_root_path@'

View File

@@ -0,0 +1,12 @@
ext-gmssl:
type: php-extension
artifact:
source:
type: ghtar
repo: gmssl/GmSSL-PHP
extract: php-src/ext/gmssl
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- gmssl

View File

@@ -0,0 +1,14 @@
ext-grpc:
type: php-extension
artifact:
source:
type: pecl
name: grpc
metadata:
license-files: [LICENSE]
license: Apache-2.0
depends:
- grpc
lang: cpp
php-extension:
arg-type@unix: enable-path

View File

@@ -0,0 +1,12 @@
ext-igbinary:
type: php-extension
artifact:
source:
type: pecl
name: igbinary
metadata:
license-files: [COPYING]
license: BSD-3-Clause
suggests:
- ext-session
- ext-apcu

View File

@@ -0,0 +1,13 @@
ext-imagick:
type: php-extension
artifact:
source:
type: pecl
name: imagick
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- imagemagick
php-extension:
arg-type: custom

View File

@@ -0,0 +1,15 @@
ext-imap:
type: php-extension
artifact:
source:
type: pecl
name: imap
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- imap
suggests:
- ext-openssl
php-extension:
arg-type: custom

View File

@@ -0,0 +1,9 @@
ext-inotify:
type: php-extension
artifact:
source:
type: pecl
name: inotify
metadata:
license-files: [LICENSE]
license: PHP-3.01

View File

@@ -0,0 +1,15 @@
ext-lz4:
type: php-extension
artifact:
source:
type: ghtagtar
repo: kjdev/php-ext-lz4
extract: php-src/ext/lz4
metadata:
license-files: [LICENSE]
license: MIT
depends:
- liblz4
php-extension:
arg-type@unix: '--enable-lz4=@shared_suffix@ --with-lz4-includedir=@build_root_path@'
arg-type@windows: '--enable-lz4'

View File

@@ -0,0 +1,13 @@
ext-maxminddb:
type: php-extension
artifact:
source:
type: pecl
name: maxminddb
metadata:
license-files: [LICENSE]
license: Apache-2.0
depends:
- libmaxminddb
php-extension:
arg-type: with

View File

@@ -1,10 +0,0 @@
ext-mbregex:
type: php-extension
depends:
- onig
- ext-mbstring
php-extension:
arg-type: custom
build-shared: false
build-static: true
display-name: mbstring

View File

@@ -1,4 +0,0 @@
ext-mbstring:
type: php-extension
php-extension:
arg-type: custom

View File

@@ -0,0 +1,14 @@
ext-memcache:
type: php-extension
artifact:
source:
type: pecl
name: memcache
metadata:
license-files: [LICENSE]
license: PHP-3.0
depends:
- ext-zlib
- ext-session
php-extension:
arg-type: '--enable-memcache@shared_suffix@ --with-zlib-dir=@build_root_path@'

View File

@@ -0,0 +1,23 @@
ext-memcached:
type: php-extension
artifact:
source:
type: pecl
name: memcached
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- libmemcached
depends@unix:
- libmemcached
- fastlz
- ext-session
- ext-zlib
suggests:
- zstd
- ext-igbinary
- ext-msgpack
- ext-session
php-extension:
arg-type: '--enable-memcached@shared_suffix@ --with-zlib-dir=@build_root_path@'

View File

@@ -0,0 +1,21 @@
ext-mongodb:
type: php-extension
artifact:
source:
type: ghrel
repo: mongodb/mongo-php-driver
match: mongodb.+\.tgz
extract: php-src/ext/mongodb
metadata:
license-files: [LICENSE]
license: PHP-3.01
suggests:
- icu
- openssl
- zstd
- zlib
frameworks:
- CoreFoundation
- Security
php-extension:
arg-type: custom

View File

@@ -0,0 +1,14 @@
ext-msgpack:
type: php-extension
artifact:
source:
type: pecl
name: msgpack
metadata:
license-files: [LICENSE]
license: BSD-3-Clause
depends:
- ext-session
php-extension:
arg-type@unix: with
arg-type@windows: enable

View File

@@ -0,0 +1,18 @@
ext-mysqlnd_ed25519:
type: php-extension
artifact:
source:
type: pie
repo: mariadb/mysqlnd_ed25519
extract: php-src/ext/mysqlnd_ed25519
metadata:
license-files: [LICENSE]
license: BSD-3-Clause
depends:
- ext-mysqlnd
- libsodium
suggests:
- openssl
php-extension:
arg-type: '--with-mysqlnd_ed25519=@shared_suffix@'
build-static: false

View File

@@ -0,0 +1,17 @@
ext-mysqlnd_parsec:
type: php-extension
artifact:
source:
type: pie
repo: mariadb/mysqlnd_parsec
extract: php-src/ext/mysqlnd_parsec
metadata:
license-files: [LICENSE]
license: BSD-3-Clause
depends:
- ext-mysqlnd
- libsodium
- openssl
php-extension:
arg-type: '--enable-mysqlnd_parsec'
build-static: false

View File

@@ -0,0 +1,9 @@
ext-opentelemetry:
type: php-extension
artifact:
source:
type: pecl
name: opentelemetry
metadata:
license-files: [LICENSE]
license: Apache-2.0

View File

@@ -0,0 +1,9 @@
ext-parallel:
type: php-extension
artifact:
source:
type: pecl
name: parallel
metadata:
license-files: [LICENSE]
license: PHP-3.01

View File

@@ -0,0 +1,12 @@
ext-pcov:
type: php-extension
artifact:
source:
type: pecl
name: pcov
metadata:
license-files: [LICENSE]
license: PHP-3.01
php-extension:
build-static: false
build-shared: true

View File

@@ -0,0 +1,14 @@
ext-pdo_sqlsrv:
type: php-extension
artifact:
source:
type: pecl
name: pdo_sqlsrv
metadata:
license-files: [LICENSE]
license: MIT
depends:
- ext-pdo
- ext-sqlsrv
php-extension:
arg-type: with

View File

@@ -1,4 +0,0 @@
ext-phar:
type: php-extension
depends:
- zlib

View File

@@ -0,0 +1,9 @@
ext-protobuf:
type: php-extension
artifact:
source:
type: pecl
name: protobuf
metadata:
license-files: [LICENSE]
license: BSD-3-Clause

View File

@@ -0,0 +1,12 @@
ext-rar:
type: php-extension
artifact:
source:
type: git
url: 'https://github.com/static-php/php-rar.git'
rev: issue-php82
extract: php-src/ext/rar
metadata:
license-files: [LICENSE]
license: PHP-3.01
lang: cpp

View File

@@ -0,0 +1,15 @@
ext-rdkafka:
type: php-extension
artifact:
source:
type: ghtar
repo: arnaud-lb/php-rdkafka
extract: php-src/ext/rdkafka
metadata:
license-files: [LICENSE]
license: MIT
depends:
- librdkafka
lang: cpp
php-extension:
arg-type: custom

View File

@@ -1,11 +0,0 @@
ext-readline:
type: php-extension
depends:
- libedit
php-extension:
support:
Windows: wip
BSD: wip
arg-type: with-path
build-shared: false
build-static: true

View File

@@ -0,0 +1,21 @@
ext-redis:
type: php-extension
artifact:
source:
type: pecl
name: redis
metadata:
license-files: [LICENSE]
license: PHP-3.01
suggests:
- ext-session
- ext-igbinary
- ext-msgpack
suggests@unix:
- ext-session
- ext-igbinary
- ext-msgpack
- zstd
- liblz4
php-extension:
arg-type: custom

View File

@@ -0,0 +1,10 @@
ext-simdjson:
type: php-extension
artifact:
source:
type: pecl
name: simdjson
metadata:
license-files: [LICENSE]
license: Apache-2.0
lang: cpp

View File

@@ -0,0 +1,18 @@
ext-snappy:
type: php-extension
artifact:
source:
type: git
url: 'https://github.com/kjdev/php-ext-snappy'
rev: master
extract: php-src/ext/snappy
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- snappy
suggests:
- ext-apcu
lang: cpp
php-extension:
arg-type@unix: '--enable-snappy --with-snappy-includedir=@build_root_path@'

View File

@@ -0,0 +1,14 @@
ext-spx:
type: php-extension
artifact:
source:
type: pie
repo: noisebynorthwest/php-spx
extract: php-src/ext/spx
metadata:
license-files: [LICENSE]
license: GPL-3.0-or-later
depends:
- ext-zlib
php-extension:
arg-type: '--enable-SPX@shared_suffix@'

View File

@@ -0,0 +1,15 @@
ext-sqlsrv:
type: php-extension
artifact:
source:
type: pecl
name: sqlsrv
metadata:
license-files: [LICENSE]
license: MIT
depends@linux:
- unixodbc
- ext-pcntl
depends@macos:
- unixodbc
lang: cpp

View File

@@ -0,0 +1,15 @@
ext-ssh2:
type: php-extension
artifact:
source:
type: pecl
name: ssh2
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- libssh2
- ext-openssl
- ext-zlib
php-extension:
arg-type: with-path

View File

@@ -0,0 +1,72 @@
ext-swoole:
type: php-extension
artifact:
source:
type: ghtar
repo: swoole/swoole-src
extract: php-src/ext/swoole
match: v6\.+
prefer-stable: true
metadata:
license-files: [LICENSE]
license: Apache-2.0
depends:
- libcares
- brotli
- nghttp2
- zlib
- ext-openssl
- ext-curl
suggests:
- zstd
- ext-sockets
- ext-swoole-hook-pgsql
- ext-swoole-hook-mysql
- ext-swoole-hook-sqlite
- ext-swoole-hook-odbc
suggests@linux:
- zstd
- liburing
- ext-sockets
- ext-swoole-hook-pgsql
- ext-swoole-hook-mysql
- ext-swoole-hook-sqlite
- ext-swoole-hook-odbc
lang: cpp
php-extension:
arg-type: custom
ext-swoole-hook-mysql:
type: php-extension
depends:
- ext-mysqlnd
- ext-pdo
- ext-pdo_mysql
suggests:
- ext-mysqli
php-extension:
arg-type: none
display-name: swoole
ext-swoole-hook-odbc:
type: php-extension
depends:
- ext-pdo
- unixodbc
php-extension:
arg-type: none
display-name: swoole
ext-swoole-hook-pgsql:
type: php-extension
depends:
- ext-pgsql
- ext-pdo
php-extension:
arg-type: none
display-name: swoole
ext-swoole-hook-sqlite:
type: php-extension
depends:
- ext-sqlite3
- ext-pdo
php-extension:
arg-type: none
display-name: swoole

View File

@@ -0,0 +1,18 @@
ext-swow:
type: php-extension
artifact:
source:
extract: php-src/ext/swow-src
type: ghtar
repo: swow/swow
prefer-stable: true
metadata:
license: Apache-2.0
license-files: [LICENSE]
suggests:
- openssl
- curl
- ext-openssl
- ext-curl
php-extension:
arg-type: custom

View File

@@ -0,0 +1,14 @@
ext-trader:
type: php-extension
artifact:
source:
type: pecl
name: trader
metadata:
license-files: [LICENSE]
license: BSD-2-Clause
php-extension:
support:
BSD: wip
Windows: wip
arg-type: enable

View File

@@ -0,0 +1,16 @@
ext-uuid:
type: php-extension
artifact:
source:
type: pecl
name: uuid
metadata:
license-files: [LICENSE]
license: LGPL-2.1-only
depends:
- libuuid
php-extension:
support:
Windows: wip
BSD: wip
arg-type: with-path

18
config/pkg/ext/ext-uv.yml Normal file
View File

@@ -0,0 +1,18 @@
ext-uv:
type: php-extension
artifact:
source:
type: pecl
name: uv
prefer-stable: false
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- libuv
- ext-sockets
php-extension:
support:
Windows: wip
BSD: wip
arg-type: with-path

View File

@@ -0,0 +1,14 @@
ext-xdebug:
type: php-extension
artifact:
source:
type: pie
repo: xdebug/xdebug
metadata:
license-files: [LICENSE]
license: Xdebug-1.03
php-extension:
zend-extension: true
build-static: false
build-shared: true
build-with-php: false

View File

@@ -0,0 +1,18 @@
ext-xhprof:
type: php-extension
artifact:
source:
type: pecl
name: xhprof
extract: php-src/ext/xhprof-src
metadata:
license-files: [LICENSE]
license: Apache-2.0
depends:
- ext-ctype
php-extension:
support:
Windows: wip
BSD: wip
arg-type: enable
build-with-php: true

View File

@@ -0,0 +1,18 @@
ext-xlswriter:
type: php-extension
artifact:
source:
type: pecl
name: xlswriter
metadata:
license-files: [LICENSE]
license: BSD-2-Clause
depends:
- ext-zlib
- ext-zip
suggests:
- openssl
php-extension:
support:
BSD: wip
arg-type: custom

15
config/pkg/ext/ext-xz.yml Normal file
View File

@@ -0,0 +1,15 @@
ext-xz:
type: php-extension
artifact:
source:
type: git
url: 'https://github.com/codemasher/php-ext-xz'
rev: main
extract: php-src/ext/xz
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends:
- xz
php-extension:
arg-type: with-path

View File

@@ -0,0 +1,14 @@
ext-yac:
type: php-extension
artifact:
source:
type: pecl
name: yac
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends@unix:
- fastlz
- ext-igbinary
php-extension:
arg-type@unix: '--enable-yac@shared_suffix@ --enable-igbinary --enable-json --with-system-fastlz'

View File

@@ -0,0 +1,16 @@
ext-yaml:
type: php-extension
artifact:
source:
type: git
url: 'https://github.com/php/pecl-file_formats-yaml'
rev: php7
extract: php-src/ext/yaml
metadata:
license-files: [LICENSE]
license: MIT
depends:
- libyaml
php-extension:
arg-type@unix: with-path
arg-type@windows: with

View File

@@ -0,0 +1,17 @@
ext-zip:
type: php-extension
artifact:
source:
type: pecl
name: zip
extract: ext-zip
metadata:
license-files: [LICENSE]
license: PHP-3.01
depends@unix:
- libzip
php-extension:
support:
BSD: wip
arg-type: custom
arg-type@windows: enable

View File

@@ -0,0 +1,15 @@
ext-zstd:
type: php-extension
artifact:
source:
type: git
url: 'https://github.com/kjdev/php-ext-zstd'
rev: master
extract: php-src/ext/zstd
metadata:
license-files: [LICENSE]
license: MIT
depends:
- zstd
php-extension:
arg-type: '--enable-zstd --with-libzstd=@build_root_path@'

View File

@@ -3,7 +3,7 @@ gmp:
artifact:
source:
type: filelist
url: 'https://gmplib.org/download/gmp/'
url: 'https://ftp.gnu.org/gnu/gmp/'
regex: '/href="(?<file>gmp-(?<version>[^"]+)\.tar\.xz)"/'
source-mirror:
type: url

View File

@@ -7,5 +7,12 @@ libavif:
metadata:
license-files: [LICENSE]
license: BSD-2-Clause
depends:
- libaom
suggests:
- libwebp
- libjpeg
- libxml2
- libpng
static-libs@unix:
- libavif.a

View File

@@ -10,9 +10,8 @@ libxml2:
license: MIT
depends@unix:
- libiconv
suggests@unix:
- xz
- zlib
- xz
headers:
- libxml2
pkg-configs:

View File

@@ -1,12 +1,10 @@
ncurses:
type: library
artifact:
source:
type: filelist
url: 'https://ftp.gnu.org/pub/gnu/ncurses/'
regex: '/href="(?<file>ncurses-(?<version>[^"]+)\.tar\.gz)"/'
binary: hosted
metadata:
license-files: [COPYING]
artifact: ncurses
static-libs@unix:
- libncurses.a
ncursesw:
type: library
artifact: ncurses
static-libs@unix:
- libncursesw.a

View File

@@ -1,5 +1,5 @@
curl:
type: library
type: target
artifact:
source:
type: ghrel
@@ -29,5 +29,7 @@ curl:
- SystemConfiguration
headers:
- curl
static-bins@unix:
- curl
static-libs@unix:
- libcurl.a

View File

@@ -2,5 +2,11 @@ go-xcaddy:
type: target
artifact:
binary: custom
env:
GOROOT: '{pkg_root_path}/go-xcaddy'
GOBIN: '{pkg_root_path}/go-xcaddy/bin'
GOPATH: '{pkg_root_path}/go-xcaddy/go'
path@unix:
- '{pkg_root_path}/go-xcaddy/bin'
static-bins:
- xcaddy

View File

@@ -0,0 +1,10 @@
htop:
type: target
artifact:
source:
type: ghrel
repo: htop-dev/htop
match: htop.+\.tar\.xz
prefer-stable: true
depends:
- ncursesw

View File

@@ -0,0 +1,8 @@
protoc:
type: target
artifact:
binary:
linux-x86_64: { type: ghrel, repo: protocolbuffers/protobuf, match: 'protoc-([0-9.]+)-linux-x86_64\.zip', extract: '{pkg_root_path}/protoc' }
linux-aarch64: { type: ghrel, repo: protocolbuffers/protobuf, match: 'protoc-([0-9.]+)-linux-aarch_64\.zip', extract: '{pkg_root_path}/protoc' }
path:
- '{pkg_root_path}/protoc/bin'

View File

@@ -0,0 +1,6 @@
rust:
type: target
artifact:
binary: custom
path:
- '{pkg_root_path}/rust/bin'

View File

@@ -361,7 +361,7 @@
},
"gmp": {
"type": "filelist",
"url": "https://gmplib.org/download/gmp/",
"url": "https://ftp.gnu.org/gnu/gmp/",
"regex": "/href=\"(?<file>gmp-(?<version>[^\"]+)\\.tar\\.xz)\"/",
"provide-pre-built": true,
"alt": {
@@ -526,7 +526,7 @@
"libavif": {
"type": "ghtar",
"repo": "AOMediaCodec/libavif",
"provide-pre-built": true,
"provide-pre-built": false,
"license": {
"type": "file",
"path": "LICENSE"

View File

@@ -6,8 +6,10 @@ namespace Package\Artifact;
use StaticPHP\Artifact\ArtifactDownloader;
use StaticPHP\Artifact\Downloader\DownloadResult;
use StaticPHP\Artifact\Downloader\Type\CheckUpdateResult;
use StaticPHP\Attribute\Artifact\AfterBinaryExtract;
use StaticPHP\Attribute\Artifact\CustomBinary;
use StaticPHP\Attribute\Artifact\CustomBinaryCheckUpdate;
use StaticPHP\Exception\DownloaderException;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\GlobalEnvManager;
@@ -65,6 +67,25 @@ class go_xcaddy
return DownloadResult::archive(basename($path), ['url' => $url, 'version' => $version], extract: "{$pkgroot}/go-xcaddy", verified: true, version: $version);
}
#[CustomBinaryCheckUpdate('go-xcaddy', [
'linux-x86_64',
'linux-aarch64',
'macos-x86_64',
'macos-aarch64',
])]
public function checkUpdateBinary(?string $old_version, ArtifactDownloader $downloader): CheckUpdateResult
{
[$version] = explode("\n", default_shell()->executeCurl('https://go.dev/VERSION?m=text') ?: '');
if ($version === '') {
throw new DownloaderException('Failed to get latest Go version from https://go.dev/VERSION?m=text');
}
return new CheckUpdateResult(
old: $old_version,
new: $version,
needUpdate: $old_version === null || $version !== $old_version,
);
}
#[AfterBinaryExtract('go-xcaddy', [
'linux-x86_64',
'linux-aarch64',

View File

@@ -7,7 +7,6 @@ namespace Package\Artifact;
use Package\Target\php;
use StaticPHP\Attribute\Artifact\AfterSourceExtract;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
use StaticPHP\Util\SourcePatcher;
@@ -52,16 +51,6 @@ class php_src
}
}
#[AfterSourceExtract('php-src')]
#[PatchDescription('Patch FFI extension on CentOS 7 with -O3 optimization (strncmp issue)')]
public function patchFfiCentos7FixO3strncmp(): void
{
spc_skip_if(!($ver = SystemTarget::getLibcVersion()) || version_compare($ver, '2.17', '>'));
$ver_id = php::getPHPVersionID(return_null_if_failed: true);
spc_skip_if($ver_id === null || $ver_id < 80316);
SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src');
}
#[AfterSourceExtract('php-src')]
#[PatchDescription('Add LICENSE file to IMAP extension if missing')]
public function patchImapLicense(): void

View File

@@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
namespace Package\Artifact;
use StaticPHP\Artifact\ArtifactDownloader;
use StaticPHP\Artifact\Downloader\DownloadResult;
use StaticPHP\Artifact\Downloader\Type\CheckUpdateResult;
use StaticPHP\Attribute\Artifact\AfterBinaryExtract;
use StaticPHP\Attribute\Artifact\CustomBinary;
use StaticPHP\Attribute\Artifact\CustomBinaryCheckUpdate;
use StaticPHP\Exception\DownloaderException;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\System\LinuxUtil;
class rust
{
#[CustomBinary('rust', [
'linux-x86_64',
'linux-aarch64',
])]
public function downBinary(ArtifactDownloader $downloader): DownloadResult
{
// determine distro first
$distro = LinuxUtil::isMuslDist() ? 'musl' : 'gnu';
$arch = SystemTarget::getTargetArch();
// get latest rust version from link
$toml_config = default_shell()->executeCurl('https://static.rust-lang.org/dist/channel-rust-stable.toml', retries: $downloader->getRetry());
// parse toml by regex since we want to avoid adding a toml parser dependency just for this
$cnt = preg_match_all('/^version = "([^"]+)"$/m', $toml_config ?: '', $matches);
if (!$cnt) {
throw new DownloaderException('Failed to parse Rust version from channel config');
}
$versions = $matches[1];
// strip version num \d.\d.\d (some version number is like "x.x.x (abcdefg 1970-01-01)"
$versions = array_filter(array_map(fn ($v) => preg_match('/^(\d+\.\d+\.\d+)/', $v, $m) ? $m[1] : null, $versions));
usort($versions, 'version_compare');
$latest_version = end($versions);
if (!$latest_version) {
throw new DownloaderException('Could not determine latest Rust version');
}
// merge download link
$download_url = "https://static.rust-lang.org/dist/rust-{$latest_version}-{$arch}-unknown-linux-{$distro}.tar.xz";
$path = DOWNLOAD_PATH . DIRECTORY_SEPARATOR . basename($download_url);
default_shell()->executeCurlDownload($download_url, $path, retries: $downloader->getRetry());
return DownloadResult::archive(basename($path), ['url' => $download_url, 'version' => $latest_version], extract: PKG_ROOT_PATH . '/rust-install', verified: false, version: $latest_version);
}
#[CustomBinaryCheckUpdate('rust', [
'linux-x86_64',
'linux-aarch64',
])]
public function checkUpdateBinary(?string $old_version, ArtifactDownloader $downloader): CheckUpdateResult
{
$toml_config = default_shell()->executeCurl('https://static.rust-lang.org/dist/channel-rust-stable.toml', retries: $downloader->getRetry());
$cnt = preg_match_all('/^version = "([^"]+)"$/m', $toml_config ?: '', $matches);
if (!$cnt) {
throw new DownloaderException('Failed to parse Rust version from channel config');
}
$versions = array_filter(array_map(fn ($v) => preg_match('/^(\d+\.\d+\.\d+)/', $v, $m) ? $m[1] : null, $matches[1]));
usort($versions, 'version_compare');
$latest_version = end($versions);
if (!$latest_version) {
throw new DownloaderException('Could not determine latest Rust version');
}
return new CheckUpdateResult(
old: $old_version,
new: $latest_version,
needUpdate: $old_version === null || $latest_version !== $old_version,
);
}
#[AfterBinaryExtract('rust', [
'linux-x86_64',
'linux-aarch64',
])]
public function postExtractRust(string $target_path): void
{
$prefix = PKG_ROOT_PATH . '/rust';
shell()->exec("cd {$target_path} && ./install.sh --prefix={$prefix}");
}
}

View File

@@ -6,8 +6,10 @@ namespace Package\Artifact;
use StaticPHP\Artifact\ArtifactDownloader;
use StaticPHP\Artifact\Downloader\DownloadResult;
use StaticPHP\Artifact\Downloader\Type\CheckUpdateResult;
use StaticPHP\Attribute\Artifact\AfterBinaryExtract;
use StaticPHP\Attribute\Artifact\CustomBinary;
use StaticPHP\Attribute\Artifact\CustomBinaryCheckUpdate;
use StaticPHP\Exception\DownloaderException;
use StaticPHP\Runtime\SystemTarget;
@@ -24,6 +26,9 @@ class zig
$index_json = default_shell()->executeCurl('https://ziglang.org/download/index.json', retries: $downloader->getRetry());
$index_json = json_decode($index_json ?: '', true);
$latest_version = null;
if ($index_json === null) {
throw new DownloaderException('Failed to fetch Zig version index');
}
foreach ($index_json as $version => $data) {
if ($version !== 'master') {
$latest_version = $version;
@@ -59,6 +64,36 @@ class zig
return DownloadResult::archive(basename($path), ['url' => $url, 'version' => $latest_version], extract: PKG_ROOT_PATH . '/zig', verified: true, version: $latest_version);
}
#[CustomBinaryCheckUpdate('zig', [
'linux-x86_64',
'linux-aarch64',
'macos-x86_64',
'macos-aarch64',
])]
public function checkUpdateBinary(?string $old_version, ArtifactDownloader $downloader): CheckUpdateResult
{
$index_json = default_shell()->executeCurl('https://ziglang.org/download/index.json', retries: $downloader->getRetry());
$index_json = json_decode($index_json ?: '', true);
$latest_version = null;
if (!is_array($index_json)) {
throw new DownloaderException('Failed to fetch Zig version index for update check');
}
foreach ($index_json as $version => $data) {
if ($version !== 'master') {
$latest_version = $version;
break;
}
}
if (!$latest_version) {
throw new DownloaderException('Could not determine latest Zig version');
}
return new CheckUpdateResult(
old: $old_version,
new: $latest_version,
needUpdate: $old_version === null || $latest_version !== $old_version,
);
}
#[AfterBinaryExtract('zig', [
'linux-x86_64',
'linux-aarch64',

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PackageInstaller;
#[Extension('dba')]
class dba
{
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string
{
$qdbm = ($qdbm = $installer->getLibraryPackage('qdbm')) ? (" --with-qdbm={$qdbm->getBuildRootPath()}") : '';
return '--enable-dba' . ($shared ? '=shared' : '') . $qdbm;
}
#[CustomPhpConfigureArg('Windows')]
public function getWindowsConfigureArg(PackageInstaller $installer): string
{
$qdbm = $installer->getLibraryPackage('qdbm') ? ' --with-qdbm' : '';
return '--with-dba' . $qdbm;
}
}

View File

@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Util\FileSystem;
#[Extension('dio')]
class dio extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-dio')]
public function patchBeforeBuildconf(): void
{
if (!file_exists("{$this->getSourceDir()}/php_dio.h")) {
FileSystem::writeFile("{$this->getSourceDir()}/php_dio.h", FileSystem::readFile("{$this->getSourceDir()}/src/php_dio.h"));
}
}
}

View File

@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
#[Extension('event')]
class event extends PhpExtensionPackage
{
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(PackageInstaller $installer): string
{
$arg = "--with-event-core --with-event-extra --with-event-libevent-dir={$this->getBuilder()->getBuildRootPath()}";
if ($installer->getLibraryPackage('openssl')) {
$arg .= " --with-event-openssl={$this->getBuilder()->getBuildRootPath()}";
}
if ($installer->getPhpExtensionPackage('ext-sockets')) {
$arg .= ' --enable-event-sockets';
} else {
$arg .= ' --disable-event-sockets';
}
return $arg;
}
#[BeforeStage('php', [php::class, 'makeForUnix'], 'ext-event')]
#[PatchDescription('Prevent event extension compile error on macOS')]
public function patchBeforeMake(PackageInstaller $installer): void
{
// Prevent event extension compile error on macOS
if (SystemTarget::getTargetOS() === 'Darwin') {
$php_src = $installer->getTargetPackage('php')->getSourceDir();
FileSystem::replaceFileRegex("{$php_src}/main/php_config.h", '/^#define HAVE_OPENPTY 1$/m', '');
}
}
}

View File

@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PhpExtensionPackage;
#[Extension('excimer')]
class excimer extends PhpExtensionPackage
{
public function getSharedExtensionEnv(): array
{
$env = parent::getSharedExtensionEnv();
$env['LIBS'] = clean_spaces(str_replace('-lphp', '', $env['LIBS']));
return $env;
}
}

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\SourcePatcher;
use StaticPHP\Util\System\LinuxUtil;
#[Extension('ffi')]
class ffi extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-ffi')]
#[PatchDescription('Patch FFI extension on CentOS 7 with -O3 optimization (strncmp issue)')]
public function patchBeforeBuildconf(): void
{
spc_skip_if(!($ver = SystemTarget::getLibcVersion()) || version_compare($ver, '2.17', '>'));
$ver_id = php::getPHPVersionID(return_null_if_failed: true);
spc_skip_if($ver_id === null || $ver_id < 80316);
spc_skip_if(LinuxUtil::getOSRelease()['dist'] !== 'centos');
SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src');
}
}

View File

@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
#[Extension('gd')]
class gd extends PhpExtensionPackage
{
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string
{
$arg = '--enable-gd' . ($shared ? '=shared' : '');
$arg .= $installer->getLibraryPackage('freetype') ? ' --with-freetype' : '';
$arg .= $installer->getLibraryPackage('libjpeg') ? ' --with-jpeg' : '';
$arg .= $installer->getLibraryPackage('libwebp') ? ' --with-webp' : '';
$arg .= $installer->getLibraryPackage('libavif') ? ' --with-avif' : '';
return $arg;
}
}

View File

@@ -6,7 +6,6 @@ namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\PhpExtensionPackage;
@@ -49,11 +48,4 @@ class glfw extends PhpExtensionPackage
putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=' . $extra_ldflags);
}
}
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH;
}
}

View File

@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Exception\EnvironmentException;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
#[Extension('grpc')]
class grpc extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-grpc')]
public function patchBeforeBuildconf(): void
{
if (SystemTarget::getTargetOS() === 'Windows') {
throw new EnvironmentException('grpc extension does not support windows yet');
}
// Fix deprecated PHP API usage in call.c
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/src/php/ext/grpc/call.c",
'zend_exception_get_default(TSRMLS_C),',
'zend_ce_exception,',
);
// custom config.m4 content for grpc extension, to prevent building libgrpc.a again
$config_m4 = <<<'M4'
PHP_ARG_ENABLE(grpc, [whether to enable grpc support], [AS_HELP_STRING([--enable-grpc], [Enable grpc support])])
if test "$PHP_GRPC" != "no"; then
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include)
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc)
GRPC_LIBDIR=@@build_lib_path@@
PHP_ADD_LIBPATH($GRPC_LIBDIR)
PHP_ADD_LIBRARY(grpc,,GRPC_SHARED_LIBADD)
LIBS="-lpthread $LIBS"
PHP_ADD_LIBRARY(pthread)
case $host in
*darwin*)
PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD)
;;
*)
PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(rt)
;;
esac
PHP_NEW_EXTENSION(grpc, @grpc_c_files@, $ext_shared, , -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1)
PHP_SUBST(GRPC_SHARED_LIBADD)
PHP_INSTALL_HEADERS([ext/grpc], [php_grpc.h])
fi
M4;
$replace = get_pack_replace();
// load grpc c files from src/php/ext/grpc
$c_files = glob("{$this->getSourceDir()}/src/php/ext/grpc/*.c");
$replace['@grpc_c_files@'] = implode(" \\\n ", array_map(fn ($f) => 'src/php/ext/grpc/' . basename($f), $c_files));
$config_m4 = str_replace(array_keys($replace), array_values($replace), $config_m4);
file_put_contents("{$this->getSourceDir()}/config.m4", $config_m4);
copy("{$this->getSourceDir()}/src/php/ext/grpc/php_grpc.h", "{$this->getSourceDir()}/php_grpc.h");
}
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PackageBuilder;
#[Extension('imagick')]
class imagick
{
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(bool $shared, PackageBuilder $builder): string
{
$disable_omp = ' ac_cv_func_omp_pause_resource_all=no';
return '--with-imagick=' . ($shared ? 'shared,' : '') . $builder->getBuildRootPath() . $disable_omp;
}
}

View File

@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\Package\Validate;
use StaticPHP\Exception\WrongUsageException;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Util\FileSystem;
#[Extension('imap')]
class imap extends PhpExtensionPackage
{
#[Validate]
public function validate(PackageBuilder $builder): void
{
if ($builder->getOption('enable-zts')) {
throw new WrongUsageException('ext-imap is not thread safe, do not build it with ZTS builds');
}
}
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-imap')]
public function patchBeforeBuildconf(PackageInstaller $installer): void
{
if ($installer->getLibraryPackage('openssl')) {
// sometimes imap with openssl does not contain zlib (required by openssl)
// we need to add it manually
FileSystem::replaceFileStr("{$this->getSourceDir()}/config.m4", 'TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD"', 'TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD -lz"');
}
// c-client is built with PASSWDTYPE=nul so libcrypt is not referenced.
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/config.m4",
" PHP_CHECK_LIBRARY(crypt, crypt,\n [\n PHP_ADD_LIBRARY(crypt,, IMAP_SHARED_LIBADD)\n AC_DEFINE(HAVE_LIBCRYPT,1,[ ])\n ])",
' dnl Skipped: crypt check not needed (c-client built with PASSWDTYPE=nul)'
);
}
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(PackageInstaller $installer, PackageBuilder $builder): string
{
$arg = "--with-imap={$builder->getBuildRootPath()}";
if (($ssl = $installer->getLibraryPackage('openssl')) !== null) {
$arg .= " --with-imap-ssl={$ssl->getBuildRootPath()}";
}
return $arg;
}
}

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Util\FileSystem;
#[Extension('maxminddb')]
class maxminddb extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-maxminddb')]
#[PatchDescription('Patch maxminddb extension for buildconf to support new source structure')]
public function patchBeforeBuildconf(): void
{
if (file_exists("{$this->getSourceDir()}/config.m4")) {
return;
}
// move ext/maxminddb/ext/* to ext/maxminddb/
$files = FileSystem::scanDirFiles("{$this->getSourceDir()}/ext", false, true);
foreach ($files as $file) {
rename("{$this->getSourceDir()}/ext/{$file}", "{$this->getSourceDir()}/{$file}");
}
}
}

View File

@@ -0,0 +1,75 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Util\FileSystem;
#[Extension('memcache')]
class memcache extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-memcache')]
public function patchBeforeBuildconf(): bool
{
if (!$this->isBuildStatic()) {
return false;
}
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/config9.m4",
'if test -d $abs_srcdir/src ; then',
'if test -d $abs_srcdir/main ; then'
);
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/config9.m4",
'export CPPFLAGS="$CPPFLAGS $INCLUDES"',
'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"'
);
// add for in-tree building
file_put_contents(
"{$this->getSourceDir()}/php_memcache.h",
<<<'EOF'
#ifndef PHP_MEMCACHE_H
#define PHP_MEMCACHE_H
extern zend_module_entry memcache_module_entry;
#define phpext_memcache_ptr &memcache_module_entry
#endif
EOF
);
return true;
}
#[BeforeStage('ext-memcache', [self::class, 'configureForUnix'])]
#[PatchDescription('Fix memcache extension compile error when building as shared')]
public function patchBeforeSharedConfigure(): bool
{
if (!$this->isBuildShared()) {
return false;
}
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/config9.m4",
'if test -d $abs_srcdir/main ; then',
'if test -d $abs_srcdir/src ; then',
);
FileSystem::replaceFileStr(
"{$this->getSourceDir()}/config9.m4",
'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"',
'export CPPFLAGS="$CPPFLAGS $INCLUDES"',
);
return true;
}
public function getSharedExtensionEnv(): array
{
$parent = parent::getSharedExtensionEnv();
$parent['CFLAGS'] .= ' -std=c17';
return $parent;
}
}

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
#[Extension('memcached')]
class memcached extends PhpExtensionPackage
{
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string
{
return '--enable-memcached' . ($shared ? '=shared' : '') . ' ' .
'--with-zlib-dir=' . $installer->getLibraryPackage('zlib')->getBuildRootPath() . ' ' .
'--with-libmemcached-dir=' . $installer->getLibraryPackage('libmemcached')->getBuildRootPath() . ' ' .
'--disable-memcached-sasl ' .
'--enable-memcached-json ' .
($installer->getLibraryPackage('zstd') ? '--with-zstd ' : '') .
($installer->getPhpExtensionPackage('ext-igbinary') ? '--enable-memcached-igbinary ' : '') .
($installer->getPhpExtensionPackage('ext-session') ? '--enable-memcached-session ' : '') .
($installer->getPhpExtensionPackage('ext-msgpack') ? '--enable-memcached-msgpack ' : '') .
'--with-system-fastlz';
}
}

View File

@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
#[Extension('mongodb')]
class mongodb extends PhpExtensionPackage
{
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string
{
$arg = ' --enable-mongodb' . ($shared ? '=shared' : '') . ' ';
$arg .= ' --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no ';
$arg .= ' --with-mongodb-sasl=no ';
if ($installer->getLibraryPackage('openssl')) {
$arg .= '--with-mongodb-ssl=openssl';
}
$arg .= $installer->getLibraryPackage('icu') ? ' --with-mongodb-icu=yes ' : ' --with-mongodb-icu=no ';
$arg .= $installer->getLibraryPackage('zstd') ? ' --with-mongodb-zstd=yes ' : ' --with-mongodb-zstd=no ';
// $arg .= $installer->getLibraryPackage('snappy') ? ' --with-mongodb-snappy=yes ' : ' --with-mongodb-snappy=no ';
$arg .= $installer->getLibraryPackage('zlib') ? ' --with-mongodb-zlib=yes ' : ' --with-mongodb-zlib=bundled ';
return clean_spaces($arg);
}
public function getSharedExtensionEnv(): array
{
$parent = parent::getSharedExtensionEnv();
$parent['CFLAGS'] .= ' -std=c17';
return $parent;
}
}

View File

@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\Package\Validate;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Exception\WrongUsageException;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\SourcePatcher;
#[Extension('opcache')]
class opcache extends PhpExtensionPackage
{
#[Validate]
public function validate(): void
{
if (php::getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
throw new WrongUsageException('Statically compiled PHP with Zend Opcache only available for PHP >= 8.0 !');
}
}
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-opcache')]
#[PatchDescription('Fix static opcache build for PHP 8.2.0 to 8.4.x')]
public function patchBeforeBuildconf(PackageInstaller $installer): bool
{
$version = php::getPHPVersion();
$php_src = $installer->getTargetPackage('php')->getSourceDir();
if (file_exists("{$php_src}/.opcache_patched")) {
return false;
}
// if 8.2.0 <= PHP_VERSION < 8.2.23, we need to patch from legacy patch file
if (version_compare($version, '8.2.0', '>=') && version_compare($version, '8.2.23', '<')) {
SourcePatcher::patchFile('spc_fix_static_opcache_before_80222.patch', $php_src);
}
// if 8.3.0 <= PHP_VERSION < 8.3.11, we need to patch from legacy patch file
elseif (version_compare($version, '8.3.0', '>=') && version_compare($version, '8.3.11', '<')) {
SourcePatcher::patchFile('spc_fix_static_opcache_before_80310.patch', $php_src);
}
// if 8.3.12 <= PHP_VERSION < 8.5.0-dev, we need to patch from legacy patch file
elseif (version_compare($version, '8.5.0-dev', '<')) {
SourcePatcher::patchPhpSrc(items: ['static_opcache']);
}
// PHP 8.5.0-dev and later supports static opcache without patching
else {
return false;
}
return file_put_contents($php_src . '/.opcache_patched', '1') !== false;
}
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(bool $shared, PackageBuilder $builder): string
{
$phpVersionID = php::getPHPVersionID();
$opcache_jit = ' --enable-opcache-jit';
if ((SystemTarget::getTargetOS() === 'Linux' &&
SystemTarget::getLibc() === 'musl' &&
$builder->getOption('enable-zts') &&
SystemTarget::getTargetArch() === 'x86_64' &&
$phpVersionID < 80500) ||
$builder->getOption('disable-opcache-jit')
) {
$opcache_jit = ' --disable-opcache-jit';
}
return '--enable-opcache' . ($shared ? '=shared' : '') . $opcache_jit;
}
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Util\GlobalEnvManager;
#[Extension('opentelemetry')]
class opentelemetry
{
#[BeforeStage('php', [php::class, 'makeForUnix'], 'ext-opentelemetry')]
public function patchBeforeMake(): void
{
// add -Wno-strict-prototypes
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
}
}

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Attribute\Package\Validate;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Exception\WrongUsageException;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Util\FileSystem;
#[Extension('parallel')]
class parallel extends PhpExtensionPackage
{
#[Validate]
public function validate(PackageBuilder $builder): void
{
if (!$builder->getOption('enable-zts')) {
throw new WrongUsageException('ext-parallel must be built with ZTS builds. Use "--enable-zts" option!');
}
}
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-parallel')]
#[PatchDescription('Fix parallel m4 hardcoded PHP_VERSION check')]
public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileRegex("{$this->getSourceDir()}/config.m4", '/PHP_VERSION=.*/m', '');
return true;
}
}

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Exception\ValidationException;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
#[Extension('password-argon2')]
class password_argon2 extends PhpExtensionPackage
{
public function runSmokeTestCliUnix(): void
{
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n -r "assert(defined(\'PASSWORD_ARGON2I\'));"');
if ($ret !== 0) {
throw new ValidationException('extension ' . $this->getName() . ' failed sanity check', validation_module: 'password_argon2 function check');
}
}
#[CustomPhpConfigureArg('Linux')]
#[CustomPhpConfigureArg('Darwin')]
public function getConfigureArg(PackageInstaller $installer, PackageBuilder $builder): string
{
if ($installer->getLibraryPackage('openssl') !== null) {
if (php::getPHPVersionID() >= 80500 || (php::getPHPVersionID() >= 80400 && !$builder->getOption('enable-zts'))) {
return '--without-password-argon2'; // use --with-openssl-argon2 in openssl extension instead
}
}
return '--with-password-argon2';
}
}

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Util\FileSystem;
#[Extension('pdo_odbc')]
class pdo_odbc extends PhpExtensionPackage
{
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-pdo_odbc')]
public function patchBeforeBuildconf(): void
{
FileSystem::replaceFileStr("{$this->getSourceDir()}/config.m4", 'PDO_ODBC_LDFLAGS="$pdo_odbc_def_ldflags', 'PDO_ODBC_LDFLAGS="-liconv $pdo_odbc_def_ldflags');
}
#[CustomPhpConfigureArg('Linux')]
#[CustomPhpConfigureArg('Darwin')]
public function getUnixConfigureArg(bool $shared): string
{
return '--with-pdo-odbc=' . ($shared ? 'shared,' : '') . 'unixODBC,' . BUILD_ROOT_PATH;
}
#[CustomPhpConfigureArg('Windows')]
public function getWindowsConfigureArg(bool $shared): string
{
return '--with-pdo-odbc';
}
}

View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\BeforeStage;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Util\FileSystem;
#[Extension('pdo_sqlite')]
class pdo_sqlite
{
#[BeforeStage('php', [php::class, 'configureForUnix'], 'ext-pdo_sqlite')]
public function patchBeforeConfigure(PackageInstaller $installer): void
{
FileSystem::replaceFileRegex(
"{$installer->getTargetPackage('php')->getSourceDir()}/configure",
'/sqlite3_column_table_name=yes/',
'sqlite3_column_table_name=no'
);
}
}

View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
use StaticPHP\Util\SPCConfigUtil;
#[Extension('pgsql')]
class pgsql extends PhpExtensionPackage
{
#[CustomPhpConfigureArg('Darwin')]
#[CustomPhpConfigureArg('Linux')]
public function getUnixConfigureArg(bool $shared, PackageBuilder $builder, PackageInstaller $installer): string
{
if (php::getPHPVersionID() >= 80400) {
$libfiles = new SPCConfigUtil(['libs_only_deps' => true, 'absolute_libs' => true])->getPackageDepsConfig('postgresql', array_keys($installer->getResolvedPackages()), $builder->getOption('with-suggests'))['libs'];
$libfiles = str_replace("{$builder->getLibDir()}/lib", '-l', $libfiles);
$libfiles = str_replace('.a', '', $libfiles);
return '--with-pgsql' . ($shared ? '=shared' : '') .
' PGSQL_CFLAGS=-I' . $builder->getIncludeDir() .
' PGSQL_LIBS="-L' . $builder->getLibDir() . ' ' . $libfiles . '"';
}
return '--with-pgsql=' . ($shared ? 'shared,' : '') . $builder->getBuildRootPath();
}
#[CustomPhpConfigureArg('Windows')]
public function getWindowsConfigureArg(bool $shared, PackageBuilder $builder): string
{
if (php::getPHPVersionID() >= 80400) {
return '--with-pgsql';
}
return "--with-pgsql={$builder->getBuildRootPath()}";
}
public function getSharedExtensionEnv(): array
{
$parent = parent::getSharedExtensionEnv();
$parent['CFLAGS'] .= ' -std=c17 -Wno-int-conversion';
return $parent;
}
}

Some files were not shown because too many files have changed in this diff Show More