mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-18 22:35:36 +08:00
Compare commits
63 Commits
0f0050115c
...
2.7.3
| 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 | ||
|
|
f2c131a2cc | ||
|
|
6f0310e8f7 | ||
|
|
c7141003db | ||
|
|
d32bdb2825 | ||
|
|
a66abfa583 | ||
|
|
2551772de4 | ||
|
|
694fd2f1e0 |
@@ -12,5 +12,5 @@ trim_trailing_whitespace = true
|
|||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
[*.{yml,yaml, vue}]
|
[*.{yml,yaml,vue,ts}]
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|||||||
1
.github/workflows/vitepress-deploy.yml
vendored
1
.github/workflows/vitepress-deploy.yml
vendored
@@ -21,7 +21,6 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
|
||||||
cache: yarn
|
cache: yarn
|
||||||
|
|
||||||
- run: yarn install --frozen-lockfile
|
- run: yarn install --frozen-lockfile
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -34,6 +34,7 @@ packlib_files.txt
|
|||||||
/bin/*
|
/bin/*
|
||||||
!/bin/spc*
|
!/bin/spc*
|
||||||
!/bin/setup-runtime*
|
!/bin/setup-runtime*
|
||||||
|
!/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
# exclude windows build tools
|
# exclude windows build tools
|
||||||
/php-sdk-binary-tools/
|
/php-sdk-binary-tools/
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ bin/spc --version
|
|||||||
- `--build-micro`:构建 phpmicro 自执行二进制
|
- `--build-micro`:构建 phpmicro 自执行二进制
|
||||||
- `--build-fpm`:构建 fpm
|
- `--build-fpm`:构建 fpm
|
||||||
- `--build-embed`:构建 embed(libphp)
|
- `--build-embed`:构建 embed(libphp)
|
||||||
|
- `--build-cgi`: 构建 cgi(不推荐)
|
||||||
- `--build-all`:构建所有
|
- `--build-all`:构建所有
|
||||||
|
|
||||||
如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误:
|
如果出现了任何错误,可以使用 `--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-micro`: build static phpmicro self-extracted executable
|
||||||
- `--build-fpm`: build static fpm binary
|
- `--build-fpm`: build static fpm binary
|
||||||
- `--build-embed`: build embed (libphp)
|
- `--build-embed`: build embed (libphp)
|
||||||
|
- `--build-cgi`: build cgi binary (not recommended)
|
||||||
- `--build-all`: build all
|
- `--build-all`: build all
|
||||||
|
|
||||||
If anything goes wrong, use `--debug` option to display full terminal output:
|
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)
|
__PROJECT__=$(cd "${__DIR__}"/../ && pwd)
|
||||||
|
|
||||||
# set download dir
|
# 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"
|
__COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar"
|
||||||
|
|
||||||
# use china mirror
|
# use china mirror
|
||||||
@@ -45,7 +45,7 @@ done
|
|||||||
|
|
||||||
case "$mirror" in
|
case "$mirror" in
|
||||||
china)
|
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"
|
__COMPOSER_URL__="https://mirrors.tencent.com/composer/composer.phar"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# This file is using docker to run commands
|
# This file is using docker to run commands
|
||||||
SPC_DOCKER_VERSION=v5
|
SPC_DOCKER_VERSION=v6
|
||||||
|
|
||||||
# Detect docker can run
|
# Detect docker can run
|
||||||
if ! which docker >/dev/null; then
|
if ! which docker >/dev/null; then
|
||||||
@@ -122,6 +122,14 @@ ADD ./src /app/src
|
|||||||
COPY ./composer.* /app/
|
COPY ./composer.* /app/
|
||||||
ADD ./bin /app/bin
|
ADD ./bin /app/bin
|
||||||
RUN composer install --no-dev
|
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
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# This file is using docker to run commands
|
# This file is using docker to run commands
|
||||||
SPC_DOCKER_VERSION=v5
|
SPC_DOCKER_VERSION=v6
|
||||||
|
|
||||||
# Detect docker can run
|
# Detect docker can run
|
||||||
if ! which docker >/dev/null; then
|
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
|
ADD ./config /app/config
|
||||||
RUN CC=gcc bin/spc doctor --auto-fix --debug
|
RUN CC=gcc bin/spc doctor --auto-fix --debug
|
||||||
|
RUN bin/spc install-pkg upx
|
||||||
RUN if [ -f /app/buildroot/bin/re2c ]; then \
|
RUN if [ -f /app/buildroot/bin/re2c ]; then \
|
||||||
cp /app/buildroot/bin/re2c /usr/local/bin/re2c ;\
|
cp /app/buildroot/bin/re2c /usr/local/bin/re2c ;\
|
||||||
fi
|
fi
|
||||||
@@ -132,6 +133,11 @@ RUN curl -o automake.tgz -fsSL https://ftp.gnu.org/gnu/automake/automake-1.17.ta
|
|||||||
make && \
|
make && \
|
||||||
make install && \
|
make install && \
|
||||||
ln -sf /usr/local/bin/automake /usr/bin/automake
|
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
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
372
composer.lock
generated
372
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
|
; buildconf command
|
||||||
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
|
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
|
||||||
; configure command
|
; 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
|
; make command
|
||||||
SPC_CMD_PREFIX_PHP_MAKE="make -j${SPC_CONCURRENCY}"
|
SPC_CMD_PREFIX_PHP_MAKE="make -j${SPC_CONCURRENCY}"
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ SPC_MICRO_PATCHES=cli_checks,macos_iconv
|
|||||||
; buildconf command
|
; buildconf command
|
||||||
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
|
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
|
||||||
; configure command
|
; 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
|
; make command
|
||||||
SPC_CMD_PREFIX_PHP_MAKE="make -j${SPC_CONCURRENCY}"
|
SPC_CMD_PREFIX_PHP_MAKE="make -j${SPC_CONCURRENCY}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
{
|
{
|
||||||
"lib-base": {
|
"lib-base": {
|
||||||
"type": "root",
|
"type": "root"
|
||||||
"lib-depends-unix": [
|
|
||||||
"pkg-config"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"php": {
|
"php": {
|
||||||
"type": "root",
|
"type": "root",
|
||||||
@@ -20,6 +17,9 @@
|
|||||||
"lib-suggests-unix": [
|
"lib-suggests-unix": [
|
||||||
"brotli",
|
"brotli",
|
||||||
"watcher"
|
"watcher"
|
||||||
|
],
|
||||||
|
"lib-depends-macos": [
|
||||||
|
"libxml2"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"micro": {
|
"micro": {
|
||||||
|
|||||||
@@ -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": {
|
"musl-toolchain-aarch64-linux": {
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/aarch64-musl-toolchain.tgz"
|
"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"
|
"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": {
|
"strawberry-perl-x86_64-win": {
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip"
|
"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"
|
"upx-*-win64/upx.exe": "{pkg_root_path}/bin/upx.exe"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"go-xcaddy-x86_64-linux": {
|
"zig-aarch64-linux": {
|
||||||
"type": "custom"
|
"type": "custom"
|
||||||
},
|
},
|
||||||
"go-xcaddy-aarch64-linux": {
|
"zig-aarch64-macos": {
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
"go-xcaddy-x86_64-macos": {
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
"go-xcaddy-aarch64-macos": {
|
|
||||||
"type": "custom"
|
"type": "custom"
|
||||||
},
|
},
|
||||||
"zig-x86_64-linux": {
|
"zig-x86_64-linux": {
|
||||||
"type": "custom"
|
"type": "custom"
|
||||||
},
|
},
|
||||||
"zig-aarch64-linux": {
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
"zig-x86_64-macos": {
|
"zig-x86_64-macos": {
|
||||||
"type": "custom"
|
"type": "custom"
|
||||||
},
|
},
|
||||||
"zig-aarch64-macos": {
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
"zig-x86_64-win": {
|
"zig-x86_64-win": {
|
||||||
"type": "custom"
|
"type": "custom"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -379,6 +379,11 @@ const craftCommandString = computed(() => {
|
|||||||
str += 'debug: true\n';
|
str += 'debug: true\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (preBuilt.value) {
|
||||||
|
str += 'download-options:\n';
|
||||||
|
str += ' prefer-pre-built: true\n';
|
||||||
|
}
|
||||||
|
|
||||||
str += '{{position_hold}}';
|
str += '{{position_hold}}';
|
||||||
|
|
||||||
if (enableUPX.value) {
|
if (enableUPX.value) {
|
||||||
@@ -387,9 +392,6 @@ const craftCommandString = computed(() => {
|
|||||||
if (zts.value) {
|
if (zts.value) {
|
||||||
str += ' enable-zts: true\n';
|
str += ' enable-zts: true\n';
|
||||||
}
|
}
|
||||||
if (preBuilt.value) {
|
|
||||||
str += ' prefer-pre-built: true\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!str.endsWith('{{position_hold}}')) {
|
if (!str.endsWith('{{position_hold}}')) {
|
||||||
str = str.replace('{{position_hold}}', 'build-options:\n');
|
str = str.replace('{{position_hold}}', 'build-options:\n');
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ export default {
|
|||||||
footer: {
|
footer: {
|
||||||
message: 'Released under the MIT License.',
|
message: 'Released under the MIT License.',
|
||||||
copyright: 'Copyright © 2023-present crazywhalecc'
|
copyright: 'Copyright © 2023-present crazywhalecc'
|
||||||
}
|
},
|
||||||
|
search: {
|
||||||
|
provider: 'algolia',
|
||||||
|
options: {
|
||||||
|
appId: 'IHJHUB1SF1',
|
||||||
|
apiKey: '8266d31cc2ffbd0e059f1c6e5bdaf8fc',
|
||||||
|
indexName: 'static-php docs',
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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-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-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-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-embed`: Build an embed sapi (used to embed into other C language programs)
|
||||||
- `--build-frankenphp`: Build a [FrankenPHP](https://github.com/php/frankenphp) executable
|
- `--build-frankenphp`: Build a [FrankenPHP](https://github.com/php/frankenphp) executable
|
||||||
|
|||||||
@@ -249,6 +249,7 @@ bin/spc doctor --auto-fix
|
|||||||
|
|
||||||
- `--build-cli`: 构建一个 cli sapi(命令行界面,可在命令行执行 PHP 代码)
|
- `--build-cli`: 构建一个 cli sapi(命令行界面,可在命令行执行 PHP 代码)
|
||||||
- `--build-fpm`: 构建一个 fpm sapi(php-fpm,用于和其他传统的 fpm 架构的软件如 nginx 配合使用)
|
- `--build-fpm`: 构建一个 fpm sapi(php-fpm,用于和其他传统的 fpm 架构的软件如 nginx 配合使用)
|
||||||
|
- `--build-cgi`: 构建一个 cgi sapi(cgi,可用于传统的 cgi 架构的软件如 apache 配合使用)
|
||||||
- `--build-micro`: 构建一个 micro sapi(用于构建一个包含 PHP 代码的独立可执行二进制)
|
- `--build-micro`: 构建一个 micro sapi(用于构建一个包含 PHP 代码的独立可执行二进制)
|
||||||
- `--build-embed`: 构建一个 embed sapi(用于嵌入到其他 C 语言程序中)
|
- `--build-embed`: 构建一个 embed sapi(用于嵌入到其他 C 语言程序中)
|
||||||
- `--build-frankenphp`: 构建一个 [frankenphp](https://github.com/php/frankenphp) 二进制
|
- `--build-frankenphp`: 构建一个 [frankenphp](https://github.com/php/frankenphp) 二进制
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ parameters:
|
|||||||
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
|
- '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#'
|
||||||
- '#Function Swoole\\Coroutine\\run not found.#'
|
- '#Function Swoole\\Coroutine\\run not found.#'
|
||||||
- '#Static call to instance method ZM\\Logger\\ConsoleColor#'
|
- '#Static call to instance method ZM\\Logger\\ConsoleColor#'
|
||||||
|
- '#Constant GNU_ARCH not found#'
|
||||||
dynamicConstantNames:
|
dynamicConstantNames:
|
||||||
- PHP_OS_FAMILY
|
- PHP_OS_FAMILY
|
||||||
excludePaths:
|
excludePaths:
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ use Symfony\Component\Console\Application;
|
|||||||
*/
|
*/
|
||||||
final class ConsoleApplication extends Application
|
final class ConsoleApplication extends Application
|
||||||
{
|
{
|
||||||
public const string VERSION = '2.7.2';
|
public const string VERSION = '2.7.3';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -392,6 +392,9 @@ abstract class BuilderBase
|
|||||||
if (($type & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP) {
|
if (($type & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP) {
|
||||||
$ls[] = 'frankenphp';
|
$ls[] = 'frankenphp';
|
||||||
}
|
}
|
||||||
|
if (($type & BUILD_TARGET_CGI) === BUILD_TARGET_CGI) {
|
||||||
|
$ls[] = 'cgi';
|
||||||
|
}
|
||||||
return implode(', ', $ls);
|
return implode(', ', $ls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,6 @@ class BSDBuilder extends UnixBuilderBase
|
|||||||
f_putenv('CXX=' . $this->getOption('cxx', 'clang++'));
|
f_putenv('CXX=' . $this->getOption('cxx', 'clang++'));
|
||||||
// set PATH
|
// set PATH
|
||||||
f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('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)
|
// set arch (default: current)
|
||||||
$this->setOptionIfNotExist('arch', php_uname('m'));
|
$this->setOptionIfNotExist('arch', php_uname('m'));
|
||||||
@@ -122,6 +118,11 @@ class BSDBuilder extends UnixBuilderBase
|
|||||||
}
|
}
|
||||||
$this->buildEmbed();
|
$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) {
|
if ($enableFrankenphp) {
|
||||||
logger()->info('building frankenphp');
|
logger()->info('building frankenphp');
|
||||||
$this->buildFrankenphp();
|
$this->buildFrankenphp();
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
||||||
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
|
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
|
||||||
$enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP;
|
$enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP;
|
||||||
|
$enableCgi = ($build_target & BUILD_TARGET_CGI) === BUILD_TARGET_CGI;
|
||||||
|
|
||||||
// prepare build php envs
|
// prepare build php envs
|
||||||
// $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__';
|
// $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__';
|
||||||
@@ -110,6 +111,7 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
($enableFpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') .
|
($enableFpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') .
|
||||||
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
|
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
|
||||||
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
|
($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') .
|
||||||
|
($enableCgi ? '--enable-cgi ' : '--disable-cgi ') .
|
||||||
$config_file_path .
|
$config_file_path .
|
||||||
$config_file_scan_dir .
|
$config_file_scan_dir .
|
||||||
$json_74 .
|
$json_74 .
|
||||||
@@ -131,6 +133,10 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
logger()->info('building fpm');
|
logger()->info('building fpm');
|
||||||
$this->buildFpm();
|
$this->buildFpm();
|
||||||
}
|
}
|
||||||
|
if ($enableCgi) {
|
||||||
|
logger()->info('building cgi');
|
||||||
|
$this->buildCgi();
|
||||||
|
}
|
||||||
if ($enableMicro) {
|
if ($enableMicro) {
|
||||||
logger()->info('building micro');
|
logger()->info('building micro');
|
||||||
$this->buildMicro();
|
$this->buildMicro();
|
||||||
@@ -142,6 +148,12 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
}
|
}
|
||||||
$this->buildEmbed();
|
$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) {
|
if ($enableFrankenphp) {
|
||||||
logger()->info('building frankenphp');
|
logger()->info('building frankenphp');
|
||||||
$this->buildFrankenphp();
|
$this->buildFrankenphp();
|
||||||
@@ -176,6 +188,25 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
$this->deployBinary(BUILD_TARGET_CLI);
|
$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
|
* Build phpmicro sapi
|
||||||
*/
|
*/
|
||||||
@@ -312,6 +343,8 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
|
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
|
||||||
$AR = getenv('AR') ?: 'ar';
|
$AR = getenv('AR') ?: 'ar';
|
||||||
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
|
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)) {
|
if (!$this->getOption('no-strip', false) && file_exists(BUILD_LIB_PATH . '/' . $realLibName)) {
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ class liburing extends LinuxLibraryBase
|
|||||||
$use_libc ? '--use-libc' : '',
|
$use_libc ? '--use-libc' : '',
|
||||||
)
|
)
|
||||||
->configure()
|
->configure()
|
||||||
->make('library', with_clean: false)
|
->make('library', 'install ENABLE_SHARED=0', with_clean: false);
|
||||||
->exec("rm -rf {$this->getLibDir()}/liburing*.so*");
|
|
||||||
|
|
||||||
$this->patchPkgconfPrefix();
|
$this->patchPkgconfPrefix();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
|
||||||
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
|
$enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED;
|
||||||
$enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP;
|
$enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP;
|
||||||
|
$enableCgi = ($build_target & BUILD_TARGET_CGI) === BUILD_TARGET_CGI;
|
||||||
|
|
||||||
// prepare build php envs
|
// prepare build php envs
|
||||||
$envs_build_php = SystemUtil::makeEnvVarString([
|
$envs_build_php = SystemUtil::makeEnvVarString([
|
||||||
@@ -124,6 +125,7 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
|
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
|
||||||
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
|
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
|
||||||
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
|
($enableMicro ? '--enable-micro ' : '--disable-micro ') .
|
||||||
|
($enableCgi ? '--enable-cgi ' : '--disable-cgi ') .
|
||||||
$config_file_path .
|
$config_file_path .
|
||||||
$config_file_scan_dir .
|
$config_file_scan_dir .
|
||||||
$json_74 .
|
$json_74 .
|
||||||
@@ -145,6 +147,10 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
logger()->info('building fpm');
|
logger()->info('building fpm');
|
||||||
$this->buildFpm();
|
$this->buildFpm();
|
||||||
}
|
}
|
||||||
|
if ($enableCgi) {
|
||||||
|
logger()->info('building cgi');
|
||||||
|
$this->buildCgi();
|
||||||
|
}
|
||||||
if ($enableMicro) {
|
if ($enableMicro) {
|
||||||
logger()->info('building micro');
|
logger()->info('building micro');
|
||||||
$this->buildMicro();
|
$this->buildMicro();
|
||||||
@@ -156,6 +162,11 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
}
|
}
|
||||||
$this->buildEmbed();
|
$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) {
|
if ($enableFrankenphp) {
|
||||||
logger()->info('building frankenphp');
|
logger()->info('building frankenphp');
|
||||||
$this->buildFrankenphp();
|
$this->buildFrankenphp();
|
||||||
@@ -184,6 +195,19 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
$this->deployBinary(BUILD_TARGET_CLI);
|
$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
|
* Build phpmicro sapi
|
||||||
*/
|
*/
|
||||||
@@ -247,6 +271,8 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
|
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
|
||||||
$AR = getenv('AR') ?: 'ar';
|
$AR = getenv('AR') ?: 'ar';
|
||||||
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
|
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();
|
$this->patchPhpScripts();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,92 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder\traits;
|
namespace SPC\builder\traits;
|
||||||
|
|
||||||
/**
|
use SPC\exception\ExecutionException;
|
||||||
* Unix 系统的工具函数 Trait,适用于 Linux、macOS
|
use SPC\exception\SPCInternalException;
|
||||||
*/
|
use SPC\exception\WrongUsageException;
|
||||||
|
use SPC\toolchain\ToolchainManager;
|
||||||
|
use SPC\toolchain\ZigToolchain;
|
||||||
|
use SPC\util\SPCTarget;
|
||||||
|
|
||||||
trait UnixSystemUtilTrait
|
trait UnixSystemUtilTrait
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param string $name 命令名称
|
* Export static library dynamic symbols to a .dynsym file.
|
||||||
* @param array $paths 寻找的目标路径(如果不传入,则使用环境变量 PATH)
|
* It will export to "/path/to/libxxx.a.dynsym".
|
||||||
* @return null|string 找到了返回命令路径,找不到返回 null
|
*
|
||||||
|
* @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
|
public static function findCommand(string $name, array $paths = []): ?string
|
||||||
{
|
{
|
||||||
@@ -31,6 +108,8 @@ trait UnixSystemUtilTrait
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Make environment variable string for shell command.
|
||||||
|
*
|
||||||
* @param array $vars Variables, like: ["CFLAGS" => "-Ixxx"]
|
* @param array $vars Variables, like: ["CFLAGS" => "-Ixxx"]
|
||||||
* @return string like: CFLAGS="-Ixxx"
|
* @return string like: CFLAGS="-Ixxx"
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder\unix;
|
namespace SPC\builder\unix;
|
||||||
|
|
||||||
use SPC\builder\BuilderBase;
|
use SPC\builder\BuilderBase;
|
||||||
|
use SPC\builder\linux\SystemUtil as LinuxSystemUtil;
|
||||||
use SPC\exception\SPCInternalException;
|
use SPC\exception\SPCInternalException;
|
||||||
use SPC\exception\ValidationException;
|
use SPC\exception\ValidationException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
use SPC\store\CurlHook;
|
|
||||||
use SPC\store\Downloader;
|
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\store\pkg\GoXcaddy;
|
use SPC\store\pkg\GoXcaddy;
|
||||||
use SPC\toolchain\GccNativeToolchain;
|
use SPC\toolchain\GccNativeToolchain;
|
||||||
@@ -121,6 +120,16 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// sanity check for embed
|
||||||
if (($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) {
|
if (($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) {
|
||||||
logger()->info('running embed sanity check');
|
logger()->info('running embed sanity check');
|
||||||
@@ -137,6 +146,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
if (SPCTarget::isStatic()) {
|
if (SPCTarget::isStatic()) {
|
||||||
$lens .= ' -static';
|
$lens .= ' -static';
|
||||||
}
|
}
|
||||||
|
$dynamic_exports = '';
|
||||||
// if someone changed to EMBED_TYPE=shared, we need to add LD_LIBRARY_PATH
|
// if someone changed to EMBED_TYPE=shared, we need to add LD_LIBRARY_PATH
|
||||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
|
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
|
||||||
if (PHP_OS_FAMILY === 'Darwin') {
|
if (PHP_OS_FAMILY === 'Darwin') {
|
||||||
@@ -151,8 +161,13 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
foreach (glob(BUILD_LIB_PATH . "/libphp*.{$suffix}") as $file) {
|
foreach (glob(BUILD_LIB_PATH . "/libphp*.{$suffix}") as $file) {
|
||||||
unlink($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) {
|
if ($ret !== 0) {
|
||||||
throw new ValidationException(
|
throw new ValidationException(
|
||||||
'embed failed sanity check: build failed. Error message: ' . implode("\n", $out),
|
'embed failed sanity check: build failed. Error message: ' . implode("\n", $out),
|
||||||
@@ -202,6 +217,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
BUILD_TARGET_CLI => SOURCE_PATH . '/php-src/sapi/cli/php',
|
BUILD_TARGET_CLI => SOURCE_PATH . '/php-src/sapi/cli/php',
|
||||||
BUILD_TARGET_MICRO => SOURCE_PATH . '/php-src/sapi/micro/micro.sfx',
|
BUILD_TARGET_MICRO => SOURCE_PATH . '/php-src/sapi/micro/micro.sfx',
|
||||||
BUILD_TARGET_FPM => SOURCE_PATH . '/php-src/sapi/fpm/php-fpm',
|
BUILD_TARGET_FPM => SOURCE_PATH . '/php-src/sapi/fpm/php-fpm',
|
||||||
|
BUILD_TARGET_CGI => SOURCE_PATH . '/php-src/sapi/cgi/php-cgi',
|
||||||
default => throw new SPCInternalException("Deployment does not accept type {$type}"),
|
default => throw new SPCInternalException("Deployment does not accept type {$type}"),
|
||||||
};
|
};
|
||||||
logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file');
|
logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file');
|
||||||
@@ -250,6 +266,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
|
|
||||||
protected function buildFrankenphp(): void
|
protected function buildFrankenphp(): void
|
||||||
{
|
{
|
||||||
|
GlobalEnvManager::addPathIfNotExists(GoXcaddy::getEnvironment()['PATH']);
|
||||||
$nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : '';
|
$nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : '';
|
||||||
$nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : '';
|
$nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : '';
|
||||||
$xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES');
|
$xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES');
|
||||||
@@ -261,21 +278,23 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.');
|
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);
|
$xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules);
|
||||||
}
|
}
|
||||||
$releaseInfo = json_decode(Downloader::curlExec(
|
[, $out] = shell()->execWithResult('go list -m github.com/dunglas/frankenphp@latest');
|
||||||
'https://api.github.com/repos/php/frankenphp/releases/latest',
|
$frankenPhpVersion = str_replace('github.com/dunglas/frankenphp v', '', $out[0]);
|
||||||
hooks: [[CurlHook::class, 'setupGithubToken']],
|
|
||||||
), true);
|
|
||||||
$frankenPhpVersion = $releaseInfo['tag_name'];
|
|
||||||
$libphpVersion = $this->getPHPVersion();
|
$libphpVersion = $this->getPHPVersion();
|
||||||
|
$dynamic_exports = '';
|
||||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
|
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 ' : '';
|
$debugFlags = $this->getOption('no-strip') ? '-w -s ' : '';
|
||||||
$extLdFlags = "-extldflags '-pie'";
|
$extLdFlags = "-extldflags '-pie{$dynamic_exports}'";
|
||||||
$muslTags = '';
|
$muslTags = '';
|
||||||
$staticFlags = '';
|
$staticFlags = '';
|
||||||
if (SPCTarget::isStatic()) {
|
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,';
|
$muslTags = 'static_build,';
|
||||||
$staticFlags = '-static-pie';
|
$staticFlags = '-static-pie';
|
||||||
}
|
}
|
||||||
@@ -303,9 +322,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
||||||
];
|
];
|
||||||
foreach (GoXcaddy::getEnvironment() as $key => $value) {
|
foreach (GoXcaddy::getEnvironment() as $key => $value) {
|
||||||
if ($key === 'PATH') {
|
if ($key !== 'PATH') {
|
||||||
GlobalEnvManager::addPathIfNotExists($value);
|
|
||||||
} else {
|
|
||||||
$env[$key] = $value;
|
$env[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,29 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder\unix\library;
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\util\executor\UnixAutoconfExecutor;
|
use SPC\util\executor\UnixAutoconfExecutor;
|
||||||
|
|
||||||
trait unixodbc
|
trait unixodbc
|
||||||
{
|
{
|
||||||
protected function build(): void
|
protected function build(): void
|
||||||
{
|
{
|
||||||
|
$sysconf_selector = match (PHP_OS_FAMILY) {
|
||||||
|
'Darwin' => match (GNU_ARCH) {
|
||||||
|
'x86_64' => '/usr/local/etc',
|
||||||
|
'aarch64' => '/opt/homebrew/etc',
|
||||||
|
default => throw new WrongUsageException('Unsupported architecture: ' . GNU_ARCH),
|
||||||
|
},
|
||||||
|
'Linux' => '/etc',
|
||||||
|
default => throw new WrongUsageException('Unsupported OS: ' . PHP_OS_FAMILY),
|
||||||
|
};
|
||||||
UnixAutoconfExecutor::create($this)
|
UnixAutoconfExecutor::create($this)
|
||||||
->configure(
|
->configure(
|
||||||
'--disable-debug',
|
'--disable-debug',
|
||||||
'--disable-dependency-tracking',
|
'--disable-dependency-tracking',
|
||||||
"--with-libiconv-prefix={$this->getBuildRootPath()}",
|
"--with-libiconv-prefix={$this->getBuildRootPath()}",
|
||||||
'--with-included-ltdl',
|
'--with-included-ltdl',
|
||||||
|
"--sysconfdir={$sysconf_selector}",
|
||||||
'--enable-gui=no',
|
'--enable-gui=no',
|
||||||
)
|
)
|
||||||
->make();
|
->make();
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class BuildPHPCommand extends BuildCommand
|
|||||||
$this->addOption('build-fpm', null, null, 'Build fpm SAPI (not available on Windows)');
|
$this->addOption('build-fpm', null, null, 'Build fpm SAPI (not available on Windows)');
|
||||||
$this->addOption('build-embed', null, null, 'Build embed SAPI (not available on Windows)');
|
$this->addOption('build-embed', null, null, 'Build embed SAPI (not available on Windows)');
|
||||||
$this->addOption('build-frankenphp', null, null, 'Build FrankenPHP SAPI (not available on Windows)');
|
$this->addOption('build-frankenphp', null, null, 'Build FrankenPHP SAPI (not available on Windows)');
|
||||||
|
$this->addOption('build-cgi', null, null, 'Build cgi SAPI (not available on Windows)');
|
||||||
$this->addOption('build-all', null, null, 'Build all SAPI');
|
$this->addOption('build-all', null, null, 'Build all SAPI');
|
||||||
$this->addOption('no-strip', null, null, 'build without strip, keep symbols to debug');
|
$this->addOption('no-strip', null, null, 'build without strip, keep symbols to debug');
|
||||||
$this->addOption('disable-opcache-jit', null, null, 'disable opcache jit');
|
$this->addOption('disable-opcache-jit', null, null, 'disable opcache jit');
|
||||||
@@ -211,12 +212,6 @@ class BuildPHPCommand extends BuildCommand
|
|||||||
// start to build
|
// start to build
|
||||||
$builder->buildPHP($rule);
|
$builder->buildPHP($rule);
|
||||||
|
|
||||||
// build dynamic extensions if needed
|
|
||||||
if (!empty($shared_extensions)) {
|
|
||||||
logger()->info('Building shared extensions ...');
|
|
||||||
$builder->buildSharedExts();
|
|
||||||
}
|
|
||||||
|
|
||||||
$builder->testPHP($rule);
|
$builder->testPHP($rule);
|
||||||
|
|
||||||
// compile stopwatch :P
|
// compile stopwatch :P
|
||||||
@@ -280,6 +275,7 @@ class BuildPHPCommand extends BuildCommand
|
|||||||
$rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE);
|
$rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE);
|
||||||
$rule |= $this->getOption('build-embed') || !empty($shared_extensions) ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE;
|
$rule |= $this->getOption('build-embed') || !empty($shared_extensions) ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE;
|
||||||
$rule |= ($this->getOption('build-frankenphp') ? (BUILD_TARGET_FRANKENPHP | BUILD_TARGET_EMBED) : BUILD_TARGET_NONE);
|
$rule |= ($this->getOption('build-frankenphp') ? (BUILD_TARGET_FRANKENPHP | BUILD_TARGET_EMBED) : BUILD_TARGET_NONE);
|
||||||
|
$rule |= ($this->getOption('build-cgi') ? BUILD_TARGET_CGI : BUILD_TARGET_NONE);
|
||||||
$rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE);
|
$rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE);
|
||||||
return $rule;
|
return $rule;
|
||||||
}
|
}
|
||||||
|
|||||||
50
src/SPC/doctor/item/PkgConfigCheck.php
Normal file
50
src/SPC/doctor/item/PkgConfigCheck.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\doctor\item;
|
||||||
|
|
||||||
|
use SPC\doctor\AsCheckItem;
|
||||||
|
use SPC\doctor\AsFixItem;
|
||||||
|
use SPC\doctor\CheckResult;
|
||||||
|
use SPC\doctor\OptionalCheck;
|
||||||
|
use SPC\store\PackageManager;
|
||||||
|
use SPC\util\PkgConfigUtil;
|
||||||
|
|
||||||
|
#[OptionalCheck([self::class, 'optionalCheck'])]
|
||||||
|
class PkgConfigCheck
|
||||||
|
{
|
||||||
|
public static function optionalCheck(): bool
|
||||||
|
{
|
||||||
|
return PHP_OS_FAMILY !== 'Windows';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @noinspection PhpUnused */
|
||||||
|
#[AsCheckItem('if pkg-config is installed or built', level: 800)]
|
||||||
|
public function checkPkgConfig(): CheckResult
|
||||||
|
{
|
||||||
|
if (!($pkgconf = PkgConfigUtil::findPkgConfig())) {
|
||||||
|
return CheckResult::fail('pkg-config is not installed', 'install-pkgconfig');
|
||||||
|
}
|
||||||
|
return CheckResult::ok($pkgconf);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[AsCheckItem('if pkg-config is working', level: 799)]
|
||||||
|
public function checkPkgConfigFunctional(): CheckResult
|
||||||
|
{
|
||||||
|
$pkgconf = PkgConfigUtil::findPkgConfig();
|
||||||
|
// check if pkg-config is functional
|
||||||
|
[$ret, $output] = shell()->execWithResult("{$pkgconf} --version", false);
|
||||||
|
if ($ret === 0) {
|
||||||
|
return CheckResult::ok(implode(' ', $output));
|
||||||
|
}
|
||||||
|
return CheckResult::fail('pkg-config is not functional', 'install-pkgconfig');
|
||||||
|
}
|
||||||
|
|
||||||
|
#[AsFixItem('install-pkgconfig')]
|
||||||
|
public function installPkgConfig(): bool
|
||||||
|
{
|
||||||
|
PackageManager::installPackage('pkg-config');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,9 +14,9 @@ use SPC\builder\Extension;
|
|||||||
*/
|
*/
|
||||||
class ValidationException extends SPCException
|
class ValidationException extends SPCException
|
||||||
{
|
{
|
||||||
private null|array|string $validation_module = null;
|
private array|string|null $validation_module = null;
|
||||||
|
|
||||||
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null, null|array|string $validation_module = null)
|
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null, array|string|null $validation_module = null)
|
||||||
{
|
{
|
||||||
parent::__construct($message, $code, $previous);
|
parent::__construct($message, $code, $previous);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace SPC\toolchain;
|
|||||||
use SPC\builder\linux\SystemUtil;
|
use SPC\builder\linux\SystemUtil;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\util\GlobalEnvManager;
|
use SPC\util\GlobalEnvManager;
|
||||||
|
use SPC\util\PkgConfigUtil;
|
||||||
use SPC\util\SPCTarget;
|
use SPC\util\SPCTarget;
|
||||||
|
|
||||||
class ToolchainManager
|
class ToolchainManager
|
||||||
@@ -56,6 +57,15 @@ class ToolchainManager
|
|||||||
if (SPCTarget::getLibc() === 'glibc' && SystemUtil::isMuslDist()) {
|
if (SPCTarget::getLibc() === 'glibc' && SystemUtil::isMuslDist()) {
|
||||||
throw new WrongUsageException('You are linking against glibc dynamically, which is only supported on glibc distros.');
|
throw new WrongUsageException('You are linking against glibc dynamically, which is only supported on glibc distros.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// init pkg-config for unix
|
||||||
|
if (is_unix()) {
|
||||||
|
if (($found = PkgConfigUtil::findPkgConfig()) === null) {
|
||||||
|
throw new WrongUsageException('Cannot find pkg-config executable. Please run `doctor` to fix this.');
|
||||||
|
}
|
||||||
|
GlobalEnvManager::putenv("PKG_CONFIG={$found}");
|
||||||
|
}
|
||||||
|
|
||||||
$toolchain = getenv('SPC_TOOLCHAIN');
|
$toolchain = getenv('SPC_TOOLCHAIN');
|
||||||
/* @var ToolchainInterface $toolchain */
|
/* @var ToolchainInterface $toolchain */
|
||||||
$instance = new $toolchain();
|
$instance = new $toolchain();
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ class GlobalEnvManager
|
|||||||
// Define env vars for unix
|
// Define env vars for unix
|
||||||
if (is_unix()) {
|
if (is_unix()) {
|
||||||
self::addPathIfNotExists(BUILD_BIN_PATH);
|
self::addPathIfNotExists(BUILD_BIN_PATH);
|
||||||
self::putenv('PKG_CONFIG=' . BUILD_BIN_PATH . '/pkg-config');
|
self::addPathIfNotExists(PKG_ROOT_PATH . '/bin');
|
||||||
self::putenv('PKG_CONFIG_PATH=' . BUILD_ROOT_PATH . '/lib/pkgconfig');
|
self::putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig');
|
||||||
}
|
}
|
||||||
|
|
||||||
$ini = self::readIniFile();
|
$ini = self::readIniFile();
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class LicenseDumper
|
|||||||
/**
|
/**
|
||||||
* Loads a source license file from the specified path.
|
* Loads a source license file from the specified path.
|
||||||
*/
|
*/
|
||||||
private function loadSourceFile(string $source_name, int $index, null|array|string $in_path, ?string $custom_base_path = null): string
|
private function loadSourceFile(string $source_name, int $index, array|string|null $in_path, ?string $custom_base_path = null): string
|
||||||
{
|
{
|
||||||
if (is_null($in_path)) {
|
if (is_null($in_path)) {
|
||||||
throw new SPCInternalException("source [{$source_name}] license file is not set, please check config/source.json");
|
throw new SPCInternalException("source [{$source_name}] license file is not set, please check config/source.json");
|
||||||
|
|||||||
@@ -14,6 +14,28 @@ use SPC\exception\ExecutionException;
|
|||||||
*/
|
*/
|
||||||
class PkgConfigUtil
|
class PkgConfigUtil
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Find the pkg-config executable which is compatible with static builds.
|
||||||
|
*
|
||||||
|
* @return null|string Path to pkg-config executable, or null if not found
|
||||||
|
*/
|
||||||
|
public static function findPkgConfig(): ?string
|
||||||
|
{
|
||||||
|
// Find pkg-config executable
|
||||||
|
$find_list = [
|
||||||
|
PKG_ROOT_PATH . '/bin/pkg-config',
|
||||||
|
BUILD_BIN_PATH . '/pkg-config',
|
||||||
|
];
|
||||||
|
$found = null;
|
||||||
|
foreach ($find_list as $file) {
|
||||||
|
if (file_exists($file) && is_executable($file)) {
|
||||||
|
$found = $file;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $found;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the version of a module.
|
* Returns the version of a module.
|
||||||
* This method uses `pkg-config --modversion` to get the version of the specified module.
|
* This method uses `pkg-config --modversion` to get the version of the specified module.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use SPC\builder\freebsd\library\BSDLibraryBase;
|
|||||||
use SPC\builder\linux\library\LinuxLibraryBase;
|
use SPC\builder\linux\library\LinuxLibraryBase;
|
||||||
use SPC\builder\macos\library\MacOSLibraryBase;
|
use SPC\builder\macos\library\MacOSLibraryBase;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\util\PkgConfigUtil;
|
||||||
use SPC\util\shell\UnixShell;
|
use SPC\util\shell\UnixShell;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -184,6 +185,7 @@ class UnixCMakeExecutor extends Executor
|
|||||||
$cxx = getenv('CCX');
|
$cxx = getenv('CCX');
|
||||||
logger()->debug("making cmake tool chain file for {$os} {$target_arch} with CFLAGS='{$cflags}'");
|
logger()->debug("making cmake tool chain file for {$os} {$target_arch} with CFLAGS='{$cflags}'");
|
||||||
$root = BUILD_ROOT_PATH;
|
$root = BUILD_ROOT_PATH;
|
||||||
|
$pkgConfigExecutable = PkgConfigUtil::findPkgConfig();
|
||||||
$ccLine = '';
|
$ccLine = '';
|
||||||
if ($cc) {
|
if ($cc) {
|
||||||
$ccLine = 'SET(CMAKE_C_COMPILER ' . $cc . ')';
|
$ccLine = 'SET(CMAKE_C_COMPILER ' . $cc . ')';
|
||||||
@@ -202,7 +204,7 @@ SET(CMAKE_PREFIX_PATH "{$root}")
|
|||||||
SET(CMAKE_INSTALL_PREFIX "{$root}")
|
SET(CMAKE_INSTALL_PREFIX "{$root}")
|
||||||
SET(CMAKE_INSTALL_LIBDIR "lib")
|
SET(CMAKE_INSTALL_LIBDIR "lib")
|
||||||
|
|
||||||
set(PKG_CONFIG_EXECUTABLE "{$root}/bin/pkg-config")
|
set(PKG_CONFIG_EXECUTABLE "{$pkgConfigExecutable}")
|
||||||
list(APPEND PKG_CONFIG_EXECUTABLE "--static")
|
list(APPEND PKG_CONFIG_EXECUTABLE "--static")
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ const BUILD_TARGET_MICRO = 2; // build micro
|
|||||||
const BUILD_TARGET_FPM = 4; // build fpm
|
const BUILD_TARGET_FPM = 4; // build fpm
|
||||||
const BUILD_TARGET_EMBED = 8; // build embed
|
const BUILD_TARGET_EMBED = 8; // build embed
|
||||||
const BUILD_TARGET_FRANKENPHP = 16; // build frankenphp
|
const BUILD_TARGET_FRANKENPHP = 16; // build frankenphp
|
||||||
const BUILD_TARGET_ALL = BUILD_TARGET_CLI | BUILD_TARGET_MICRO | BUILD_TARGET_FPM | BUILD_TARGET_EMBED | BUILD_TARGET_FRANKENPHP; // build all
|
const BUILD_TARGET_CGI = 32; // build cgi
|
||||||
|
const BUILD_TARGET_ALL = BUILD_TARGET_CLI | BUILD_TARGET_MICRO | BUILD_TARGET_FPM | BUILD_TARGET_EMBED | BUILD_TARGET_FRANKENPHP | BUILD_TARGET_CGI; // build all
|
||||||
|
|
||||||
// doctor error fix policy
|
// doctor error fix policy
|
||||||
const FIX_POLICY_DIE = 1; // die directly
|
const FIX_POLICY_DIE = 1; // die directly
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ define('BUILD_BIN_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_BI
|
|||||||
// output path for shared extensions
|
// output path for shared extensions
|
||||||
define('BUILD_MODULES_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_MODULES_PATH')) ? $a : (BUILD_ROOT_PATH . '/modules')));
|
define('BUILD_MODULES_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_MODULES_PATH')) ? $a : (BUILD_ROOT_PATH . '/modules')));
|
||||||
|
|
||||||
define('PKG_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('PKG_ROOT_PATH')) ? $a : (WORKING_DIR . '/pkgroot')));
|
// pkg arch name
|
||||||
|
$_pkg_arch_name = arch2gnu(php_uname('m')) . '-' . strtolower(PHP_OS_FAMILY);
|
||||||
|
define('PKG_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('PKG_ROOT_PATH')) ? $a : (WORKING_DIR . "/pkgroot/{$_pkg_arch_name}")));
|
||||||
|
|
||||||
define('SOURCE_PATH', FileSystem::convertPath(is_string($a = getenv('SOURCE_PATH')) ? $a : (WORKING_DIR . '/source')));
|
define('SOURCE_PATH', FileSystem::convertPath(is_string($a = getenv('SOURCE_PATH')) ? $a : (WORKING_DIR . '/source')));
|
||||||
define('DOWNLOAD_PATH', FileSystem::convertPath(is_string($a = getenv('DOWNLOAD_PATH')) ? $a : (WORKING_DIR . '/downloads')));
|
define('DOWNLOAD_PATH', FileSystem::convertPath(is_string($a = getenv('DOWNLOAD_PATH')) ? $a : (WORKING_DIR . '/downloads')));
|
||||||
define('CPU_COUNT', match (PHP_OS_FAMILY) {
|
define('CPU_COUNT', match (PHP_OS_FAMILY) {
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
// test php version (8.1 ~ 8.4 available, multiple for matrix)
|
// test php version (8.1 ~ 8.4 available, multiple for matrix)
|
||||||
$test_php_version = [
|
$test_php_version = [
|
||||||
'8.1',
|
// '8.1',
|
||||||
'8.2',
|
// '8.2',
|
||||||
'8.3',
|
// '8.3',
|
||||||
'8.4',
|
'8.4',
|
||||||
// '8.5',
|
// '8.5',
|
||||||
// 'git',
|
// 'git',
|
||||||
@@ -28,9 +28,9 @@ $test_os = [
|
|||||||
'macos-15', // bin/spc for arm64
|
'macos-15', // bin/spc for arm64
|
||||||
'ubuntu-latest', // bin/spc-alpine-docker for x86_64
|
'ubuntu-latest', // bin/spc-alpine-docker for x86_64
|
||||||
'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
|
'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
|
||||||
'ubuntu-24.04', // bin/spc for x86_64
|
// 'ubuntu-24.04', // bin/spc for x86_64
|
||||||
'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
|
'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
|
||||||
'ubuntu-24.04-arm', // bin/spc for arm64
|
// 'ubuntu-24.04-arm', // bin/spc for arm64
|
||||||
// 'windows-latest', // .\bin\spc.ps1
|
// 'windows-latest', // .\bin\spc.ps1
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -50,13 +50,13 @@ $prefer_pre_built = false;
|
|||||||
|
|
||||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||||
$extensions = match (PHP_OS_FAMILY) {
|
$extensions = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => 'swoole,swoole-hook-mysql,swoole-hook-pgsql,swoole-hook-sqlite,swoole-hook-odbc,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib',
|
'Linux', 'Darwin' => 'bcmath',
|
||||||
'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pdo,pdo_mysql,pdo_sqlite,phar,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip',
|
'Windows' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pdo,pdo_mysql,pdo_sqlite,phar,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip',
|
||||||
};
|
};
|
||||||
|
|
||||||
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
|
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
|
||||||
$shared_extensions = match (PHP_OS_FAMILY) {
|
$shared_extensions = match (PHP_OS_FAMILY) {
|
||||||
'Linux' => '',
|
'Linux' => 'zip',
|
||||||
'Darwin' => '',
|
'Darwin' => '',
|
||||||
'Windows' => '',
|
'Windows' => '',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ class BuilderTest extends TestCase
|
|||||||
[BUILD_TARGET_MICRO, 'micro'],
|
[BUILD_TARGET_MICRO, 'micro'],
|
||||||
[BUILD_TARGET_EMBED, 'embed'],
|
[BUILD_TARGET_EMBED, 'embed'],
|
||||||
[BUILD_TARGET_FRANKENPHP, 'frankenphp'],
|
[BUILD_TARGET_FRANKENPHP, 'frankenphp'],
|
||||||
[BUILD_TARGET_ALL, 'cli, micro, fpm, embed, frankenphp'],
|
[BUILD_TARGET_ALL, 'cli, micro, fpm, embed, frankenphp, cgi'],
|
||||||
[BUILD_TARGET_CLI | BUILD_TARGET_EMBED, 'cli, embed'],
|
[BUILD_TARGET_CLI | BUILD_TARGET_EMBED, 'cli, embed'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user