mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 22:35:43 +08:00
Compare commits
166 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d303348d9 | ||
|
|
2a2f4120b9 | ||
|
|
15f8887f14 | ||
|
|
fe945ab3ea | ||
|
|
e2b6f4cedd | ||
|
|
d82c86cf62 | ||
|
|
9df2867175 | ||
|
|
5c803d1553 | ||
|
|
d45b1853f8 | ||
|
|
1ac621fb9c | ||
|
|
4e74ac1937 | ||
|
|
959734ac31 | ||
|
|
166f3de52f | ||
|
|
e3adfff16f | ||
|
|
7cbc374278 | ||
|
|
129041402d | ||
|
|
9ac578dfd6 | ||
|
|
ef709a169b | ||
|
|
2eeba33f94 | ||
|
|
f4b2b9ae7d | ||
|
|
e44efb2a54 | ||
|
|
598f6d55c5 | ||
|
|
a2c5c7e6e6 | ||
|
|
4f6e646812 | ||
|
|
a79564f685 | ||
|
|
a77e49cbc9 | ||
|
|
cefb737fd2 | ||
|
|
8c8aba2dd5 | ||
|
|
97b18e9121 | ||
|
|
ddc9cc2237 | ||
|
|
aff803f334 | ||
|
|
38ec03fe30 | ||
|
|
55836771c9 | ||
|
|
08a68796bf | ||
|
|
3b9efcb2d4 | ||
|
|
022ba3dce4 | ||
|
|
86973e622d | ||
|
|
0fa38bad6d | ||
|
|
465bd3ce85 | ||
|
|
0c9130ab6c | ||
|
|
6c75ecf0c4 | ||
|
|
d533a0591b | ||
|
|
3f74d58503 | ||
|
|
1ba92ccc99 | ||
|
|
75db184077 | ||
|
|
66902d74c4 | ||
|
|
f6cc6af39c | ||
|
|
0da8dcf04a | ||
|
|
190be6c7b9 | ||
|
|
2972ab31d7 | ||
|
|
4b4ae9b014 | ||
|
|
20db00afcc | ||
|
|
56c90ca4a3 | ||
|
|
fad2314539 | ||
|
|
460eb02086 | ||
|
|
5a30d509e7 | ||
|
|
0f0050115c | ||
|
|
bf55db959e | ||
|
|
39a9840d49 | ||
|
|
866ca264d9 | ||
|
|
f18725083a | ||
|
|
20fbbb1dbe | ||
|
|
1a7bf2d070 | ||
|
|
fc7e8ebc53 | ||
|
|
532360886e | ||
|
|
117a54d077 | ||
|
|
f2c131a2cc | ||
|
|
6f0310e8f7 | ||
|
|
c7141003db | ||
|
|
d32bdb2825 | ||
|
|
a66abfa583 | ||
|
|
2551772de4 | ||
|
|
25fe794acc | ||
|
|
694fd2f1e0 | ||
|
|
5a4b920ae2 | ||
|
|
95f1b65bca | ||
|
|
25401e5959 | ||
|
|
3da58d5c24 | ||
|
|
08ab3c17d6 | ||
|
|
ecdb94b429 | ||
|
|
00892c20fa | ||
|
|
c433aed521 | ||
|
|
1243fb9678 | ||
|
|
d9c2247f99 | ||
|
|
0d4d4283d1 | ||
|
|
effefd4844 | ||
|
|
2d409db2f9 | ||
|
|
00f262571c | ||
|
|
4eac953c71 | ||
|
|
43352ab986 | ||
|
|
9803bf6c3f | ||
|
|
ba326973e5 | ||
|
|
a1f2126c00 | ||
|
|
b1da64d46b | ||
|
|
2694dd9e21 | ||
|
|
37e0f1d3f3 | ||
|
|
f80aee5133 | ||
|
|
65ee7479ac | ||
|
|
868f6d408b | ||
|
|
efdfbf437a | ||
|
|
2b57bca55c | ||
|
|
99ccbf8a40 | ||
|
|
9fe322375f | ||
|
|
d13e369994 | ||
|
|
a46ad7b81e | ||
|
|
324ba0d3dc | ||
|
|
1c7fa0132d | ||
|
|
93223a9d44 | ||
|
|
b6d4af218b | ||
|
|
448941f741 | ||
|
|
7e0e9091be | ||
|
|
8104ff7236 | ||
|
|
75f734daa8 | ||
|
|
779a724875 | ||
|
|
e975e151f9 | ||
|
|
a5351e1546 | ||
|
|
af90b840ee | ||
|
|
2558c02470 | ||
|
|
df60ccff0e | ||
|
|
2ed8bbf391 | ||
|
|
ef3025798d | ||
|
|
bea3bd8392 | ||
|
|
99e8900aba | ||
|
|
1c4a6ca02e | ||
|
|
b5fa7be53f | ||
|
|
3804e842bb | ||
|
|
e6832ecf61 | ||
|
|
ed3e29bade | ||
|
|
811aeb58ea | ||
|
|
6b5aaa38ae | ||
|
|
4e9545262d | ||
|
|
d48c84d81b | ||
|
|
cbddb2652d | ||
|
|
5f629253ac | ||
|
|
8d84a95c01 | ||
|
|
2cabaf6402 | ||
|
|
ad25ac49b8 | ||
|
|
d0412a88df | ||
|
|
a3ae1eb2f0 | ||
|
|
2e616af836 | ||
|
|
4fd8afcee4 | ||
|
|
e96b4f5541 | ||
|
|
9978a56b1e | ||
|
|
d3a5be13ea | ||
|
|
5ba0de12eb | ||
|
|
a73c097c94 | ||
|
|
d3840b19fa | ||
|
|
b34b6594de | ||
|
|
2fba61e9bd | ||
|
|
1e9434221b | ||
|
|
afd6791075 | ||
|
|
b3b53b6b4d | ||
|
|
b8b8cf6ea9 | ||
|
|
9a340e1ad8 | ||
|
|
29dc5e4ea7 | ||
|
|
08fa49b791 | ||
|
|
333b776e77 | ||
|
|
f68f060be2 | ||
|
|
722bb31815 | ||
|
|
e28580de00 | ||
|
|
cc447a089a | ||
|
|
0c9a30256e | ||
|
|
fa10142f13 | ||
|
|
c342741670 | ||
|
|
64d49003e0 | ||
|
|
b0c93c7418 |
@@ -10,6 +10,7 @@ trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
indent_size = 2
|
||||
|
||||
[*.{yml,yaml, vue}]
|
||||
[*.{yml,yaml,vue,ts}]
|
||||
indent_size = 2
|
||||
|
||||
13
.github/ISSUE_TEMPLATE/bug_report.md
vendored
13
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -3,6 +3,15 @@ name: Bug report
|
||||
about: Build PHP or library failed, download failed, doesn't seem to work...
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: crazywhalecc
|
||||
|
||||
body:
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: What happened?
|
||||
description: |
|
||||
Please tell us what you do, what you get and what you expected.
|
||||
Provide with some step-by-step instructions to reproduce the issue.
|
||||
If possible, attach a screenshot or log files in ./log directory.
|
||||
validations:
|
||||
required: true
|
||||
---
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -3,6 +3,6 @@ name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: new feature
|
||||
assignees: ''
|
||||
assignees: crazywhalecc
|
||||
|
||||
---
|
||||
|
||||
4
.github/workflows/ext-matrix-tests.yml
vendored
4
.github/workflows/ext-matrix-tests.yml
vendored
@@ -65,7 +65,7 @@ jobs:
|
||||
- sqlsrv
|
||||
- ssh2
|
||||
- swoole
|
||||
- swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite
|
||||
- swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite,swoole-hook-odbc
|
||||
- swow
|
||||
- sysvmsg,sysvsem,sysvshm
|
||||
- tidy
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
- zlib
|
||||
- zstd
|
||||
php-version:
|
||||
- "git"
|
||||
- "8.4"
|
||||
operating-system:
|
||||
- "ubuntu-latest"
|
||||
#- "macos-13"
|
||||
|
||||
45
.github/workflows/release-build.yml
vendored
45
.github/workflows/release-build.yml
vendored
@@ -3,6 +3,10 @@ name: Build SPC Binary
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
paths:
|
||||
- '.github/workflows/release-build.yml'
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
@@ -10,7 +14,7 @@ on:
|
||||
|
||||
env:
|
||||
PHP_VERSION: 8.4
|
||||
MICRO_VERSION: 8.4.10
|
||||
MICRO_VERSION: 8.4.11
|
||||
|
||||
jobs:
|
||||
build-release-artifacts:
|
||||
@@ -117,7 +121,8 @@ jobs:
|
||||
files: dist/${{ matrix.operating-system.filename }}
|
||||
|
||||
- name: "Deploy to self-hosted OSS"
|
||||
if: github.repository == 'crazywhalecc/static-php-cli'
|
||||
# only run this step if the repository is static-php-cli and the branch is main
|
||||
if: github.repository == 'crazywhalecc/static-php-cli' && github.ref == 'refs/heads/main'
|
||||
uses: static-php/upload-s3-action@v1.0.0
|
||||
with:
|
||||
aws_key_id: ${{ secrets.AWS_KEY_ID }}
|
||||
@@ -132,3 +137,39 @@ jobs:
|
||||
with:
|
||||
path: spc${{ env.SUFFIX }}
|
||||
name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }}
|
||||
test-spc:
|
||||
name: "Test SPC Binary for ${{ matrix.operating-system.name }}"
|
||||
runs-on: ${{ matrix.operating-system.os }}
|
||||
needs: [build-release-artifacts]
|
||||
strategy:
|
||||
matrix:
|
||||
operating-system:
|
||||
- name: "linux-x86_64"
|
||||
os: "ubuntu-latest"
|
||||
- name: "macos-x86_64"
|
||||
os: "macos-13"
|
||||
- name: "linux-aarch64"
|
||||
os: "ubuntu-24.04-arm"
|
||||
- name: "macos-aarch64"
|
||||
os: "macos-latest"
|
||||
- name: "windows-x64"
|
||||
os: "windows-latest"
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: "Download Artifact"
|
||||
uses: actions/download-artifact@v4
|
||||
env:
|
||||
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
|
||||
with:
|
||||
name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }}
|
||||
|
||||
- name: "Chmod"
|
||||
if: matrix.operating-system.name != 'windows-x64'
|
||||
run: chmod +x spc
|
||||
|
||||
- name: "Run SPC Tests"
|
||||
env:
|
||||
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
|
||||
run: ./spc${{ env.SUFFIX }} dev:extensions
|
||||
|
||||
7
.github/workflows/tests.yml
vendored
7
.github/workflows/tests.yml
vendored
@@ -206,6 +206,13 @@ jobs:
|
||||
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
||||
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}
|
||||
|
||||
- name: "Upload logs"
|
||||
if: ${{ always() && hashFiles('log/**') != '' }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-logs-${{ matrix.os }}-${{ matrix.php }}
|
||||
path: log
|
||||
|
||||
# - name: Setup tmate session
|
||||
# if: ${{ failure() }}
|
||||
# uses: mxschmitt/action-tmate@v3
|
||||
|
||||
1
.github/workflows/vitepress-deploy.yml
vendored
1
.github/workflows/vitepress-deploy.yml
vendored
@@ -21,7 +21,6 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
cache: yarn
|
||||
|
||||
- run: yarn install --frozen-lockfile
|
||||
|
||||
11
.gitignore
vendored
11
.gitignore
vendored
@@ -34,6 +34,7 @@ packlib_files.txt
|
||||
/bin/*
|
||||
!/bin/spc*
|
||||
!/bin/setup-runtime*
|
||||
!/bin/docker-entrypoint.sh
|
||||
|
||||
# exclude windows build tools
|
||||
/php-sdk-binary-tools/
|
||||
@@ -48,6 +49,12 @@ packlib_files.txt
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
|
||||
# craft.log
|
||||
craft.log
|
||||
# craft
|
||||
craft.yml
|
||||
|
||||
# SPC logs
|
||||
log/
|
||||
|
||||
# spc.phar
|
||||
spc.phar
|
||||
spc.exe
|
||||
|
||||
@@ -207,6 +207,7 @@ bin/spc --version
|
||||
- `--build-micro`:构建 phpmicro 自执行二进制
|
||||
- `--build-fpm`:构建 fpm
|
||||
- `--build-embed`:构建 embed(libphp)
|
||||
- `--build-cgi`: 构建 cgi(不推荐)
|
||||
- `--build-all`:构建所有
|
||||
|
||||
如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误:
|
||||
|
||||
@@ -218,6 +218,7 @@ Now we support `cli`, `micro`, `fpm` and `embed` SAPI. You can use one or more o
|
||||
- `--build-micro`: build static phpmicro self-extracted executable
|
||||
- `--build-fpm`: build static fpm binary
|
||||
- `--build-embed`: build embed (libphp)
|
||||
- `--build-cgi`: build cgi binary (not recommended)
|
||||
- `--build-all`: build all
|
||||
|
||||
If anything goes wrong, use `--debug` option to display full terminal output:
|
||||
|
||||
11
bin/docker-entrypoint.sh
Normal file
11
bin/docker-entrypoint.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
TARGET_DIR="/app/pkgroot/$(uname -m)-linux"
|
||||
BACKUP_DIR="/app/pkgroot-private"
|
||||
# copy private pkgroot to pkgroot if pkgroot is empty
|
||||
if [ ! -d "$TARGET_DIR" ] || [ -z "$(ls -A "$TARGET_DIR")" ]; then
|
||||
echo "* Copying private pkgroot to pkgroot ..."
|
||||
rm -rf "$TARGET_DIR"
|
||||
cp -r "$BACKUP_DIR" "$TARGET_DIR"
|
||||
fi
|
||||
exec "$@"
|
||||
@@ -25,7 +25,7 @@ __DIR__=$(cd "$(dirname "$0")" && pwd)
|
||||
__PROJECT__=$(cd "${__DIR__}"/../ && pwd)
|
||||
|
||||
# set download dir
|
||||
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"
|
||||
|
||||
# use china mirror
|
||||
@@ -45,7 +45,7 @@ done
|
||||
|
||||
case "$mirror" in
|
||||
china)
|
||||
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||
__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.4.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz"
|
||||
__COMPOSER_URL__="https://mirrors.tencent.com/composer/composer.phar"
|
||||
;;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
set -e
|
||||
|
||||
# This file is using docker to run commands
|
||||
SPC_DOCKER_VERSION=v5
|
||||
SPC_DOCKER_VERSION=v6
|
||||
|
||||
# Detect docker can run
|
||||
if ! which docker >/dev/null; then
|
||||
@@ -122,6 +122,14 @@ ADD ./src /app/src
|
||||
COPY ./composer.* /app/
|
||||
ADD ./bin /app/bin
|
||||
RUN composer install --no-dev
|
||||
ADD ./config /app/config
|
||||
RUN bin/spc doctor --auto-fix
|
||||
RUN bin/spc install-pkg upx
|
||||
|
||||
RUN mv /app/pkgroot/\$(uname -m)-linux /app/pkgroot-private
|
||||
ADD bin/docker-entrypoint.sh /bin/docker-entrypoint.sh
|
||||
RUN chmod +x /bin/docker-entrypoint.sh
|
||||
ENTRYPOINT ["/bin/docker-entrypoint.sh"]
|
||||
EOF
|
||||
fi
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
set -e
|
||||
|
||||
# This file is using docker to run commands
|
||||
SPC_DOCKER_VERSION=v5
|
||||
SPC_DOCKER_VERSION=v6
|
||||
|
||||
# Detect docker can run
|
||||
if ! which docker >/dev/null; then
|
||||
@@ -113,6 +113,7 @@ ENV PATH="/app/bin:/cmake/bin:/opt/rh/devtoolset-10/root/usr/bin:\$PATH"
|
||||
|
||||
ADD ./config /app/config
|
||||
RUN CC=gcc bin/spc doctor --auto-fix --debug
|
||||
RUN bin/spc install-pkg upx
|
||||
RUN if [ -f /app/buildroot/bin/re2c ]; then \
|
||||
cp /app/buildroot/bin/re2c /usr/local/bin/re2c ;\
|
||||
fi
|
||||
@@ -132,6 +133,11 @@ RUN curl -o automake.tgz -fsSL https://ftp.gnu.org/gnu/automake/automake-1.17.ta
|
||||
make && \
|
||||
make install && \
|
||||
ln -sf /usr/local/bin/automake /usr/bin/automake
|
||||
|
||||
RUN mv /app/pkgroot/\$(uname -m)-linux /app/pkgroot-private
|
||||
ADD bin/docker-entrypoint.sh /bin/docker-entrypoint.sh
|
||||
RUN chmod +x /bin/docker-entrypoint.sh
|
||||
ENTRYPOINT ["/bin/docker-entrypoint.sh"]
|
||||
EOF
|
||||
fi
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"symfony/console": "^5.4 || ^6 || ^7",
|
||||
"symfony/process": "^7.2",
|
||||
"symfony/yaml": "^7.2",
|
||||
"zhamao/logger": "^1.0"
|
||||
"zhamao/logger": "^1.1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"captainhook/captainhook-phar": "^5.23",
|
||||
|
||||
398
composer.lock
generated
398
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -103,7 +103,7 @@ SPC_MICRO_PATCHES=cli_checks,disable_huge_page
|
||||
; buildconf command
|
||||
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
|
||||
; configure command
|
||||
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --disable-shared --enable-static --disable-all --disable-cgi --disable-phpdbg --with-pic"
|
||||
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --disable-shared --enable-static --disable-all --disable-phpdbg --with-pic"
|
||||
; make command
|
||||
SPC_CMD_PREFIX_PHP_MAKE="make -j${SPC_CONCURRENCY}"
|
||||
|
||||
@@ -124,6 +124,8 @@ SPC_TARGET=native-macos
|
||||
; compiler environments
|
||||
CC=clang
|
||||
CXX=clang++
|
||||
AR=ar
|
||||
LD=ld
|
||||
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
|
||||
SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
|
||||
SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
|
||||
@@ -135,7 +137,7 @@ SPC_MICRO_PATCHES=cli_checks,macos_iconv
|
||||
; buildconf command
|
||||
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
|
||||
; configure command
|
||||
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg"
|
||||
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-phpdbg"
|
||||
; make command
|
||||
SPC_CMD_PREFIX_PHP_MAKE="make -j${SPC_CONCURRENCY}"
|
||||
|
||||
|
||||
@@ -694,7 +694,8 @@
|
||||
"arg-type": "custom",
|
||||
"ext-suggests": [
|
||||
"session",
|
||||
"igbinary"
|
||||
"igbinary",
|
||||
"msgpack"
|
||||
],
|
||||
"lib-suggests-unix": [
|
||||
"zstd",
|
||||
@@ -841,14 +842,23 @@
|
||||
"nghttp2",
|
||||
"zlib"
|
||||
],
|
||||
"lib-suggests": [
|
||||
"zstd"
|
||||
],
|
||||
"lib-suggests-linux": [
|
||||
"zstd",
|
||||
"liburing"
|
||||
],
|
||||
"ext-depends": [
|
||||
"openssl",
|
||||
"curl"
|
||||
],
|
||||
"ext-suggests": [
|
||||
"sockets",
|
||||
"swoole-hook-pgsql",
|
||||
"swoole-hook-mysql",
|
||||
"swoole-hook-sqlite"
|
||||
"swoole-hook-sqlite",
|
||||
"swoole-hook-odbc"
|
||||
]
|
||||
},
|
||||
"swoole-hook-mysql": {
|
||||
@@ -858,11 +868,12 @@
|
||||
},
|
||||
"notes": true,
|
||||
"type": "addon",
|
||||
"arg-type": "custom",
|
||||
"arg-type": "none",
|
||||
"ext-depends": [
|
||||
"mysqlnd",
|
||||
"pdo",
|
||||
"pdo_mysql"
|
||||
"pdo_mysql",
|
||||
"swoole"
|
||||
],
|
||||
"ext-suggests": [
|
||||
"mysqli"
|
||||
@@ -876,10 +887,11 @@
|
||||
},
|
||||
"notes": true,
|
||||
"type": "addon",
|
||||
"arg-type": "custom",
|
||||
"arg-type": "none",
|
||||
"ext-depends": [
|
||||
"pgsql",
|
||||
"pdo"
|
||||
"pdo",
|
||||
"swoole"
|
||||
]
|
||||
},
|
||||
"swoole-hook-sqlite": {
|
||||
@@ -889,10 +901,27 @@
|
||||
},
|
||||
"notes": true,
|
||||
"type": "addon",
|
||||
"arg-type": "custom",
|
||||
"arg-type": "none",
|
||||
"ext-depends": [
|
||||
"sqlite3",
|
||||
"pdo"
|
||||
"pdo",
|
||||
"swoole"
|
||||
]
|
||||
},
|
||||
"swoole-hook-odbc": {
|
||||
"support": {
|
||||
"Windows": "no",
|
||||
"BSD": "wip"
|
||||
},
|
||||
"notes": true,
|
||||
"type": "addon",
|
||||
"arg-type": "none",
|
||||
"ext-depends": [
|
||||
"pdo",
|
||||
"swoole"
|
||||
],
|
||||
"lib-depends": [
|
||||
"unixodbc"
|
||||
]
|
||||
},
|
||||
"swow": {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
{
|
||||
"lib-base": {
|
||||
"type": "root",
|
||||
"lib-depends-unix": [
|
||||
"pkg-config"
|
||||
]
|
||||
"type": "root"
|
||||
},
|
||||
"php": {
|
||||
"type": "root",
|
||||
@@ -13,7 +10,16 @@
|
||||
"micro"
|
||||
],
|
||||
"lib-suggests-linux": [
|
||||
"libacl"
|
||||
"libacl",
|
||||
"brotli",
|
||||
"watcher"
|
||||
],
|
||||
"lib-suggests-unix": [
|
||||
"brotli",
|
||||
"watcher"
|
||||
],
|
||||
"lib-depends-macos": [
|
||||
"libxml2"
|
||||
]
|
||||
},
|
||||
"micro": {
|
||||
@@ -919,5 +925,20 @@
|
||||
"zstd.h",
|
||||
"zstd_errors.h"
|
||||
]
|
||||
},
|
||||
"liburing": {
|
||||
"source": "liburing",
|
||||
"pkg-configs": [
|
||||
"liburing",
|
||||
"liburing-ffi"
|
||||
],
|
||||
"static-libs-linux": [
|
||||
"liburing.a",
|
||||
"liburing-ffi.a"
|
||||
],
|
||||
"headers-linux": [
|
||||
"liburing/",
|
||||
"liburing.h"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
{
|
||||
"go-xcaddy-aarch64-linux": {
|
||||
"type": "custom"
|
||||
},
|
||||
"go-xcaddy-aarch64-macos": {
|
||||
"type": "custom"
|
||||
},
|
||||
"go-xcaddy-x86_64-linux": {
|
||||
"type": "custom"
|
||||
},
|
||||
"go-xcaddy-x86_64-macos": {
|
||||
"type": "custom"
|
||||
},
|
||||
"musl-toolchain-aarch64-linux": {
|
||||
"type": "url",
|
||||
"url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/aarch64-musl-toolchain.tgz"
|
||||
@@ -15,6 +27,38 @@
|
||||
"nasm-2.16.01/ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe"
|
||||
}
|
||||
},
|
||||
"pkg-config-aarch64-linux": {
|
||||
"type": "ghrel",
|
||||
"repo": "static-php/static-php-cli-hosted",
|
||||
"match": "pkg-config-aarch64-linux-musl-1.2.5.txz",
|
||||
"extract-files": {
|
||||
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
|
||||
}
|
||||
},
|
||||
"pkg-config-aarch64-macos": {
|
||||
"type": "ghrel",
|
||||
"repo": "static-php/static-php-cli-hosted",
|
||||
"match": "pkg-config-aarch64-darwin.txz",
|
||||
"extract-files": {
|
||||
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
|
||||
}
|
||||
},
|
||||
"pkg-config-x86_64-linux": {
|
||||
"type": "ghrel",
|
||||
"repo": "static-php/static-php-cli-hosted",
|
||||
"match": "pkg-config-x86_64-linux-musl-1.2.5.txz",
|
||||
"extract-files": {
|
||||
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
|
||||
}
|
||||
},
|
||||
"pkg-config-x86_64-macos": {
|
||||
"type": "ghrel",
|
||||
"repo": "static-php/static-php-cli-hosted",
|
||||
"match": "pkg-config-x86_64-darwin.txz",
|
||||
"extract-files": {
|
||||
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
|
||||
}
|
||||
},
|
||||
"strawberry-perl-x86_64-win": {
|
||||
"type": "url",
|
||||
"url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip"
|
||||
@@ -43,30 +87,18 @@
|
||||
"upx-*-win64/upx.exe": "{pkg_root_path}/bin/upx.exe"
|
||||
}
|
||||
},
|
||||
"go-xcaddy-x86_64-linux": {
|
||||
"zig-aarch64-linux": {
|
||||
"type": "custom"
|
||||
},
|
||||
"go-xcaddy-aarch64-linux": {
|
||||
"type": "custom"
|
||||
},
|
||||
"go-xcaddy-x86_64-macos": {
|
||||
"type": "custom"
|
||||
},
|
||||
"go-xcaddy-aarch64-macos": {
|
||||
"zig-aarch64-macos": {
|
||||
"type": "custom"
|
||||
},
|
||||
"zig-x86_64-linux": {
|
||||
"type": "custom"
|
||||
},
|
||||
"zig-aarch64-linux": {
|
||||
"type": "custom"
|
||||
},
|
||||
"zig-x86_64-macos": {
|
||||
"type": "custom"
|
||||
},
|
||||
"zig-aarch64-macos": {
|
||||
"type": "custom"
|
||||
},
|
||||
"zig-x86_64-win": {
|
||||
"type": "custom"
|
||||
}
|
||||
|
||||
@@ -1136,5 +1136,14 @@
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"liburing": {
|
||||
"type": "ghtar",
|
||||
"repo": "axboe/liburing",
|
||||
"prefer-stable": true,
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "COPYING"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,6 +51,14 @@ export default {
|
||||
footer: {
|
||||
message: 'Released under the MIT License.',
|
||||
copyright: 'Copyright © 2023-present crazywhalecc'
|
||||
}
|
||||
},
|
||||
search: {
|
||||
provider: 'algolia',
|
||||
options: {
|
||||
appId: 'IHJHUB1SF1',
|
||||
apiKey: '8266d31cc2ffbd0e059f1c6e5bdaf8fc',
|
||||
indexName: 'static-php docs',
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,14 @@ If you use `swoole,swoole-hook-sqlite`, you will enable the coroutine mode of Sw
|
||||
swoole-hook-sqlite conflicts with the `pdo_sqlite` extension. If you want to use Swoole and `pdo_sqlite`, please delete the pdo_sqlite extension and enable `swoole` and `swoole-hook-sqlite`.
|
||||
This extension contains an implementation of the coroutine environment for `pdo_sqlite`.
|
||||
|
||||
## swoole-hook-odbc
|
||||
|
||||
swoole-hook-odbc is not an extension, it's a Hook feature of Swoole.
|
||||
If you use `swoole,swoole-hook-odbc`, you will enable the coroutine mode of Swoole's `odbc` extension.
|
||||
|
||||
swoole-hook-odbc conflicts with the `pdo_odbc` extension. If you want to use Swoole and `pdo_odbc`, please delete the `pdo_odbc` extension and enable `swoole` and `swoole-hook-odbc`.
|
||||
This extension contains an implementation of the coroutine environment for `pdo_odbc`.
|
||||
|
||||
## swow
|
||||
|
||||
1. Only PHP 8.0+ is supported.
|
||||
|
||||
@@ -172,7 +172,7 @@ If the build is successful, you will see the `buildroot/bin` directory in the cu
|
||||
If the build fails, you can use the `--debug` parameter to view detailed error information,
|
||||
or use the `--with-clean` to clear the old compilation results and recompile.
|
||||
|
||||
If the build still fails to use the above method, please submit an issue and attach your `craft.yml` and `craft.log`.
|
||||
If the build still fails to use the above method, please submit an issue and attach your `craft.yml` and `./log` archive.
|
||||
|
||||
## Step-by-step build command
|
||||
|
||||
@@ -289,6 +289,7 @@ You need to specify a compilation target, choose from the following parameters:
|
||||
|
||||
- `--build-cli`: Build a cli sapi (command line interface, which can execute PHP code on the command line)
|
||||
- `--build-fpm`: Build a fpm sapi (php-fpm, used in conjunction with other traditional fpm architecture software such as nginx)
|
||||
- `--build-cgi`: Build a cgi sapi (cgi, rarely used)
|
||||
- `--build-micro`: Build a micro sapi (used to build a standalone executable binary containing PHP code)
|
||||
- `--build-embed`: Build an embed sapi (used to embed into other C language programs)
|
||||
- `--build-frankenphp`: Build a [FrankenPHP](https://github.com/php/frankenphp) executable
|
||||
|
||||
@@ -43,6 +43,14 @@ swoole-hook-sqlite 不是一个扩展,而是 Swoole 的 Hook 特性。
|
||||
swoole-hook-sqlite 与 `pdo_sqlite` 扩展冲突。如需使用 Swoole 和 `pdo_sqlite`,请删除 pdo_sqlite 扩展,启用 `swoole` 和 `swoole-hook-sqlite` 即可。
|
||||
该扩展包含了 `pdo_sqlite` 的协程环境的实现。
|
||||
|
||||
## swoole-hook-odbc
|
||||
|
||||
swoole-hook-odbc 不是一个扩展,而是 Swoole 的 Hook 特性。
|
||||
如果你在编译时添加了 `swoole,swoole-hook-odbc`,你将启用 Swoole 的 `odbc` 扩展的协程模式。
|
||||
|
||||
swoole-hook-odbc 与 `pdo_odbc` 扩展冲突。如需使用 Swoole 和 `pdo_odbc`,请删除 `pdo_odbc` 扩展,启用 `swoole` 和 `swoole-hook-odbc` 即可。
|
||||
该扩展包含了 `pdo_odbc` 的协程环境的实现。
|
||||
|
||||
## swow
|
||||
|
||||
1. swow 仅支持 PHP 8.0+ 版本。
|
||||
|
||||
@@ -149,7 +149,7 @@ bin/spc craft --debug
|
||||
|
||||
如果中途构建出错,你可以使用 `--debug` 参数查看详细的错误信息,或者使用 `--with-clean` 参数清除旧的编译结果,重新编译。
|
||||
|
||||
如使用以上方式仍构建失败,请提交一个 issue,附上你的 `craft.yml`、`craft.log`。
|
||||
如使用以上方式仍构建失败,请提交一个 issue,附上你的 `craft.yml` 文件、`log/` 目录的压缩包。
|
||||
|
||||
## 分步构建命令
|
||||
|
||||
@@ -249,6 +249,7 @@ bin/spc doctor --auto-fix
|
||||
|
||||
- `--build-cli`: 构建一个 cli sapi(命令行界面,可在命令行执行 PHP 代码)
|
||||
- `--build-fpm`: 构建一个 fpm sapi(php-fpm,用于和其他传统的 fpm 架构的软件如 nginx 配合使用)
|
||||
- `--build-cgi`: 构建一个 cgi sapi(cgi,可用于传统的 cgi 架构的软件如 apache 配合使用)
|
||||
- `--build-micro`: 构建一个 micro sapi(用于构建一个包含 PHP 代码的独立可执行二进制)
|
||||
- `--build-embed`: 构建一个 embed sapi(用于嵌入到其他 C 语言程序中)
|
||||
- `--build-frankenphp`: 构建一个 [frankenphp](https://github.com/php/frankenphp) 二进制
|
||||
|
||||
@@ -8,6 +8,8 @@ parameters:
|
||||
- '#class Fiber#'
|
||||
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
|
||||
- '#Function Swoole\\Coroutine\\run not found.#'
|
||||
- '#Static call to instance method ZM\\Logger\\ConsoleColor#'
|
||||
- '#Constant GNU_ARCH not found#'
|
||||
dynamicConstantNames:
|
||||
- PHP_OS_FAMILY
|
||||
excludePaths:
|
||||
|
||||
@@ -34,7 +34,7 @@ use Symfony\Component\Console\Application;
|
||||
*/
|
||||
final class ConsoleApplication extends Application
|
||||
{
|
||||
public const VERSION = '2.7.0';
|
||||
public const string VERSION = '2.7.3';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@@ -4,18 +4,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder;
|
||||
|
||||
use PharIo\FileSystem\File;
|
||||
use SPC\exception\ExceptionHandler;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\BuildFailureException;
|
||||
use SPC\exception\InterruptException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\LockFile;
|
||||
use SPC\store\SourceManager;
|
||||
use SPC\store\SourcePatcher;
|
||||
use SPC\util\CustomExt;
|
||||
use SPC\util\AttributeMapper;
|
||||
|
||||
abstract class BuilderBase
|
||||
{
|
||||
@@ -46,20 +43,14 @@ abstract class BuilderBase
|
||||
/**
|
||||
* Convert libraries to class
|
||||
*
|
||||
* @param array<string> $sorted_libraries Libraries to build (if not empty, must sort first)
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
* @param array<string> $sorted_libraries Libraries to build (if not empty, must sort first)
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract public function proveLibs(array $sorted_libraries);
|
||||
|
||||
/**
|
||||
* Set-Up libraries
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function setupLibs(): void
|
||||
{
|
||||
@@ -70,12 +61,11 @@ abstract class BuilderBase
|
||||
match ($status) {
|
||||
LIB_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] setup success, took ' . round(microtime(true) - $starttime, 2) . ' s'),
|
||||
LIB_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
|
||||
LIB_STATUS_BUILD_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'),
|
||||
LIB_STATUS_INSTALL_FAILED => logger()->error('lib [' . $lib::NAME . '] install failed'),
|
||||
default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'),
|
||||
};
|
||||
if (in_array($status, [LIB_STATUS_BUILD_FAILED, LIB_STATUS_INSTALL_FAILED])) {
|
||||
throw new RuntimeException('Library [' . $lib::NAME . '] setup failed.');
|
||||
throw new BuildFailureException('Library [' . $lib::NAME . '] setup failed.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,9 +129,6 @@ abstract class BuilderBase
|
||||
|
||||
/**
|
||||
* Check if there is a cpp extensions or libraries.
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function hasCpp(): bool
|
||||
{
|
||||
@@ -174,15 +161,10 @@ abstract class BuilderBase
|
||||
/**
|
||||
* Verify the list of "ext" extensions for validity and declare an Extension object to check the dependencies of the extensions.
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws \ReflectionException
|
||||
* @throws \Throwable|WrongUsageException
|
||||
* @internal
|
||||
*/
|
||||
public function proveExts(array $static_extensions, array $shared_extensions = [], bool $skip_check_deps = false, bool $skip_extract = false): void
|
||||
{
|
||||
CustomExt::loadCustomExt();
|
||||
// judge ext
|
||||
foreach ($static_extensions as $ext) {
|
||||
// if extension does not support static build, throw exception
|
||||
@@ -213,7 +195,7 @@ abstract class BuilderBase
|
||||
}
|
||||
|
||||
foreach ([...$static_extensions, ...$shared_extensions] as $extension) {
|
||||
$class = CustomExt::getExtClass($extension);
|
||||
$class = AttributeMapper::getExtensionClassByName($extension) ?? Extension::class;
|
||||
/** @var Extension $ext */
|
||||
$ext = new $class($extension, $this);
|
||||
if (in_array($extension, $static_extensions)) {
|
||||
@@ -248,9 +230,7 @@ abstract class BuilderBase
|
||||
abstract public function testPHP(int $build_target = BUILD_TARGET_NONE);
|
||||
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
* Build shared extensions.
|
||||
*/
|
||||
public function buildSharedExts(): void
|
||||
{
|
||||
@@ -273,9 +253,8 @@ abstract class BuilderBase
|
||||
}
|
||||
$ext->buildShared();
|
||||
}
|
||||
} catch (RuntimeException $e) {
|
||||
} finally {
|
||||
FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line);
|
||||
throw $e;
|
||||
}
|
||||
FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line);
|
||||
FileSystem::replaceFileStr(BUILD_LIB_PATH . '/php/build/phpize.m4', '# test "[$]$1" = "no" && $1=yes', 'test "[$]$1" = "no" && $1=yes');
|
||||
@@ -284,19 +263,16 @@ abstract class BuilderBase
|
||||
/**
|
||||
* Generate extension enable arguments for configure.
|
||||
* e.g. --enable-mbstring
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function makeStaticExtensionArgs(): string
|
||||
{
|
||||
$ret = [];
|
||||
foreach ($this->getExts() as $ext) {
|
||||
$arg = $ext->getConfigureArg();
|
||||
$arg = null;
|
||||
if ($ext->isBuildShared() && !$ext->isBuildStatic()) {
|
||||
if (
|
||||
(Config::getExt($ext->getName(), 'type') === 'builtin' &&
|
||||
!file_exists(SOURCE_PATH . '/php-src/ext/' . $ext->getName() . '/config.m4')) ||
|
||||
!file_exists(SOURCE_PATH . '/php-src/ext/' . $ext->getName() . '/config.m4')) ||
|
||||
Config::getExt($ext->getName(), 'build-with-php') === true
|
||||
) {
|
||||
$arg = $ext->getConfigureArg(true);
|
||||
@@ -304,6 +280,7 @@ abstract class BuilderBase
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$arg ??= $ext->getConfigureArg();
|
||||
logger()->info($ext->getName() . ' is using ' . $arg);
|
||||
$ret[] = trim($arg);
|
||||
}
|
||||
@@ -321,9 +298,6 @@ abstract class BuilderBase
|
||||
|
||||
/**
|
||||
* Get PHP Version ID from php-src/main/php_version.h
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function getPHPVersionID(): int
|
||||
{
|
||||
@@ -336,7 +310,7 @@ abstract class BuilderBase
|
||||
return intval($match[1]);
|
||||
}
|
||||
|
||||
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
|
||||
throw new WrongUsageException('PHP version file format is malformed, please remove "./source/php-src" dir and download/extract again');
|
||||
}
|
||||
|
||||
public function getPHPVersion(bool $exception_on_failure = true): string
|
||||
@@ -354,7 +328,7 @@ abstract class BuilderBase
|
||||
if (!$exception_on_failure) {
|
||||
return 'unknown';
|
||||
}
|
||||
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
|
||||
throw new WrongUsageException('PHP version file format is malformed, please remove it and download again');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -418,6 +392,9 @@ abstract class BuilderBase
|
||||
if (($type & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP) {
|
||||
$ls[] = 'frankenphp';
|
||||
}
|
||||
if (($type & BUILD_TARGET_CGI) === BUILD_TARGET_CGI) {
|
||||
$ls[] = 'cgi';
|
||||
}
|
||||
return implode(', ', $ls);
|
||||
}
|
||||
|
||||
@@ -501,7 +478,7 @@ abstract class BuilderBase
|
||||
foreach ($patches as $patch) {
|
||||
try {
|
||||
if (!file_exists($patch)) {
|
||||
throw new RuntimeException("Additional patch script file {$patch} not found!");
|
||||
throw new WrongUsageException("Additional patch script file {$patch} not found!");
|
||||
}
|
||||
logger()->debug('Running additional patch script: ' . $patch);
|
||||
require $patch;
|
||||
@@ -514,11 +491,6 @@ abstract class BuilderBase
|
||||
exit($e->getCode());
|
||||
} catch (\Throwable $e) {
|
||||
logger()->critical('Patch script ' . $patch . ' failed to run.');
|
||||
if ($this->getOption('debug')) {
|
||||
ExceptionHandler::getInstance()->handle($e);
|
||||
} else {
|
||||
logger()->critical('Please check with --debug option to see more details.');
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@ use SPC\builder\freebsd\BSDBuilder;
|
||||
use SPC\builder\linux\LinuxBuilder;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\builder\windows\WindowsBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\ExceptionHandler;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
@@ -20,11 +19,6 @@ class BuilderProvider
|
||||
{
|
||||
private static ?BuilderBase $builder = null;
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public static function makeBuilderByInput(InputInterface $input): BuilderBase
|
||||
{
|
||||
ini_set('memory_limit', '4G');
|
||||
@@ -36,12 +30,13 @@ class BuilderProvider
|
||||
'BSD' => new BSDBuilder($input->getOptions()),
|
||||
default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'),
|
||||
};
|
||||
|
||||
// bind the builder to ExceptionHandler
|
||||
ExceptionHandler::bindBuilder(self::$builder);
|
||||
|
||||
return self::$builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public static function getBuilder(): BuilderBase
|
||||
{
|
||||
if (self::$builder === null) {
|
||||
|
||||
@@ -4,8 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\EnvironmentException;
|
||||
use SPC\exception\SPCException;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
@@ -24,21 +25,16 @@ class Extension
|
||||
|
||||
protected string $source_dir;
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function __construct(protected string $name, protected BuilderBase $builder)
|
||||
{
|
||||
$ext_type = Config::getExt($this->name, 'type');
|
||||
$unix_only = Config::getExt($this->name, 'unix-only', false);
|
||||
$windows_only = Config::getExt($this->name, 'windows-only', false);
|
||||
if (PHP_OS_FAMILY !== 'Windows' && $windows_only) {
|
||||
throw new RuntimeException("{$ext_type} extension {$name} is not supported on Linux and macOS platform");
|
||||
throw new EnvironmentException("{$ext_type} extension {$name} is not supported on Linux and macOS platform");
|
||||
}
|
||||
if (PHP_OS_FAMILY === 'Windows' && $unix_only) {
|
||||
throw new RuntimeException("{$ext_type} extension {$name} is not supported on Windows platform");
|
||||
throw new EnvironmentException("{$ext_type} extension {$name} is not supported on Windows platform");
|
||||
}
|
||||
// set source_dir for builtin
|
||||
if ($ext_type === 'builtin') {
|
||||
@@ -46,7 +42,7 @@ class Extension
|
||||
} elseif ($ext_type === 'external') {
|
||||
$source = Config::getExt($this->name, 'source');
|
||||
if ($source === null) {
|
||||
throw new RuntimeException("{$ext_type} extension {$name} source not found");
|
||||
throw new ValidationException("{$ext_type} extension {$name} source not found", validation_module: "Extension [{$name}] loader");
|
||||
}
|
||||
$source_path = Config::getSource($source)['path'] ?? null;
|
||||
$source_path = $source_path === null ? SOURCE_PATH . '/' . $source : SOURCE_PATH . '/' . $source_path;
|
||||
@@ -63,9 +59,6 @@ class Extension
|
||||
|
||||
/**
|
||||
* 获取开启该扩展的 PHP 编译添加的参数
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function getConfigureArg(bool $shared = false): string
|
||||
{
|
||||
@@ -80,9 +73,6 @@ class Extension
|
||||
|
||||
/**
|
||||
* 根据 ext 的 arg-type 获取对应开启的参数,一般都是 --enable-xxx 和 --with-xxx
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function getEnableArg(bool $shared = false): string
|
||||
{
|
||||
@@ -112,10 +102,6 @@ class Extension
|
||||
|
||||
/**
|
||||
* 检查下依赖就行了,作用是导入依赖给 Extension 对象,今后可以对库依赖进行选择性处理
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function checkDependency(): static
|
||||
{
|
||||
@@ -259,8 +245,6 @@ class Extension
|
||||
* i.e.; pdo_pgsql would return:
|
||||
*
|
||||
* `-d "extension=pgsql" -d "extension=pdo_pgsql"`
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function getSharedExtensionLoadString(): string
|
||||
{
|
||||
@@ -268,12 +252,15 @@ class Extension
|
||||
$order = [];
|
||||
|
||||
$resolve = function ($extension) use (&$resolve, &$loaded, &$order) {
|
||||
if (!$extension instanceof Extension) {
|
||||
return;
|
||||
}
|
||||
if (isset($loaded[$extension->getName()])) {
|
||||
return;
|
||||
}
|
||||
$loaded[$extension->getName()] = true;
|
||||
|
||||
foreach ($this->dependencies as $dependency) {
|
||||
foreach ($extension->dependencies as $dependency) {
|
||||
$resolve($dependency);
|
||||
}
|
||||
|
||||
@@ -285,6 +272,9 @@ class Extension
|
||||
$ret = '';
|
||||
foreach ($order as $ext) {
|
||||
if ($ext instanceof self && $ext->isBuildShared()) {
|
||||
if (Config::getExt($ext->getName(), 'type', false) === 'addon') {
|
||||
continue;
|
||||
}
|
||||
if (Config::getExt($ext->getName(), 'zend-extension', false) === true) {
|
||||
$ret .= " -d \"zend_extension={$ext->getName()}\"";
|
||||
} else {
|
||||
@@ -300,20 +290,16 @@ class Extension
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function runCliCheckUnix(): void
|
||||
{
|
||||
// Run compile check if build target is cli
|
||||
// If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php
|
||||
// If check failed, throw RuntimeException
|
||||
$sharedExtensions = $this->getSharedExtensionLoadString();
|
||||
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException(
|
||||
'extension ' . $this->getName() . ' failed runtime check: php-cli returned ' . $ret . "\n" .
|
||||
join("\n", $out)
|
||||
throw new ValidationException(
|
||||
"extension {$this->getName()} failed compile check: php-cli returned {$ret}",
|
||||
validation_module: 'Extension ' . $this->getName() . ' sanity check'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -327,23 +313,21 @@ class Extension
|
||||
|
||||
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' -r "' . trim($test) . '"');
|
||||
if ($ret !== 0) {
|
||||
var_dump($out);
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||
throw new ValidationException(
|
||||
"extension {$this->getName()} failed sanity check. Code: {$ret}, output: " . implode("\n", $out),
|
||||
validation_module: 'Extension ' . $this->getName() . ' function check'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function runCliCheckWindows(): void
|
||||
{
|
||||
// Run compile check if build target is cli
|
||||
// If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php
|
||||
// If check failed, throw RuntimeException
|
||||
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n --ri "' . $this->getDistName() . '"', false);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check");
|
||||
}
|
||||
|
||||
if (file_exists(FileSystem::convertPath(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php'))) {
|
||||
@@ -356,7 +340,10 @@ class Extension
|
||||
|
||||
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n -r "' . trim($test) . '"');
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||
throw new ValidationException(
|
||||
"extension {$this->getName()} failed function check",
|
||||
validation_module: "Extension {$this->getName()} function check"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -368,50 +355,50 @@ class Extension
|
||||
|
||||
/**
|
||||
* Build shared extension
|
||||
*
|
||||
* @throws WrongUsageException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function buildShared(): void
|
||||
public function buildShared(array $visited = []): void
|
||||
{
|
||||
if (Config::getExt($this->getName(), 'type') === 'builtin' || Config::getExt($this->getName(), 'build-with-php') === true) {
|
||||
try {
|
||||
if (Config::getExt($this->getName(), 'type') === 'builtin' || Config::getExt($this->getName(), 'build-with-php') === true) {
|
||||
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
|
||||
logger()->info('Shared extension [' . $this->getName() . '] was already built by php-src/configure (' . $this->getName() . '.so)');
|
||||
return;
|
||||
}
|
||||
if (Config::getExt($this->getName(), 'build-with-php') === true) {
|
||||
logger()->warning('Shared extension [' . $this->getName() . '] did not build with php-src/configure (' . $this->getName() . '.so)');
|
||||
logger()->warning('Try deleting your build and source folders and running `spc build`` again.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
|
||||
logger()->info('Shared extension [' . $this->getName() . '] was already built by php-src/configure (' . $this->getName() . '.so)');
|
||||
logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)');
|
||||
return;
|
||||
}
|
||||
if (Config::getExt($this->getName(), 'build-with-php') === true) {
|
||||
logger()->warning('Shared extension [' . $this->getName() . '] did not build with php-src/configure (' . $this->getName() . '.so)');
|
||||
logger()->warning('Try deleting your build and source folders and running `spc build`` again.');
|
||||
logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
|
||||
foreach ($this->dependencies as $dependency) {
|
||||
if (!$dependency instanceof Extension) {
|
||||
continue;
|
||||
}
|
||||
if (!$dependency->isBuildStatic() && !in_array($dependency->getName(), $visited)) {
|
||||
logger()->info('extension ' . $this->getName() . ' requires extension ' . $dependency->getName());
|
||||
$dependency->buildShared([...$visited, $this->getName()]);
|
||||
}
|
||||
}
|
||||
if (Config::getExt($this->getName(), 'type') === 'addon') {
|
||||
return;
|
||||
}
|
||||
match (PHP_OS_FAMILY) {
|
||||
'Darwin', 'Linux' => $this->buildUnixShared(),
|
||||
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'),
|
||||
};
|
||||
} catch (SPCException $e) {
|
||||
$e->bindExtensionInfo(['extension_name' => $this->getName()]);
|
||||
throw $e;
|
||||
}
|
||||
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
|
||||
logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)');
|
||||
}
|
||||
logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)');
|
||||
foreach ($this->dependencies as $dependency) {
|
||||
if (!$dependency instanceof Extension) {
|
||||
continue;
|
||||
}
|
||||
if (!$dependency->isBuildStatic()) {
|
||||
logger()->info('extension ' . $this->getName() . ' requires extension ' . $dependency->getName());
|
||||
$dependency->buildShared();
|
||||
}
|
||||
}
|
||||
match (PHP_OS_FAMILY) {
|
||||
'Darwin', 'Linux' => $this->buildUnixShared(),
|
||||
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Build shared extension for Unix
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
* @throws \ReflectionException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function buildUnixShared(): void
|
||||
{
|
||||
@@ -506,15 +493,12 @@ class Extension
|
||||
return $this->build_static;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function addLibraryDependency(string $name, bool $optional = false): void
|
||||
{
|
||||
$depLib = $this->builder->getLib($name);
|
||||
if (!$depLib) {
|
||||
if (!$optional) {
|
||||
throw new RuntimeException("extension {$this->name} requires library {$name}");
|
||||
throw new WrongUsageException("extension {$this->name} requires library {$name}");
|
||||
}
|
||||
logger()->info("enabling {$this->name} without library {$name}");
|
||||
} else {
|
||||
@@ -522,15 +506,12 @@ class Extension
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function addExtensionDependency(string $name, bool $optional = false): void
|
||||
{
|
||||
$depExt = $this->builder->getExt($name);
|
||||
if (!$depExt) {
|
||||
if (!$optional) {
|
||||
throw new RuntimeException("{$this->name} requires extension {$name}");
|
||||
throw new WrongUsageException("{$this->name} requires extension {$name} which is not included");
|
||||
}
|
||||
logger()->info("enabling {$this->name} without extension {$name}");
|
||||
} else {
|
||||
|
||||
@@ -4,8 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\SPCException;
|
||||
use SPC\exception\SPCInternalException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\Downloader;
|
||||
@@ -27,23 +27,17 @@ abstract class LibraryBase
|
||||
|
||||
protected bool $patched = false;
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function __construct(?string $source_dir = null)
|
||||
{
|
||||
if (static::NAME === 'unknown') {
|
||||
throw new RuntimeException('no unknown!!!!!');
|
||||
throw new SPCInternalException('Please set the NAME constant in ' . static::class);
|
||||
}
|
||||
$this->source_dir = $source_dir ?? (SOURCE_PATH . '/' . Config::getLib(static::NAME, 'source'));
|
||||
$this->source_dir = $source_dir ?? (SOURCE_PATH . DIRECTORY_SEPARATOR . Config::getLib(static::NAME, 'source'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to install or build this library.
|
||||
* @param bool $force If true, force install or build
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
* @param bool $force If true, force install or build
|
||||
*/
|
||||
public function setup(bool $force = false): int
|
||||
{
|
||||
@@ -107,10 +101,6 @@ abstract class LibraryBase
|
||||
|
||||
/**
|
||||
* Calculate dependencies for current library.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function calcDependency(): void
|
||||
{
|
||||
@@ -131,9 +121,6 @@ abstract class LibraryBase
|
||||
|
||||
/**
|
||||
* Get config static libs.
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function getStaticLibs(): array
|
||||
{
|
||||
@@ -142,9 +129,6 @@ abstract class LibraryBase
|
||||
|
||||
/**
|
||||
* Get config headers.
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function getHeaders(): array
|
||||
{
|
||||
@@ -153,19 +137,12 @@ abstract class LibraryBase
|
||||
|
||||
/**
|
||||
* Get binary files.
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function getBinaryFiles(): array
|
||||
{
|
||||
return Config::getLib(static::NAME, 'bin', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function tryInstall(array $lock, bool $force_install = false): int
|
||||
{
|
||||
$install_file = $lock['filename'];
|
||||
@@ -177,7 +154,7 @@ abstract class LibraryBase
|
||||
FileSystem::extractPackage($install_file, $lock['source_type'], DOWNLOAD_PATH . '/' . $install_file, BUILD_ROOT_PATH);
|
||||
$this->install();
|
||||
return LIB_STATUS_OK;
|
||||
} catch (FileSystemException|RuntimeException $e) {
|
||||
} catch (SPCException $e) {
|
||||
logger()->error('Failed to extract pre-built library [' . static::NAME . ']: ' . $e->getMessage());
|
||||
return LIB_STATUS_INSTALL_FAILED;
|
||||
}
|
||||
@@ -194,10 +171,6 @@ abstract class LibraryBase
|
||||
* BUILD_STATUS_OK if build success
|
||||
* BUILD_STATUS_ALREADY if already built
|
||||
* BUILD_STATUS_FAILED if build failed
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function tryBuild(bool $force_build = false): int
|
||||
{
|
||||
@@ -319,8 +292,6 @@ abstract class LibraryBase
|
||||
|
||||
/**
|
||||
* Build this library.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
abstract protected function build();
|
||||
|
||||
@@ -333,7 +304,7 @@ abstract class LibraryBase
|
||||
}
|
||||
$replace_items = json_decode(file_get_contents($replace_item_file), true);
|
||||
if (!is_array($replace_items)) {
|
||||
throw new RuntimeException('Invalid placeholder file: ' . $replace_item_file);
|
||||
throw new SPCInternalException("Invalid placeholder file: {$replace_item_file}");
|
||||
}
|
||||
$placeholders = get_pack_replace();
|
||||
// replace placeholders in BUILD_ROOT_PATH
|
||||
@@ -351,8 +322,6 @@ abstract class LibraryBase
|
||||
|
||||
/**
|
||||
* Add lib dependency
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function addLibraryDependency(string $name, bool $optional = false): void
|
||||
{
|
||||
@@ -362,7 +331,7 @@ abstract class LibraryBase
|
||||
return;
|
||||
}
|
||||
if (!$optional) {
|
||||
throw new RuntimeException(static::NAME . " requires library {$name}");
|
||||
throw new WrongUsageException(static::NAME . " requires library {$name} but it is not included");
|
||||
}
|
||||
logger()->debug('enabling ' . static::NAME . " without {$name}");
|
||||
}
|
||||
|
||||
@@ -6,18 +6,12 @@ namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('bz2')]
|
||||
class bz2 extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';
|
||||
|
||||
@@ -8,17 +8,13 @@ use SPC\builder\Extension;
|
||||
use SPC\builder\linux\LinuxBuilder;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\builder\windows\WindowsBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\exception\PatchException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('curl')]
|
||||
class curl extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
logger()->info('patching before-configure for curl checks');
|
||||
@@ -46,10 +42,6 @@ class curl extends Extension
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';
|
||||
@@ -105,7 +97,7 @@ class curl extends Extension
|
||||
);
|
||||
|
||||
if ($patched === null) {
|
||||
throw new \RuntimeException('Failed to patch config.m4 due to a regex error');
|
||||
throw new PatchException('shared extension curl patcher', 'Failed to patch config.m4 due to a regex error');
|
||||
}
|
||||
|
||||
FileSystem::writeFile($file, $patched);
|
||||
|
||||
@@ -5,16 +5,12 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('dom')]
|
||||
class dom extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
$arg = '--enable-dom' . ($shared ? '=shared' : '');
|
||||
|
||||
@@ -5,16 +5,12 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('ev')]
|
||||
class ev extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
@@ -27,18 +26,12 @@ class event extends Extension
|
||||
return $arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
$patched = parent::patchBeforeMake();
|
||||
|
||||
@@ -6,17 +6,12 @@ namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('gettext')]
|
||||
class gettext extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
if ($this->builder instanceof MacOSBuilder) {
|
||||
@@ -25,10 +20,6 @@ class gettext extends Extension
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
if ($this->builder instanceof MacOSBuilder) {
|
||||
|
||||
@@ -5,16 +5,12 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('glfw')]
|
||||
class glfw extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
if (file_exists(SOURCE_PATH . '/php-src/ext/glfw')) {
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\windows\WindowsBuilder;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
@@ -18,7 +19,7 @@ class grpc extends Extension
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
if ($this->builder instanceof WindowsBuilder) {
|
||||
throw new \RuntimeException('grpc extension does not support windows yet');
|
||||
throw new ValidationException('grpc extension does not support windows yet');
|
||||
}
|
||||
if (file_exists(SOURCE_PATH . '/php-src/ext/grpc')) {
|
||||
return false;
|
||||
@@ -27,7 +28,7 @@ class grpc extends Extension
|
||||
if (is_dir($this->source_dir . '/src/php/ext/grpc')) {
|
||||
shell()->exec('ln -s ' . $this->source_dir . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc');
|
||||
} else {
|
||||
throw new \RuntimeException('Cannot find grpc source code');
|
||||
throw new ValidationException('Cannot find grpc source code in ' . $this->source_dir . '/src/php/ext/grpc');
|
||||
}
|
||||
if (SPCTarget::getTargetOS() === 'Darwin') {
|
||||
FileSystem::replaceFileRegex(
|
||||
|
||||
@@ -19,7 +19,7 @@ class imagick extends Extension
|
||||
protected function splitLibsIntoStaticAndShared(string $allLibs): array
|
||||
{
|
||||
[$static, $shared] = parent::splitLibsIntoStaticAndShared($allLibs);
|
||||
if (str_contains(getenv('PATH'), 'rh/devtoolset-10')) {
|
||||
if (str_contains(getenv('PATH'), 'rh/devtoolset') || str_contains(getenv('PATH'), 'rh/gcc-toolset')) {
|
||||
$static .= ' -l:libstdc++.a';
|
||||
$shared = str_replace('-lstdc++', '', $shared);
|
||||
}
|
||||
|
||||
@@ -24,9 +24,6 @@ class imap extends Extension
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function validate(): void
|
||||
{
|
||||
if ($this->builder->getOption('enable-zts')) {
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('mbregex')]
|
||||
@@ -16,11 +16,6 @@ class mbregex extends Extension
|
||||
return 'mbstring';
|
||||
}
|
||||
|
||||
public function getConfigureArg(bool $shared = false): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* mbregex is not an extension, we need to overwrite the default check.
|
||||
*/
|
||||
@@ -29,7 +24,7 @@ class mbregex extends Extension
|
||||
$sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? '-d "extension_dir=' . BUILD_MODULES_PATH . '" -d "extension=mbstring"' : '';
|
||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedext . ' --ri "mbstring" | grep regex', false);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
|
||||
throw new ValidationException("Extension {$this->getName()} failed compile check: compiled php-cli mbstring extension does not contain regex !");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +32,11 @@ class mbregex extends Extension
|
||||
{
|
||||
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "mbstring"', false);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !');
|
||||
throw new ValidationException("extension {$this->getName()} failed compile check: compiled php-cli does not contain mbstring !");
|
||||
}
|
||||
$out = implode("\n", $out);
|
||||
if (!str_contains($out, 'regex')) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
|
||||
throw new ValidationException("extension {$this->getName()} failed compile check: compiled php-cli mbstring extension does not contain regex !");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
@@ -17,9 +16,6 @@ class memcache extends Extension
|
||||
return '--enable-memcache' . ($shared ? '=shared' : '') . ' --with-zlib-dir=' . BUILD_ROOT_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
FileSystem::replaceFileStr(
|
||||
|
||||
@@ -12,9 +12,9 @@ class mongodb extends Extension
|
||||
{
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
$arg = ' --enable-mongodb ';
|
||||
$arg = ' --enable-mongodb' . ($shared ? '=shared' : '') . ' ';
|
||||
$arg .= ' --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no ';
|
||||
$arg .= ' --with-mongodb-sasl=no ';
|
||||
$arg .= ' --with-mongodb-sasl=no ';
|
||||
if ($this->builder->getLib('openssl')) {
|
||||
$arg .= '--with-mongodb-ssl=openssl';
|
||||
}
|
||||
@@ -22,6 +22,6 @@ class mongodb extends Extension
|
||||
$arg .= $this->builder->getLib('zstd') ? ' --with-mongodb-zstd=yes ' : ' --with-mongodb-zstd=no ';
|
||||
// $arg .= $this->builder->getLib('snappy') ? ' --with-mongodb-snappy=yes ' : ' --with-mongodb-snappy=no ';
|
||||
$arg .= $this->builder->getLib('zlib') ? ' --with-mongodb-zlib=yes ' : ' --with-mongodb-zlib=bundled ';
|
||||
return $arg;
|
||||
return clean_spaces($arg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,14 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\SourcePatcher;
|
||||
use SPC\util\CustomExt;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
#[CustomExt('opcache')]
|
||||
class opcache extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function validate(): void
|
||||
{
|
||||
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
|
||||
@@ -51,7 +47,18 @@ class opcache extends Extension
|
||||
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
return '--enable-opcache';
|
||||
$phpVersionID = $this->builder->getPHPVersionID();
|
||||
$opcache_jit = ' --enable-opcache-jit';
|
||||
if ((SPCTarget::getTargetOS() === 'Linux' &&
|
||||
SPCTarget::getLibc() === 'musl' &&
|
||||
$this->builder->getOption('enable-zts') &&
|
||||
arch2gnu(php_uname('m')) === 'x86_64' &&
|
||||
$phpVersionID < 80500) ||
|
||||
$this->builder->getOption('disable-opcache-jit')
|
||||
) {
|
||||
$opcache_jit = ' --disable-opcache-jit';
|
||||
}
|
||||
return '--enable-opcache' . ($shared ? '=shared' : '') . $opcache_jit;
|
||||
}
|
||||
|
||||
public function getDistName(): string
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
@@ -15,7 +16,7 @@ class opentelemetry extends Extension
|
||||
public function validate(): void
|
||||
{
|
||||
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
|
||||
throw new \RuntimeException('The opentelemetry extension requires PHP 8.0 or later');
|
||||
throw new ValidationException('The opentelemetry extension requires PHP 8.0 or later');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('password-argon2')]
|
||||
@@ -20,7 +20,7 @@ class password_argon2 extends Extension
|
||||
{
|
||||
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n -r "assert(defined(\'PASSWORD_ARGON2I\'));"');
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||
throw new ValidationException('extension ' . $this->getName() . ' failed sanity check', validation_module: 'password_argon2 function check');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,16 +5,12 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('pdo_sqlite')]
|
||||
class pdo_sqlite extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
FileSystem::replaceFileRegex(
|
||||
|
||||
@@ -5,20 +5,12 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('pgsql')]
|
||||
class pgsql extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
FileSystem::replaceFileRegex(
|
||||
@@ -29,10 +21,6 @@ class pgsql extends Extension
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
if ($this->builder->getPHPVersionID() >= 80400) {
|
||||
@@ -46,10 +34,6 @@ class pgsql extends Extension
|
||||
return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getWindowsConfigureArg(bool $shared = false): string
|
||||
{
|
||||
if ($this->builder->getPHPVersionID() >= 80400) {
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('protobuf')]
|
||||
@@ -13,12 +14,12 @@ class protobuf extends Extension
|
||||
public function validate(): void
|
||||
{
|
||||
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
|
||||
throw new \RuntimeException('The latest protobuf extension requires PHP 8.0 or later');
|
||||
throw new ValidationException('The latest protobuf extension requires PHP 8.0 or later');
|
||||
}
|
||||
$grpc = $this->builder->getExt('grpc');
|
||||
// protobuf conflicts with grpc
|
||||
if ($grpc?->isBuildStatic()) {
|
||||
throw new \RuntimeException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
|
||||
throw new ValidationException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,12 @@ namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('rar')]
|
||||
class rar extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
// workaround for newer Xcode clang (>= 15.0)
|
||||
|
||||
@@ -5,16 +5,12 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('readline')]
|
||||
class readline extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
FileSystem::replaceFileRegex(
|
||||
|
||||
@@ -16,9 +16,11 @@ class redis extends Extension
|
||||
if ($this->isBuildStatic()) {
|
||||
$arg .= $this->builder->getExt('session')?->isBuildStatic() ? ' --enable-redis-session' : ' --disable-redis-session';
|
||||
$arg .= $this->builder->getExt('igbinary')?->isBuildStatic() ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
|
||||
$arg .= $this->builder->getExt('msgpack')?->isBuildStatic() ? ' --enable-redis-msgpack' : ' --disable-redis-msgpack';
|
||||
} else {
|
||||
$arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session';
|
||||
$arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary';
|
||||
$arg .= $this->builder->getExt('msgpack') ? ' --enable-redis-msgpack' : ' --disable-redis-msgpack';
|
||||
}
|
||||
if ($this->builder->getLib('zstd')) {
|
||||
$arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"';
|
||||
|
||||
@@ -6,16 +6,12 @@ namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('snappy')]
|
||||
class snappy extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
FileSystem::replaceFileRegex(
|
||||
|
||||
@@ -5,16 +5,12 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('ssh2')]
|
||||
class ssh2 extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeConfigure(): bool
|
||||
{
|
||||
FileSystem::replaceFileRegex(
|
||||
|
||||
@@ -8,6 +8,8 @@ use SPC\builder\Extension;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
use SPC\util\SPCConfigUtil;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
#[CustomExt('swoole')]
|
||||
class swoole extends Extension
|
||||
@@ -43,32 +45,40 @@ class swoole extends Extension
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
// enable swoole
|
||||
$arg = '--enable-swoole';
|
||||
$arg = '--enable-swoole' . ($shared ? '=shared' : '');
|
||||
|
||||
// commonly-used feature: coroutine-time, disable-thread-context
|
||||
$arg .= ' --enable-swoole-coro-time --disable-thread-context';
|
||||
// commonly used feature: coroutine-time
|
||||
$arg .= ' --enable-swoole-coro-time --with-pic';
|
||||
|
||||
// required feature: curl, openssl (but curl hook is buggy for php 8.0)
|
||||
$arg .= $this->builder->getOption('enable-zts') ? ' --enable-swoole-thread --disable-thread-context' : ' --disable-swoole-thread --enable-thread-context';
|
||||
|
||||
// required features: curl, openssl (but curl hook is buggy for php 8.0)
|
||||
$arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl';
|
||||
$arg .= ' --enable-openssl';
|
||||
|
||||
// additional feature: c-ares, brotli, nghttp2 (can be disabled, but we enable it by default in config to support full network feature)
|
||||
// additional features that only require libraries
|
||||
$arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : '';
|
||||
if (!$shared) {
|
||||
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
|
||||
}
|
||||
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : '';
|
||||
$arg .= $this->builder->getLib('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : '';
|
||||
$arg .= $this->builder->getLib('zstd') ? ' --enable-zstd' : '';
|
||||
$arg .= $this->builder->getLib('liburing') ? ' --enable-iouring' : '';
|
||||
$arg .= $this->builder->getExt('sockets') ? ' --enable-sockets' : '';
|
||||
|
||||
// additional feature: swoole-pgsql, it should depend on lib [postgresql], but it will lack of CFLAGS etc.
|
||||
// so this is a tricky way (enable ext [pgsql,pdo] to add postgresql hook and pdo_pgsql support)
|
||||
$arg .= $this->builder->getExt('swoole-hook-pgsql') ? '' : ' --disable-swoole-pgsql';
|
||||
// enable additional features that require the pdo extension, but conflict with pdo_* extensions
|
||||
// to make sure everything works as it should, this is done in fake addon extensions
|
||||
$arg .= $this->builder->getExt('swoole-hook-pgsql') ? ' --enable-swoole-pgsql' : ' --disable-swoole-pgsql';
|
||||
$arg .= $this->builder->getExt('swoole-hook-mysql') ? ' --enable-mysqlnd' : ' --disable-mysqlnd';
|
||||
$arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite';
|
||||
|
||||
// enable this feature , need remove pdo_sqlite
|
||||
// more info : https://wenda.swoole.com/detail/109023
|
||||
$arg .= $this->builder->getExt('swoole-hook-sqlite') ? '' : ' --disable-swoole-sqlite';
|
||||
if ($this->builder->getExt('swoole-hook-odbc')) {
|
||||
$config = (new SPCConfigUtil($this->builder, ['libs_only_deps' => true]))->config([], ['unixodbc']);
|
||||
$arg .= ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"';
|
||||
}
|
||||
|
||||
if (SPCTarget::getTargetOS() === 'Darwin') {
|
||||
$arg .= ' ac_cv_lib_pthread_pthread_barrier_init=no';
|
||||
}
|
||||
|
||||
// enable this feature , need stop pdo_*
|
||||
// $arg .= $this->builder->getLib('unixodbc') ? ' --with-swoole-odbc=unixODBC,' : ' ';
|
||||
return $arg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('swoole-hook-mysql')]
|
||||
@@ -16,26 +16,15 @@ class swoole_hook_mysql extends Extension
|
||||
return 'swoole';
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
// pdo_mysql doesn't need to be disabled
|
||||
// enable swoole-hook-mysql will enable mysqli, pdo, pdo_mysql, we don't need to add any additional options
|
||||
return '';
|
||||
}
|
||||
|
||||
public function runCliCheckUnix(): void
|
||||
{
|
||||
// skip if not enable swoole
|
||||
if ($this->builder->getExt('swoole') === null) {
|
||||
return;
|
||||
}
|
||||
[$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"', false);
|
||||
$out = implode('', $out);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: 'extension swoole_hook_mysql sanity check');
|
||||
}
|
||||
if (!str_contains($out, 'mysqlnd')) {
|
||||
throw new RuntimeException('swoole mysql hook is not enabled correctly.');
|
||||
throw new ValidationException('swoole mysql hook is not enabled correctly.', validation_module: 'Extension swoole mysql hook availability check');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
src/SPC/builder/extension/swoole_hook_odbc.php
Normal file
40
src/SPC/builder/extension/swoole_hook_odbc.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('swoole-hook-odbc')]
|
||||
class swoole_hook_odbc extends Extension
|
||||
{
|
||||
public function getDistName(): string
|
||||
{
|
||||
return 'swoole';
|
||||
}
|
||||
|
||||
public function validate(): void
|
||||
{
|
||||
// pdo_pgsql need to be disabled
|
||||
if ($this->builder->getExt('pdo_odbc')?->isBuildStatic()) {
|
||||
throw new WrongUsageException('swoole-hook-odbc provides pdo_odbc, if you enable odbc hook for swoole, you must remove pdo_odbc extension.');
|
||||
}
|
||||
}
|
||||
|
||||
public function runCliCheckUnix(): void
|
||||
{
|
||||
$sharedExtensions = $this->getSharedExtensionLoadString();
|
||||
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false);
|
||||
$out = implode('', $out);
|
||||
if ($ret !== 0) {
|
||||
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check");
|
||||
}
|
||||
if (!str_contains($out, 'coroutine_odbc')) {
|
||||
throw new ValidationException('swoole odbc hook is not enabled correctly.', validation_module: 'Extension swoole odbc hook availability check');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
@@ -20,31 +20,27 @@ class swoole_hook_pgsql extends Extension
|
||||
public function validate(): void
|
||||
{
|
||||
// pdo_pgsql need to be disabled
|
||||
if ($this->builder->getExt('pdo_pgsql') !== null) {
|
||||
if ($this->builder->getExt('pdo_pgsql')?->isBuildStatic()) {
|
||||
throw new WrongUsageException('swoole-hook-pgsql provides pdo_pgsql, if you enable pgsql hook for swoole, you must remove pdo_pgsql extension.');
|
||||
}
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
// enable swoole pgsql hook
|
||||
return '--enable-swoole-pgsql';
|
||||
}
|
||||
|
||||
public function runCliCheckUnix(): void
|
||||
{
|
||||
// skip if not enable swoole
|
||||
if ($this->builder->getExt('swoole') === null) {
|
||||
return;
|
||||
}
|
||||
$sharedExtensions = $this->getSharedExtensionLoadString();
|
||||
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
|
||||
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false);
|
||||
$out = implode('', $out);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||
throw new ValidationException(
|
||||
"extension {$this->getName()} failed sanity check: php-cli returned {$ret}",
|
||||
validation_module: 'Extension swoole-hook-pgsql sanity check'
|
||||
);
|
||||
}
|
||||
if (!str_contains($out, 'coroutine_pgsql')) {
|
||||
throw new RuntimeException('swoole pgsql hook is not enabled correctly.');
|
||||
throw new ValidationException(
|
||||
'swoole pgsql hook is not enabled correctly.',
|
||||
validation_module: 'Extension swoole pgsql hook availability check'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
@@ -20,31 +20,21 @@ class swoole_hook_sqlite extends Extension
|
||||
public function validate(): void
|
||||
{
|
||||
// pdo_pgsql need to be disabled
|
||||
if ($this->builder->getExt('pdo_sqlite') !== null) {
|
||||
if ($this->builder->getExt('pdo_sqlite')?->isBuildStatic()) {
|
||||
throw new WrongUsageException('swoole-hook-sqlite provides pdo_sqlite, if you enable sqlite hook for swoole, you must remove pdo_sqlite extension.');
|
||||
}
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
// enable swoole pgsql hook
|
||||
return '--enable-swoole-sqlite';
|
||||
}
|
||||
|
||||
public function runCliCheckUnix(): void
|
||||
{
|
||||
// skip if not enable swoole
|
||||
if ($this->builder->getExt('swoole') === null) {
|
||||
return;
|
||||
}
|
||||
$sharedExtensions = $this->getSharedExtensionLoadString();
|
||||
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
|
||||
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false);
|
||||
$out = implode('', $out);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||
throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check");
|
||||
}
|
||||
if (!str_contains($out, 'coroutine_sqlite')) {
|
||||
throw new RuntimeException('swoole sqlite hook is not enabled correctly.');
|
||||
throw new ValidationException('swoole sqlite hook is not enabled correctly.', validation_module: 'Extension swoole sqlite hook availability check');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('swow')]
|
||||
@@ -14,7 +14,7 @@ class swow extends Extension
|
||||
public function validate(): void
|
||||
{
|
||||
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
|
||||
throw new RuntimeException('The latest swow extension requires PHP 8.0 or later');
|
||||
throw new ValidationException('The latest swow extension requires PHP 8.0 or later');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,6 @@ class swow extends Extension
|
||||
return $arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
if ($this->builder->getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) {
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
@@ -14,7 +15,7 @@ class uv extends Extension
|
||||
public function validate(): void
|
||||
{
|
||||
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
|
||||
throw new \RuntimeException('The latest uv extension requires PHP 8.0 or later');
|
||||
throw new ValidationException('The latest uv extension requires PHP 8.0 or later');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\SPCInternalException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
@@ -16,9 +16,6 @@ use SPC\util\CustomExt;
|
||||
#[CustomExt('simplexml')]
|
||||
class xml extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
$arg = match ($this->name) {
|
||||
@@ -27,7 +24,7 @@ class xml extends Extension
|
||||
'xmlreader' => '--enable-xmlreader',
|
||||
'xmlwriter' => '--enable-xmlwriter',
|
||||
'simplexml' => '--enable-simplexml',
|
||||
default => throw new RuntimeException('Not accept non-xml extension'),
|
||||
default => throw new SPCInternalException('Not accept non-xml extension'),
|
||||
};
|
||||
$arg .= ($shared ? '=shared' : '') . ' --with-libxml="' . BUILD_ROOT_PATH . '"';
|
||||
return $arg;
|
||||
@@ -47,7 +44,7 @@ class xml extends Extension
|
||||
'xmlreader' => '--enable-xmlreader',
|
||||
'xmlwriter' => '--enable-xmlwriter',
|
||||
'simplexml' => '--with-simplexml',
|
||||
default => throw new RuntimeException('Not accept non-xml extension'),
|
||||
default => throw new SPCInternalException('Not accept non-xml extension'),
|
||||
};
|
||||
$arg .= ' --with-libxml';
|
||||
return $arg;
|
||||
|
||||
@@ -5,8 +5,6 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\freebsd;
|
||||
|
||||
use SPC\builder\unix\UnixBuilderBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourcePatcher;
|
||||
@@ -16,11 +14,6 @@ class BSDBuilder extends UnixBuilderBase
|
||||
/** @var bool Micro patch phar flag */
|
||||
private bool $phar_patched = false;
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->options = $options;
|
||||
@@ -32,10 +25,6 @@ class BSDBuilder extends UnixBuilderBase
|
||||
f_putenv('CXX=' . $this->getOption('cxx', 'clang++'));
|
||||
// set PATH
|
||||
f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH'));
|
||||
// set PKG_CONFIG
|
||||
f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config');
|
||||
// set PKG_CONFIG_PATH
|
||||
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/');
|
||||
|
||||
// set arch (default: current)
|
||||
$this->setOptionIfNotExist('arch', php_uname('m'));
|
||||
@@ -56,10 +45,7 @@ class BSDBuilder extends UnixBuilderBase
|
||||
/**
|
||||
* Just start to build statically linked php binary
|
||||
*
|
||||
* @param int $build_target build target
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
* @param int $build_target build target
|
||||
*/
|
||||
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
|
||||
{
|
||||
@@ -132,6 +118,11 @@ class BSDBuilder extends UnixBuilderBase
|
||||
}
|
||||
$this->buildEmbed();
|
||||
}
|
||||
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
|
||||
if (!empty($shared_extensions)) {
|
||||
logger()->info('Building shared extensions ...');
|
||||
$this->buildSharedExts();
|
||||
}
|
||||
if ($enableFrankenphp) {
|
||||
logger()->info('building frankenphp');
|
||||
$this->buildFrankenphp();
|
||||
@@ -148,9 +139,6 @@ class BSDBuilder extends UnixBuilderBase
|
||||
|
||||
/**
|
||||
* Build cli sapi
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function buildCli(): void
|
||||
{
|
||||
@@ -170,10 +158,6 @@ class BSDBuilder extends UnixBuilderBase
|
||||
|
||||
/**
|
||||
* Build phpmicro sapi
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
protected function buildMicro(): void
|
||||
{
|
||||
@@ -209,9 +193,6 @@ class BSDBuilder extends UnixBuilderBase
|
||||
|
||||
/**
|
||||
* Build fpm sapi
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function buildFpm(): void
|
||||
{
|
||||
@@ -230,8 +211,6 @@ class BSDBuilder extends UnixBuilderBase
|
||||
|
||||
/**
|
||||
* Build embed sapi
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function buildEmbed(): void
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\freebsd;
|
||||
|
||||
use SPC\builder\traits\UnixSystemUtilTrait;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\EnvironmentException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
|
||||
class SystemUtil
|
||||
@@ -15,14 +15,15 @@ class SystemUtil
|
||||
|
||||
/**
|
||||
* Get Logic CPU Count for macOS
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function getCpuCount(): int
|
||||
{
|
||||
[$ret, $output] = shell()->execWithResult('sysctl -n hw.ncpu');
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('Failed to get cpu count');
|
||||
throw new EnvironmentException(
|
||||
'Failed to get cpu count from FreeBSD sysctl',
|
||||
'Please ensure you are running this command on a FreeBSD system and have the sysctl command available.'
|
||||
);
|
||||
}
|
||||
|
||||
return (int) $output[0];
|
||||
@@ -31,9 +32,8 @@ class SystemUtil
|
||||
/**
|
||||
* Get Target Arch CFlags
|
||||
*
|
||||
* @param string $arch Arch Name
|
||||
* @return string return Arch CFlags string
|
||||
* @throws WrongUsageException
|
||||
* @param string $arch Arch Name
|
||||
* @return string return Arch CFlags string
|
||||
*/
|
||||
public static function getArchCFlags(string $arch): string
|
||||
{
|
||||
|
||||
@@ -22,19 +22,11 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\freebsd\library;
|
||||
|
||||
use SPC\builder\macos\library\MacOSLibraryBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
|
||||
class openssl extends BSDLibraryBase
|
||||
{
|
||||
public const NAME = 'openssl';
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
[$lib,,$destdir] = SEPARATED_PATH;
|
||||
|
||||
@@ -5,8 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\linux;
|
||||
|
||||
use SPC\builder\unix\UnixBuilderBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\PatchException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourcePatcher;
|
||||
@@ -19,10 +18,6 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
/** @var bool Micro patch phar flag */
|
||||
private bool $phar_patched = false;
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->options = $options;
|
||||
@@ -45,10 +40,7 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
/**
|
||||
* Build PHP from source.
|
||||
*
|
||||
* @param int $build_target Build target, use `BUILD_TARGET_*` constants
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
* @param int $build_target Build target, use `BUILD_TARGET_*` constants
|
||||
*/
|
||||
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
|
||||
{
|
||||
@@ -72,10 +64,7 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
// if opcache_jit is enabled for 8.5 or opcache enabled,
|
||||
// we need to disable undefined behavior sanitizer.
|
||||
f_putenv('SPC_COMPILER_EXTRA=-fno-sanitize=undefined');
|
||||
} elseif ($opcache_jit) {
|
||||
$opcache_jit = false;
|
||||
}
|
||||
$opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit ' : '--disable-opcache-jit ';
|
||||
|
||||
if ($this->getOption('enable-zts', false)) {
|
||||
$maxExecutionTimers = $phpVersionID >= 80100 ? '--enable-zend-max-execution-timers ' : '';
|
||||
@@ -95,6 +84,7 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
||||
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
|
||||
$enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP;
|
||||
$enableCgi = ($build_target & BUILD_TARGET_CGI) === BUILD_TARGET_CGI;
|
||||
|
||||
// prepare build php envs
|
||||
// $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__';
|
||||
@@ -121,9 +111,9 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
($enableFpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') .
|
||||
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
|
||||
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
|
||||
($enableCgi ? '--enable-cgi ' : '--disable-cgi ') .
|
||||
$config_file_path .
|
||||
$config_file_scan_dir .
|
||||
$opcache_jit_arg .
|
||||
$json_74 .
|
||||
$zts .
|
||||
$maxExecutionTimers .
|
||||
@@ -143,6 +133,10 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
logger()->info('building fpm');
|
||||
$this->buildFpm();
|
||||
}
|
||||
if ($enableCgi) {
|
||||
logger()->info('building cgi');
|
||||
$this->buildCgi();
|
||||
}
|
||||
if ($enableMicro) {
|
||||
logger()->info('building micro');
|
||||
$this->buildMicro();
|
||||
@@ -154,6 +148,12 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
}
|
||||
$this->buildEmbed();
|
||||
}
|
||||
// build dynamic extensions if needed, must happen before building FrankenPHP to make sure we export all necessary, undefined symbols
|
||||
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
|
||||
if (!empty($shared_extensions)) {
|
||||
logger()->info('Building shared extensions ...');
|
||||
$this->buildSharedExts();
|
||||
}
|
||||
if ($enableFrankenphp) {
|
||||
logger()->info('building frankenphp');
|
||||
$this->buildFrankenphp();
|
||||
@@ -168,9 +168,6 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
|
||||
/**
|
||||
* Build cli sapi
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function buildCli(): void
|
||||
{
|
||||
@@ -191,12 +188,27 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
$this->deployBinary(BUILD_TARGET_CLI);
|
||||
}
|
||||
|
||||
protected function buildCgi(): void
|
||||
{
|
||||
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
||||
$SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make';
|
||||
shell()->cd(SOURCE_PATH . '/php-src')
|
||||
->exec('sed -i "s|//lib|/lib|g" Makefile')
|
||||
->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cgi");
|
||||
|
||||
if (!$this->getOption('no-strip', false)) {
|
||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/cgi')->exec('strip --strip-unneeded php-cgi');
|
||||
}
|
||||
if ($this->getOption('with-upx-pack')) {
|
||||
shell()->cd(SOURCE_PATH . '/php-src/sapi/cgi')
|
||||
->exec(getenv('UPX_EXEC') . ' --best php-cgi');
|
||||
}
|
||||
|
||||
$this->deployBinary(BUILD_TARGET_CGI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build phpmicro sapi
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
protected function buildMicro(): void
|
||||
{
|
||||
@@ -231,9 +243,6 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
|
||||
/**
|
||||
* Build fpm sapi
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function buildFpm(): void
|
||||
{
|
||||
@@ -255,8 +264,6 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
|
||||
/**
|
||||
* Build embed sapi
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function buildEmbed(): void
|
||||
{
|
||||
@@ -336,6 +343,8 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
|
||||
$AR = getenv('AR') ?: 'ar';
|
||||
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
|
||||
// export dynamic symbols
|
||||
SystemUtil::exportDynamicSymbols(BUILD_LIB_PATH . '/libphp.a');
|
||||
}
|
||||
|
||||
if (!$this->getOption('no-strip', false) && file_exists(BUILD_LIB_PATH . '/' . $realLibName)) {
|
||||
@@ -346,12 +355,6 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
|
||||
/**
|
||||
* Return extra variables for php make command.
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
* @throws \ReflectionException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
private function getMakeExtraVars(): array
|
||||
{
|
||||
@@ -370,8 +373,6 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
* Strip micro.sfx for Linux.
|
||||
* The micro.sfx does not support UPX directly, but we can remove UPX-info segment to adapt.
|
||||
* This will also make micro.sfx with upx-packed more like a malware fore antivirus :(
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function processMicroUPX(): void
|
||||
{
|
||||
@@ -386,7 +387,7 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
$out[1] = explode(' ', $out[1]);
|
||||
$offset = $out[1][0];
|
||||
if ($ret !== 0 || !str_starts_with($offset, '0x')) {
|
||||
throw new RuntimeException('Cannot find offset in readelf output');
|
||||
throw new PatchException('phpmicro UPX patcher', 'Cannot find offset in readelf output');
|
||||
}
|
||||
$offset = hexdec($offset);
|
||||
// remove upx extra wastes
|
||||
|
||||
@@ -4,8 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
@@ -13,9 +11,6 @@ class imap extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'imap';
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
$cc = getenv('CC') ?: 'gcc';
|
||||
@@ -44,9 +39,6 @@ class imap extends LinuxLibraryBase
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
if ($this->builder->getLib('openssl')) {
|
||||
|
||||
@@ -4,18 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
|
||||
class libffi extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'libffi';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function build(): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($this)
|
||||
|
||||
@@ -21,20 +21,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
|
||||
class libpng extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'libpng';
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function build(): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($this)
|
||||
|
||||
58
src/SPC/builder/linux/library/liburing.php
Normal file
58
src/SPC/builder/linux/library/liburing.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\builder\linux\SystemUtil;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
class liburing extends LinuxLibraryBase
|
||||
{
|
||||
public const NAME = 'liburing';
|
||||
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
if (!SystemUtil::isMuslDist()) {
|
||||
return false;
|
||||
}
|
||||
FileSystem::replaceFileStr($this->source_dir . '/configure', 'realpath -s', 'realpath');
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
$use_libc = SPCTarget::getLibc() !== 'glibc' || version_compare(SPCTarget::getLibcVersion(), '2.30', '>=');
|
||||
$make = UnixAutoconfExecutor::create($this);
|
||||
|
||||
if (!$use_libc) {
|
||||
$make->appendEnv([
|
||||
'CC' => 'gcc', // libc-less version fails to compile with clang or zig
|
||||
'CXX' => 'g++',
|
||||
'AR' => 'ar',
|
||||
'LD' => 'ld',
|
||||
]);
|
||||
} else {
|
||||
$make->appendEnv([
|
||||
'CFLAGS' => '-D_GNU_SOURCE',
|
||||
]);
|
||||
}
|
||||
|
||||
$make
|
||||
->removeConfigureArgs(
|
||||
'--disable-shared',
|
||||
'--enable-static',
|
||||
'--with-pic',
|
||||
'--enable-pic',
|
||||
)
|
||||
->addConfigureArgs(
|
||||
$use_libc ? '--use-libc' : '',
|
||||
)
|
||||
->configure()
|
||||
->make('library', 'install ENABLE_SHARED=0', with_clean: false);
|
||||
|
||||
$this->patchPkgconfPrefix();
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\linux\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class openssl extends LinuxLibraryBase
|
||||
@@ -32,11 +29,6 @@ class openssl extends LinuxLibraryBase
|
||||
|
||||
public const NAME = 'openssl';
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function build(): void
|
||||
{
|
||||
$extra = '';
|
||||
|
||||
@@ -6,8 +6,6 @@ namespace SPC\builder\macos;
|
||||
|
||||
use SPC\builder\macos\library\MacOSLibraryBase;
|
||||
use SPC\builder\unix\UnixBuilderBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourcePatcher;
|
||||
@@ -19,11 +17,6 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
/** @var bool Micro patch phar flag */
|
||||
private bool $phar_patched = false;
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->options = $options;
|
||||
@@ -48,9 +41,7 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
/**
|
||||
* Get dynamically linked macOS frameworks
|
||||
*
|
||||
* @param bool $asString If true, return as string
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
* @param bool $asString If true, return as string
|
||||
*/
|
||||
public function getFrameworks(bool $asString = false): array|string
|
||||
{
|
||||
@@ -83,10 +74,7 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
/**
|
||||
* Just start to build statically linked php binary
|
||||
*
|
||||
* @param int $build_target build target
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
* @param int $build_target build target
|
||||
*/
|
||||
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
|
||||
{
|
||||
@@ -102,13 +90,6 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
$json_74 = $phpVersionID < 80000 ? '--enable-json ' : '';
|
||||
$zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : '';
|
||||
|
||||
$opcache_jit = !$this->getOption('disable-opcache-jit', false);
|
||||
// disable opcache jit for PHP < 8.5.0 when opcache is not enabled
|
||||
if ($opcache_jit && $phpVersionID < 80500 && !$this->getExt('opcache')) {
|
||||
$opcache_jit = false;
|
||||
}
|
||||
$opcache_jit_arg = $opcache_jit ? '--enable-opcache-jit ' : '--disable-opcache-jit ';
|
||||
|
||||
$config_file_path = $this->getOption('with-config-file-path', false) ?
|
||||
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
|
||||
$config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ?
|
||||
@@ -119,6 +100,7 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
||||
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
|
||||
$enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP;
|
||||
$enableCgi = ($build_target & BUILD_TARGET_CGI) === BUILD_TARGET_CGI;
|
||||
|
||||
// prepare build php envs
|
||||
$envs_build_php = SystemUtil::makeEnvVarString([
|
||||
@@ -143,7 +125,7 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
|
||||
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
|
||||
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
|
||||
$opcache_jit_arg .
|
||||
($enableCgi ? '--enable-cgi ' : '--disable-cgi ') .
|
||||
$config_file_path .
|
||||
$config_file_scan_dir .
|
||||
$json_74 .
|
||||
@@ -165,6 +147,10 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
logger()->info('building fpm');
|
||||
$this->buildFpm();
|
||||
}
|
||||
if ($enableCgi) {
|
||||
logger()->info('building cgi');
|
||||
$this->buildCgi();
|
||||
}
|
||||
if ($enableMicro) {
|
||||
logger()->info('building micro');
|
||||
$this->buildMicro();
|
||||
@@ -176,6 +162,11 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
}
|
||||
$this->buildEmbed();
|
||||
}
|
||||
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
|
||||
if (!empty($shared_extensions)) {
|
||||
logger()->info('Building shared extensions ...');
|
||||
$this->buildSharedExts();
|
||||
}
|
||||
if ($enableFrankenphp) {
|
||||
logger()->info('building frankenphp');
|
||||
$this->buildFrankenphp();
|
||||
@@ -190,9 +181,6 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
|
||||
/**
|
||||
* Build cli sapi
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function buildCli(): void
|
||||
{
|
||||
@@ -207,12 +195,21 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
$this->deployBinary(BUILD_TARGET_CLI);
|
||||
}
|
||||
|
||||
protected function buildCgi(): void
|
||||
{
|
||||
$vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars());
|
||||
|
||||
$shell = shell()->cd(SOURCE_PATH . '/php-src');
|
||||
$SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make';
|
||||
$shell->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cgi");
|
||||
if (!$this->getOption('no-strip', false)) {
|
||||
$shell->exec('dsymutil -f sapi/cgi/php-cgi')->exec('strip -S sapi/cgi/php-cgi');
|
||||
}
|
||||
$this->deployBinary(BUILD_TARGET_CGI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build phpmicro sapi
|
||||
*
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
protected function buildMicro(): void
|
||||
{
|
||||
@@ -248,9 +245,6 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
|
||||
/**
|
||||
* Build fpm sapi
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function buildFpm(): void
|
||||
{
|
||||
@@ -266,8 +260,6 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
|
||||
/**
|
||||
* Build embed sapi
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function buildEmbed(): void
|
||||
{
|
||||
@@ -279,6 +271,8 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
|
||||
$AR = getenv('AR') ?: 'ar';
|
||||
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
|
||||
// export dynamic symbols
|
||||
SystemUtil::exportDynamicSymbols(BUILD_LIB_PATH . '/libphp.a');
|
||||
}
|
||||
$this->patchPhpScripts();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\macos;
|
||||
|
||||
use SPC\builder\traits\UnixSystemUtilTrait;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\EnvironmentException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
|
||||
class SystemUtil
|
||||
@@ -15,25 +15,25 @@ class SystemUtil
|
||||
|
||||
/**
|
||||
* Get Logic CPU Count for macOS
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function getCpuCount(): int
|
||||
{
|
||||
[$ret, $output] = shell()->execWithResult('sysctl -n hw.ncpu', false);
|
||||
$cpu = exec('sysctl -n hw.ncpu', $output, $ret);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('Failed to get cpu count');
|
||||
throw new EnvironmentException(
|
||||
'Failed to get cpu count from macOS sysctl',
|
||||
'Please ensure you are running this command on a macOS system and have the sysctl command available.'
|
||||
);
|
||||
}
|
||||
|
||||
return (int) $output[0];
|
||||
return (int) $cpu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Target Arch CFlags
|
||||
*
|
||||
* @param string $arch Arch Name
|
||||
* @return string return Arch CFlags string
|
||||
* @throws WrongUsageException
|
||||
* @param string $arch Arch Name
|
||||
* @return string return Arch CFlags string
|
||||
*/
|
||||
public static function getArchCFlags(string $arch): string
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@ use SPC\builder\BuilderBase;
|
||||
use SPC\builder\LibraryBase;
|
||||
use SPC\builder\macos\MacOSBuilder;
|
||||
use SPC\builder\traits\UnixLibraryTrait;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
|
||||
abstract class MacOSLibraryBase extends LibraryBase
|
||||
@@ -28,10 +26,6 @@ abstract class MacOSLibraryBase extends LibraryBase
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function getFrameworks(): array
|
||||
{
|
||||
return Config::getLib(static::NAME, 'frameworks', []);
|
||||
|
||||
@@ -21,7 +21,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class curl extends MacOSLibraryBase
|
||||
@@ -30,9 +29,6 @@ class curl extends MacOSLibraryBase
|
||||
|
||||
public const NAME = 'curl';
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
FileSystem::replaceFileRegex(
|
||||
|
||||
@@ -4,18 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\executor\UnixCMakeExecutor;
|
||||
|
||||
class glfw extends MacOSLibraryBase
|
||||
{
|
||||
public const NAME = 'glfw';
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
UnixCMakeExecutor::create($this)
|
||||
|
||||
@@ -4,8 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourcePatcher;
|
||||
|
||||
@@ -13,10 +11,6 @@ class imap extends MacOSLibraryBase
|
||||
{
|
||||
public const NAME = 'imap';
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
$cc = getenv('CC') ?: 'clang';
|
||||
@@ -37,9 +31,6 @@ class imap extends MacOSLibraryBase
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
if ($this->builder->getLib('openssl')) {
|
||||
|
||||
@@ -4,18 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
|
||||
class libffi extends MacOSLibraryBase
|
||||
{
|
||||
public const NAME = 'libffi';
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
$arch = getenv('SPC_ARCH');
|
||||
|
||||
@@ -21,20 +21,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
|
||||
class libpng extends MacOSLibraryBase
|
||||
{
|
||||
public const NAME = 'libpng';
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
$arch = arch2gnu(php_uname('m'));
|
||||
|
||||
@@ -21,9 +21,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\macos\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
class openssl extends MacOSLibraryBase
|
||||
@@ -32,11 +29,6 @@ class openssl extends MacOSLibraryBase
|
||||
|
||||
public const NAME = 'openssl';
|
||||
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
// lib:zlib
|
||||
|
||||
@@ -4,20 +4,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\traits;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\exception\PatchException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\SPCConfigUtil;
|
||||
|
||||
trait UnixLibraryTrait
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
public function getStaticLibFiles(bool $include_self = true): string
|
||||
{
|
||||
$libs = $include_self ? [$this] : [];
|
||||
@@ -28,11 +21,11 @@ trait UnixLibraryTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch pkgconfig file prefix
|
||||
* Patch pkgconfig file prefix, exec_prefix, libdir, includedir for correct build.
|
||||
*
|
||||
* @param array $files file list
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @param array $files File list to patch, if empty, will use pkg-configs from config (e.g. ['zlib.pc', 'openssl.pc'])
|
||||
* @param int $patch_option Patch options
|
||||
* @param null|array $custom_replace Custom replace rules, if provided, will be used to replace in the format [regex, replacement]
|
||||
*/
|
||||
public function patchPkgconfPrefix(array $files = [], int $patch_option = PKGCONF_PATCH_ALL, ?array $custom_replace = null): void
|
||||
{
|
||||
@@ -43,7 +36,7 @@ trait UnixLibraryTrait
|
||||
foreach ($files as $name) {
|
||||
$realpath = realpath(BUILD_ROOT_PATH . '/lib/pkgconfig/' . $name);
|
||||
if ($realpath === false) {
|
||||
throw new RuntimeException('Cannot find library [' . static::NAME . '] pkgconfig file [' . $name . '] !');
|
||||
throw new PatchException('pkg-config prefix patcher', 'Cannot find library [' . static::NAME . '] pkgconfig file [' . $name . '] in ' . BUILD_LIB_PATH . '/pkgconfig/ !');
|
||||
}
|
||||
logger()->debug('Patching ' . $realpath);
|
||||
// replace prefix
|
||||
@@ -70,7 +63,7 @@ trait UnixLibraryTrait
|
||||
$realpath = realpath(BUILD_LIB_PATH . '/' . $name);
|
||||
if ($realpath === false) {
|
||||
if ($throwOnMissing) {
|
||||
throw new RuntimeException('Cannot find library [' . static::NAME . '] la file [' . $name . '] !');
|
||||
throw new PatchException('la dependency patcher', 'Cannot find library [' . static::NAME . '] la file [' . $name . '] !');
|
||||
}
|
||||
logger()->warning('Cannot find library [' . static::NAME . '] la file [' . $name . '] !');
|
||||
continue;
|
||||
|
||||
@@ -4,21 +4,101 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\traits;
|
||||
|
||||
/**
|
||||
* Unix 系统的工具函数 Trait,适用于 Linux、macOS
|
||||
*/
|
||||
use SPC\exception\ExecutionException;
|
||||
use SPC\exception\SPCInternalException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\toolchain\ToolchainManager;
|
||||
use SPC\toolchain\ZigToolchain;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
trait UnixSystemUtilTrait
|
||||
{
|
||||
/**
|
||||
* @param string $name 命令名称
|
||||
* @param array $paths 寻找的目标路径(如果不传入,则使用环境变量 PATH)
|
||||
* @return null|string 找到了返回命令路径,找不到返回 null
|
||||
* Export static library dynamic symbols to a .dynsym file.
|
||||
* It will export to "/path/to/libxxx.a.dynsym".
|
||||
*
|
||||
* @param string $lib_file Static library file path (e.g. /path/to/libxxx.a)
|
||||
*/
|
||||
public static function exportDynamicSymbols(string $lib_file): void
|
||||
{
|
||||
// check
|
||||
if (!is_file($lib_file)) {
|
||||
throw new WrongUsageException("The lib archive file {$lib_file} does not exist, please build it first.");
|
||||
}
|
||||
// shell out
|
||||
$cmd = 'nm -g --defined-only -P ' . escapeshellarg($lib_file);
|
||||
$result = shell()->execWithResult($cmd);
|
||||
if ($result[0] !== 0) {
|
||||
throw new ExecutionException($cmd, 'Failed to get defined symbols from ' . $lib_file);
|
||||
}
|
||||
// parse shell output and filter
|
||||
$defined = [];
|
||||
foreach ($result[1] as $line) {
|
||||
$line = trim($line);
|
||||
if ($line === '' || str_ends_with($line, '.o:') || str_ends_with($line, '.o]:')) {
|
||||
continue;
|
||||
}
|
||||
$name = strtok($line, " \t");
|
||||
if (!$name) {
|
||||
continue;
|
||||
}
|
||||
$name = preg_replace('/@.*$/', '', $name);
|
||||
if ($name !== '' && $name !== false) {
|
||||
$defined[] = $name;
|
||||
}
|
||||
}
|
||||
$defined = array_unique($defined);
|
||||
sort($defined);
|
||||
// export
|
||||
if (SPCTarget::getTargetOS() === 'Linux') {
|
||||
file_put_contents("{$lib_file}.dynsym", "{\n" . implode("\n", array_map(fn ($x) => " {$x};", $defined)) . "};\n");
|
||||
} else {
|
||||
file_put_contents("{$lib_file}.dynsym", implode("\n", $defined) . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get linker flag to export dynamic symbols from a static library.
|
||||
*
|
||||
* @param string $lib_file Static library file path (e.g. /path/to/libxxx.a)
|
||||
* @return null|string Linker flag to export dynamic symbols, null if no .dynsym file found
|
||||
*/
|
||||
public static function getDynamicExportedSymbols(string $lib_file): ?string
|
||||
{
|
||||
$symbol_file = "{$lib_file}.dynsym";
|
||||
if (!is_file($symbol_file)) {
|
||||
self::exportDynamicSymbols($lib_file);
|
||||
}
|
||||
if (!is_file($symbol_file)) {
|
||||
throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available.");
|
||||
}
|
||||
// https://github.com/ziglang/zig/issues/24662
|
||||
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
||||
return '-Wl,--export-dynamic';
|
||||
}
|
||||
// macOS
|
||||
if (SPCTarget::getTargetOS() !== 'Linux') {
|
||||
return "-Wl,-exported_symbols_list,{$symbol_file}";
|
||||
}
|
||||
return "-Wl,--dynamic-list={$symbol_file}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a command in given paths or system PATH.
|
||||
* If $name is an absolute path, check if it exists.
|
||||
*
|
||||
* @param string $name Command name or absolute path
|
||||
* @param array $paths Paths to search, if empty, use system PATH
|
||||
* @return null|string Absolute path of the command if found, null otherwise
|
||||
*/
|
||||
public static function findCommand(string $name, array $paths = []): ?string
|
||||
{
|
||||
if (!$paths) {
|
||||
$paths = explode(PATH_SEPARATOR, getenv('PATH'));
|
||||
}
|
||||
if (str_starts_with($name, '/')) {
|
||||
return file_exists($name) ? $name : null;
|
||||
}
|
||||
foreach ($paths as $path) {
|
||||
if (file_exists($path . DIRECTORY_SEPARATOR . $name)) {
|
||||
return $path . DIRECTORY_SEPARATOR . $name;
|
||||
@@ -28,6 +108,8 @@ trait UnixSystemUtilTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* Make environment variable string for shell command.
|
||||
*
|
||||
* @param array $vars Variables, like: ["CFLAGS" => "-Ixxx"]
|
||||
* @return string like: CFLAGS="-Ixxx"
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\traits;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\SPCException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\PkgConfigUtil;
|
||||
|
||||
@@ -24,7 +24,7 @@ trait openssl
|
||||
if (PHP_OS_FAMILY !== 'Windows') {
|
||||
try {
|
||||
return PkgConfigUtil::getModuleVersion('openssl');
|
||||
} catch (RuntimeException) {
|
||||
} catch (SPCException) {
|
||||
}
|
||||
}
|
||||
// get openssl version from header openssl/opensslv.h
|
||||
|
||||
@@ -5,14 +5,15 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\unix;
|
||||
|
||||
use SPC\builder\BuilderBase;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\builder\linux\SystemUtil as LinuxSystemUtil;
|
||||
use SPC\exception\SPCInternalException;
|
||||
use SPC\exception\ValidationException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\CurlHook;
|
||||
use SPC\store\Downloader;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\pkg\GoXcaddy;
|
||||
use SPC\toolchain\GccNativeToolchain;
|
||||
use SPC\toolchain\ToolchainManager;
|
||||
use SPC\util\DependencyUtil;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
use SPC\util\SPCConfigUtil;
|
||||
@@ -56,7 +57,14 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
}
|
||||
// if some libs are not supported (but in config "lib.json", throw exception)
|
||||
if (!isset($support_lib_list[$library])) {
|
||||
throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!');
|
||||
$os = match (PHP_OS_FAMILY) {
|
||||
'Linux' => 'Linux',
|
||||
'Darwin' => 'macOS',
|
||||
'Windows' => 'Windows',
|
||||
'BSD' => 'FreeBSD',
|
||||
default => PHP_OS_FAMILY,
|
||||
};
|
||||
throw new WrongUsageException("library [{$library}] is in the lib.json list but not supported to build on {$os}.");
|
||||
}
|
||||
$lib = new ($support_lib_list[$library])($this);
|
||||
$this->addLib($lib);
|
||||
@@ -70,9 +78,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanity check after build complete
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* Sanity check after build complete.
|
||||
*/
|
||||
protected function sanityCheck(int $build_target): void
|
||||
{
|
||||
@@ -82,7 +88,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
[$ret, $output] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -r "echo \"hello\";"');
|
||||
$raw_output = implode('', $output);
|
||||
if ($ret !== 0 || trim($raw_output) !== 'hello') {
|
||||
throw new RuntimeException("cli failed sanity check: ret[{$ret}]. out[{$raw_output}]");
|
||||
throw new ValidationException("cli failed sanity check. code: {$ret}, output: {$raw_output}", validation_module: 'php-cli sanity check');
|
||||
}
|
||||
|
||||
foreach ($this->getExts() as $ext) {
|
||||
@@ -105,12 +111,25 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
foreach ($task['conditions'] as $condition => $closure) {
|
||||
if (!$closure($ret, $out)) {
|
||||
$raw_out = trim(implode('', $out));
|
||||
throw new RuntimeException("micro failed sanity check: {$task_name}, condition [{$condition}], ret[{$ret}], out[{$raw_out}]");
|
||||
throw new ValidationException(
|
||||
"failure info: {$condition}, code: {$ret}, output: {$raw_out}",
|
||||
validation_module: "phpmicro sanity check item [{$task_name}]"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sanity check for php-cgi
|
||||
if (($build_target & BUILD_TARGET_CGI) === BUILD_TARGET_CGI) {
|
||||
logger()->info('running cgi sanity check');
|
||||
[$ret, $output] = shell()->execWithResult("echo '<?php echo \"<h1>Hello, World!</h1>\";' | " . BUILD_BIN_PATH . '/php-cgi -n');
|
||||
$raw_output = implode('', $output);
|
||||
if ($ret !== 0 || !str_contains($raw_output, 'Hello, World!') || !str_contains($raw_output, 'text/html')) {
|
||||
throw new ValidationException("cgi failed sanity check. code: {$ret}, output: {$raw_output}", validation_module: 'php-cgi sanity check');
|
||||
}
|
||||
}
|
||||
|
||||
// sanity check for embed
|
||||
if (($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) {
|
||||
logger()->info('running embed sanity check');
|
||||
@@ -127,6 +146,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
if (SPCTarget::isStatic()) {
|
||||
$lens .= ' -static';
|
||||
}
|
||||
$dynamic_exports = '';
|
||||
// if someone changed to EMBED_TYPE=shared, we need to add LD_LIBRARY_PATH
|
||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
|
||||
if (PHP_OS_FAMILY === 'Darwin') {
|
||||
@@ -141,14 +161,25 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
foreach (glob(BUILD_LIB_PATH . "/libphp*.{$suffix}") as $file) {
|
||||
unlink($file);
|
||||
}
|
||||
// calling linux system util in other unix OS is okay
|
||||
if ($dynamic_exports = LinuxSystemUtil::getDynamicExportedSymbols(BUILD_LIB_PATH . '/libphp.a')) {
|
||||
$dynamic_exports = ' ' . $dynamic_exports;
|
||||
}
|
||||
}
|
||||
[$ret, $out] = shell()->cd($sample_file_path)->execWithResult(getenv('CC') . ' -o embed embed.c ' . $lens);
|
||||
$cc = getenv('CC');
|
||||
[$ret, $out] = shell()->cd($sample_file_path)->execWithResult("{$cc} -o embed embed.c {$lens} {$dynamic_exports}");
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('embed failed sanity check: build failed. Error message: ' . implode("\n", $out));
|
||||
throw new ValidationException(
|
||||
'embed failed sanity check: build failed. Error message: ' . implode("\n", $out),
|
||||
validation_module: 'static libphp.a sanity check'
|
||||
);
|
||||
}
|
||||
[$ret, $output] = shell()->cd($sample_file_path)->execWithResult($ext_path . './embed');
|
||||
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {
|
||||
throw new RuntimeException('embed failed sanity check: run failed. Error message: ' . implode("\n", $output));
|
||||
throw new ValidationException(
|
||||
'embed failed sanity check: run failed. Error message: ' . implode("\n", $output),
|
||||
validation_module: 'static libphp.a sanity check'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,24 +188,28 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
logger()->info('running frankenphp sanity check');
|
||||
$frankenphp = BUILD_BIN_PATH . '/frankenphp';
|
||||
if (!file_exists($frankenphp)) {
|
||||
throw new RuntimeException('FrankenPHP binary not found: ' . $frankenphp);
|
||||
throw new ValidationException(
|
||||
"FrankenPHP binary not found: {$frankenphp}",
|
||||
validation_module: 'FrankenPHP sanity check'
|
||||
);
|
||||
}
|
||||
$prefix = PHP_OS_FAMILY === 'Darwin' ? 'DYLD_' : 'LD_';
|
||||
[$ret, $output] = shell()
|
||||
->setEnv(["{$prefix}LIBRARY_PATH" => BUILD_LIB_PATH])
|
||||
->execWithResult("{$frankenphp} version");
|
||||
if ($ret !== 0 || !str_contains(implode('', $output), 'FrankenPHP')) {
|
||||
throw new RuntimeException('FrankenPHP failed sanity check: ret[' . $ret . ']. out[' . implode('', $output) . ']');
|
||||
throw new ValidationException(
|
||||
'FrankenPHP failed sanity check: ret[' . $ret . ']. out[' . implode('', $output) . ']',
|
||||
validation_module: 'FrankenPHP sanity check'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将编译好的二进制文件发布到 buildroot
|
||||
* Deploy the binary file to the build bin path.
|
||||
*
|
||||
* @param int $type 发布类型
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
* @param int $type Type integer, one of BUILD_TARGET_CLI, BUILD_TARGET_MICRO, BUILD_TARGET_FPM
|
||||
*/
|
||||
protected function deployBinary(int $type): bool
|
||||
{
|
||||
@@ -182,7 +217,8 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
BUILD_TARGET_CLI => SOURCE_PATH . '/php-src/sapi/cli/php',
|
||||
BUILD_TARGET_MICRO => SOURCE_PATH . '/php-src/sapi/micro/micro.sfx',
|
||||
BUILD_TARGET_FPM => SOURCE_PATH . '/php-src/sapi/fpm/php-fpm',
|
||||
default => throw new RuntimeException('Deployment does not accept type ' . $type),
|
||||
BUILD_TARGET_CGI => SOURCE_PATH . '/php-src/sapi/cgi/php-cgi',
|
||||
default => throw new SPCInternalException("Deployment does not accept type {$type}"),
|
||||
};
|
||||
logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file');
|
||||
FileSystem::createDir(BUILD_BIN_PATH);
|
||||
@@ -192,18 +228,15 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
|
||||
/**
|
||||
* Run php clean
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function cleanMake(): void
|
||||
{
|
||||
logger()->info('cleaning up');
|
||||
logger()->info('cleaning up php-src build files');
|
||||
shell()->cd(SOURCE_PATH . '/php-src')->exec('make clean');
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch phpize and php-config if needed
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function patchPhpScripts(): void
|
||||
{
|
||||
@@ -231,12 +264,9 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws WrongUsageException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function buildFrankenphp(): void
|
||||
{
|
||||
GlobalEnvManager::addPathIfNotExists(GoXcaddy::getEnvironment()['PATH']);
|
||||
$nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : '';
|
||||
$nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : '';
|
||||
$xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES');
|
||||
@@ -248,31 +278,42 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.');
|
||||
$xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules);
|
||||
}
|
||||
$lrt = PHP_OS_FAMILY === 'Linux' ? '-lrt' : '';
|
||||
$releaseInfo = json_decode(Downloader::curlExec(
|
||||
'https://api.github.com/repos/php/frankenphp/releases/latest',
|
||||
hooks: [[CurlHook::class, 'setupGithubToken']],
|
||||
), true);
|
||||
$frankenPhpVersion = $releaseInfo['tag_name'];
|
||||
[, $out] = shell()->execWithResult('go list -m github.com/dunglas/frankenphp@latest');
|
||||
$frankenPhpVersion = str_replace('github.com/dunglas/frankenphp v', '', $out[0]);
|
||||
$libphpVersion = $this->getPHPVersion();
|
||||
$dynamic_exports = '';
|
||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
|
||||
$libphpVersion = preg_replace('/\.\d$/', '', $libphpVersion);
|
||||
$libphpVersion = preg_replace('/\.\d+$/', '', $libphpVersion);
|
||||
} else {
|
||||
if ($dynamicSymbolsArgument = LinuxSystemUtil::getDynamicExportedSymbols(BUILD_LIB_PATH . '/libphp.a')) {
|
||||
$dynamic_exports = ' ' . $dynamicSymbolsArgument;
|
||||
}
|
||||
}
|
||||
$debugFlags = $this->getOption('no-strip') ? '-w -s ' : '';
|
||||
$extLdFlags = "-extldflags '-pie'";
|
||||
$extLdFlags = "-extldflags '-pie{$dynamic_exports}'";
|
||||
$muslTags = '';
|
||||
$staticFlags = '';
|
||||
if (SPCTarget::isStatic()) {
|
||||
$extLdFlags = "-extldflags '-static-pie -Wl,-z,stack-size=0x80000'";
|
||||
$extLdFlags = "-extldflags '-static-pie -Wl,-z,stack-size=0x80000{$dynamic_exports}'";
|
||||
$muslTags = 'static_build,';
|
||||
$staticFlags = '-static-pie';
|
||||
}
|
||||
|
||||
$config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list);
|
||||
$cflags = "{$this->arch_c_flags} {$config['cflags']} " . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS');
|
||||
$libs = $config['libs'];
|
||||
$libs .= PHP_OS_FAMILY === 'Linux' ? ' -lrt' : '';
|
||||
// Go's gcc driver doesn't automatically link against -lgcov or -lrt. Ugly, but necessary fix.
|
||||
if ((str_contains((string) getenv('SPC_DEFAULT_C_FLAGS'), '-fprofile') ||
|
||||
str_contains((string) getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), '-fprofile')) &&
|
||||
ToolchainManager::getToolchainClass() === GccNativeToolchain::class) {
|
||||
$cflags .= ' -Wno-error=missing-profile';
|
||||
$libs .= ' -lgcov';
|
||||
}
|
||||
$env = [
|
||||
'CGO_ENABLED' => '1',
|
||||
'CGO_CFLAGS' => $config['cflags'],
|
||||
'CGO_LDFLAGS' => "{$staticFlags} {$config['ldflags']} {$config['libs']} {$lrt}",
|
||||
'CGO_CFLAGS' => clean_spaces($cflags),
|
||||
'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}",
|
||||
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
|
||||
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . $debugFlags .
|
||||
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
|
||||
@@ -281,9 +322,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
||||
];
|
||||
foreach (GoXcaddy::getEnvironment() as $key => $value) {
|
||||
if ($key === 'PATH') {
|
||||
GlobalEnvManager::addPathIfNotExists($value);
|
||||
} else {
|
||||
if ($key !== 'PATH') {
|
||||
$env[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
|
||||
trait attr
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($this)
|
||||
|
||||
@@ -4,17 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\executor\UnixCMakeExecutor;
|
||||
|
||||
trait brotli
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
UnixCMakeExecutor::create($this)
|
||||
|
||||
@@ -4,16 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\executor\UnixCMakeExecutor;
|
||||
|
||||
trait curl
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt');
|
||||
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\BuildFailureException;
|
||||
|
||||
trait fastlz
|
||||
{
|
||||
protected function build(): void
|
||||
@@ -13,10 +15,10 @@ trait fastlz
|
||||
->exec((getenv('AR') ?: 'ar') . ' rcs libfastlz.a fastlz.o');
|
||||
|
||||
if (!copy($this->source_dir . '/fastlz.h', BUILD_INCLUDE_PATH . '/fastlz.h')) {
|
||||
throw new \RuntimeException('Failed to copy fastlz.h');
|
||||
throw new BuildFailureException('Failed to copy fastlz.h, file does not exist');
|
||||
}
|
||||
if (!copy($this->source_dir . '/libfastlz.a', BUILD_LIB_PATH . '/libfastlz.a')) {
|
||||
throw new \RuntimeException('Failed to copy libfastlz.a');
|
||||
throw new BuildFailureException('Failed to copy libfastlz.a, file does not exist');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\executor\UnixCMakeExecutor;
|
||||
|
||||
trait freetype
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
$cmake = UnixCMakeExecutor::create($this)
|
||||
|
||||
@@ -4,16 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
|
||||
trait gmp
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($this)->configure()->make();
|
||||
|
||||
@@ -4,20 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
trait imagemagick
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
$ac = UnixAutoconfExecutor::create($this)
|
||||
|
||||
@@ -4,24 +4,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
|
||||
trait jbig
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'CFLAGS = -O2 -W -Wno-unused-result', 'CFLAGS = -O2 -W -Wno-unused-result -fPIC');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
shell()->cd($this->source_dir)->initializeEnv($this)
|
||||
|
||||
@@ -4,16 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\executor\UnixCMakeExecutor;
|
||||
|
||||
trait lerc
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
UnixCMakeExecutor::create($this)
|
||||
|
||||
@@ -4,16 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
|
||||
trait libacl
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
$file_path = SOURCE_PATH . '/php-src/Makefile';
|
||||
@@ -25,9 +20,6 @@ trait libacl
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($this)
|
||||
|
||||
@@ -4,18 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\executor\UnixCMakeExecutor;
|
||||
|
||||
trait libavif
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
* @throws RuntimeException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
UnixCMakeExecutor::create($this)
|
||||
|
||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\executor\UnixAutoconfExecutor;
|
||||
|
||||
@@ -20,9 +19,6 @@ trait libcares
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($this)->configure('--disable-tests')->make();
|
||||
|
||||
@@ -4,16 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\util\executor\UnixCMakeExecutor;
|
||||
|
||||
trait libde265
|
||||
{
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
protected function build(): void
|
||||
{
|
||||
UnixCMakeExecutor::create($this)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user