mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 07:15:38 +08:00
Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79ab6490fd | ||
|
|
191d345250 | ||
|
|
311ee40ae4 | ||
|
|
808d224b08 | ||
|
|
4247883664 | ||
|
|
3198cc40c1 | ||
|
|
8680e83af3 | ||
|
|
0156f33a20 | ||
|
|
df8b2dbf16 | ||
|
|
30e174ac95 | ||
|
|
b9f8f02d98 | ||
|
|
0b0ae270da | ||
|
|
893ce31b17 | ||
|
|
e35d6c2651 | ||
|
|
8dd0512335 | ||
|
|
5c1194ea92 | ||
|
|
953ed83df5 | ||
|
|
c330d02e78 | ||
|
|
af6a23011c | ||
|
|
882ae07deb | ||
|
|
4bc30b0b6f | ||
|
|
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 |
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}"
|
||||||
|
|
||||||
|
|||||||
@@ -414,9 +414,17 @@
|
|||||||
"libmemcached",
|
"libmemcached",
|
||||||
"fastlz"
|
"fastlz"
|
||||||
],
|
],
|
||||||
|
"lib-suggests": [
|
||||||
|
"zstd"
|
||||||
|
],
|
||||||
"ext-depends": [
|
"ext-depends": [
|
||||||
"session",
|
"session",
|
||||||
"zlib"
|
"zlib"
|
||||||
|
],
|
||||||
|
"ext-suggests": [
|
||||||
|
"igbinary",
|
||||||
|
"msgpack",
|
||||||
|
"session"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mongodb": {
|
"mongodb": {
|
||||||
|
|||||||
@@ -9,12 +9,17 @@
|
|||||||
"lib-base",
|
"lib-base",
|
||||||
"micro"
|
"micro"
|
||||||
],
|
],
|
||||||
|
"lib-depends-macos": [
|
||||||
|
"lib-base",
|
||||||
|
"micro",
|
||||||
|
"libxml2"
|
||||||
|
],
|
||||||
"lib-suggests-linux": [
|
"lib-suggests-linux": [
|
||||||
"libacl",
|
"libacl",
|
||||||
"brotli",
|
"brotli",
|
||||||
"watcher"
|
"watcher"
|
||||||
],
|
],
|
||||||
"lib-suggests-unix": [
|
"lib-suggests-macos": [
|
||||||
"brotli",
|
"brotli",
|
||||||
"watcher"
|
"watcher"
|
||||||
]
|
]
|
||||||
@@ -447,6 +452,7 @@
|
|||||||
},
|
},
|
||||||
"libmemcached": {
|
"libmemcached": {
|
||||||
"source": "libmemcached",
|
"source": "libmemcached",
|
||||||
|
"cpp-library": true,
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
"libmemcached.a",
|
"libmemcached.a",
|
||||||
"libmemcachedprotocol.a",
|
"libmemcachedprotocol.a",
|
||||||
@@ -591,7 +597,6 @@
|
|||||||
],
|
],
|
||||||
"lib-suggests-unix": [
|
"lib-suggests-unix": [
|
||||||
"xz",
|
"xz",
|
||||||
"icu",
|
|
||||||
"zlib"
|
"zlib"
|
||||||
],
|
],
|
||||||
"lib-depends-windows": [
|
"lib-depends-windows": [
|
||||||
|
|||||||
@@ -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');
|
||||||
|
|||||||
@@ -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.4';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use SPC\exception\WrongUsageException;
|
|||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\store\LockFile;
|
use SPC\store\LockFile;
|
||||||
|
use SPC\store\pkg\GoXcaddy;
|
||||||
use SPC\store\SourceManager;
|
use SPC\store\SourceManager;
|
||||||
use SPC\store\SourcePatcher;
|
use SPC\store\SourcePatcher;
|
||||||
use SPC\util\AttributeMapper;
|
use SPC\util\AttributeMapper;
|
||||||
@@ -392,6 +393,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,8 +508,7 @@ abstract class BuilderBase
|
|||||||
throw new WrongUsageException('FrankenPHP SAPI is only available on Linux and macOS!');
|
throw new WrongUsageException('FrankenPHP SAPI is only available on Linux and macOS!');
|
||||||
}
|
}
|
||||||
// frankenphp needs package go-xcaddy installed
|
// frankenphp needs package go-xcaddy installed
|
||||||
$pkg_dir = PKG_ROOT_PATH . '/go-xcaddy-' . arch2gnu(php_uname('m')) . '-' . osfamily2shortname();
|
if (!GoXcaddy::isInstalled()) {
|
||||||
if (!file_exists("{$pkg_dir}/bin/go") || !file_exists("{$pkg_dir}/bin/xcaddy")) {
|
|
||||||
global $argv;
|
global $argv;
|
||||||
throw new WrongUsageException("FrankenPHP SAPI requires the go-xcaddy package, please install it first: {$argv[0]} install-pkg go-xcaddy");
|
throw new WrongUsageException("FrankenPHP SAPI requires the go-xcaddy package, please install it first: {$argv[0]} install-pkg go-xcaddy");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,14 @@ declare(strict_types=1);
|
|||||||
namespace SPC\builder;
|
namespace SPC\builder;
|
||||||
|
|
||||||
use SPC\exception\EnvironmentException;
|
use SPC\exception\EnvironmentException;
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\SPCException;
|
use SPC\exception\SPCException;
|
||||||
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\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\toolchain\ClangNativeToolchain;
|
||||||
|
use SPC\toolchain\GccNativeToolchain;
|
||||||
use SPC\toolchain\ToolchainManager;
|
use SPC\toolchain\ToolchainManager;
|
||||||
use SPC\toolchain\ZigToolchain;
|
use SPC\toolchain\ZigToolchain;
|
||||||
use SPC\util\SPCConfigUtil;
|
use SPC\util\SPCConfigUtil;
|
||||||
@@ -418,8 +421,24 @@ class Extension
|
|||||||
'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"),
|
'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"),
|
||||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
||||||
];
|
];
|
||||||
if (ToolchainManager::getToolchainClass() === ZigToolchain::class && SPCTarget::getTargetOS() === 'Linux') {
|
if (str_contains($env['LIBS'], '-lstdc++') && SPCTarget::getTargetOS() === 'Linux') {
|
||||||
|
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
||||||
$env['SPC_COMPILER_EXTRA'] = '-lstdc++';
|
$env['SPC_COMPILER_EXTRA'] = '-lstdc++';
|
||||||
|
} elseif (ToolchainManager::getToolchainClass() === GccNativeToolchain::class || ToolchainManager::getToolchainClass() === ClangNativeToolchain::class) {
|
||||||
|
try {
|
||||||
|
$content = FileSystem::readFile($this->source_dir . '/config.m4');
|
||||||
|
if ($content && !str_contains($content, 'PHP_ADD_LIBRARY(stdc++')) {
|
||||||
|
$pattern = '/(PHP_NEW_EXTENSION\(' . $this->name . ',.*\))/m';
|
||||||
|
$replacement = "$1\nPHP_ADD_LIBRARY(stdc++, 1, " . strtoupper($this->name) . '_SHARED_LIBADD)';
|
||||||
|
FileSystem::replaceFileRegex(
|
||||||
|
$this->source_dir . '/config.m4',
|
||||||
|
$pattern,
|
||||||
|
$replacement
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (FileSystemException) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->patchBeforeSharedPhpize()) {
|
if ($this->patchBeforeSharedPhpize()) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class dba extends Extension
|
|||||||
{
|
{
|
||||||
public function getUnixConfigureArg(bool $shared = false): string
|
public function getUnixConfigureArg(bool $shared = false): string
|
||||||
{
|
{
|
||||||
$qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH) : '';
|
$qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . BUILD_ROOT_PATH) : '';
|
||||||
return '--enable-dba' . ($shared ? '=shared' : '') . $qdbm;
|
return '--enable-dba' . ($shared ? '=shared' : '') . $qdbm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ class memcached extends Extension
|
|||||||
'--with-libmemcached-dir=' . BUILD_ROOT_PATH . ' ' .
|
'--with-libmemcached-dir=' . BUILD_ROOT_PATH . ' ' .
|
||||||
'--disable-memcached-sasl ' .
|
'--disable-memcached-sasl ' .
|
||||||
'--enable-memcached-json ' .
|
'--enable-memcached-json ' .
|
||||||
|
($this->builder->getLib('zstd') ? '--with-zstd ' : '') .
|
||||||
|
($this->builder->getExt('igbinary') ? '--enable-memcached-igbinary ' : '') .
|
||||||
|
($this->builder->getExt('session') ? '--enable-memcached-session ' : '') .
|
||||||
|
($this->builder->getExt('msgpack') ? '--enable-memcached-msgpack ' : '') .
|
||||||
'--with-system-fastlz';
|
'--with-system-fastlz';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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__';
|
||||||
@@ -102,21 +103,21 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')
|
$this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
|
||||||
->exec(
|
|
||||||
$php_configure_env . ' ' .
|
$php_configure_env . ' ' .
|
||||||
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
||||||
($enableCli ? '--enable-cli ' : '--disable-cli ') .
|
($enableCli ? '--enable-cli ' : '--disable-cli ') .
|
||||||
($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 .
|
||||||
$zts .
|
$zts .
|
||||||
$maxExecutionTimers .
|
$maxExecutionTimers .
|
||||||
$this->makeStaticExtensionArgs() . ' '
|
$this->makeStaticExtensionArgs() . ' '
|
||||||
);
|
));
|
||||||
|
|
||||||
$this->emitPatchPoint('before-php-make');
|
$this->emitPatchPoint('before-php-make');
|
||||||
SourcePatcher::patchBeforeMake($this);
|
SourcePatcher::patchBeforeMake($this);
|
||||||
@@ -131,6 +132,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,16 +147,15 @@ 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
|
if ($enableFrankenphp) {
|
||||||
|
logger()->info('building frankenphp');
|
||||||
|
$this->buildFrankenphp();
|
||||||
|
}
|
||||||
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
|
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
|
||||||
if (!empty($shared_extensions)) {
|
if (!empty($shared_extensions)) {
|
||||||
logger()->info('Building shared extensions ...');
|
logger()->info('Building shared extensions ...');
|
||||||
$this->buildSharedExts();
|
$this->buildSharedExts();
|
||||||
}
|
}
|
||||||
if ($enableFrankenphp) {
|
|
||||||
logger()->info('building frankenphp');
|
|
||||||
$this->buildFrankenphp();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPHP(int $build_target = BUILD_TARGET_NONE)
|
public function testPHP(int $build_target = BUILD_TARGET_NONE)
|
||||||
@@ -182,6 +186,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
|
||||||
*/
|
*/
|
||||||
@@ -302,7 +325,7 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
$target = "{$libDir}/{$realLibName}";
|
$target = "{$libDir}/{$realLibName}";
|
||||||
if (file_exists($target)) {
|
if (file_exists($target)) {
|
||||||
[, $output] = shell()->execWithResult('readelf -d ' . escapeshellarg($target));
|
[, $output] = shell()->execWithResult('readelf -d ' . escapeshellarg($target));
|
||||||
$output = join("\n", $output);
|
$output = implode("\n", $output);
|
||||||
if (preg_match('/SONAME.*\[(.+)]/', $output, $sonameMatch)) {
|
if (preg_match('/SONAME.*\[(.+)]/', $output, $sonameMatch)) {
|
||||||
$currentSoname = $sonameMatch[1];
|
$currentSoname = $sonameMatch[1];
|
||||||
if ($currentSoname !== basename($target)) {
|
if ($currentSoname !== basename($target)) {
|
||||||
|
|||||||
@@ -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([
|
||||||
@@ -117,20 +118,20 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
|
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')
|
$this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
|
||||||
->exec(
|
|
||||||
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
||||||
($enableCli ? '--enable-cli ' : '--disable-cli ') .
|
($enableCli ? '--enable-cli ' : '--disable-cli ') .
|
||||||
($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 .
|
||||||
$zts .
|
$zts .
|
||||||
$this->makeStaticExtensionArgs() . ' ' .
|
$this->makeStaticExtensionArgs() . ' ' .
|
||||||
$envs_build_php
|
$envs_build_php
|
||||||
);
|
));
|
||||||
|
|
||||||
$this->emitPatchPoint('before-php-make');
|
$this->emitPatchPoint('before-php-make');
|
||||||
SourcePatcher::patchBeforeMake($this);
|
SourcePatcher::patchBeforeMake($this);
|
||||||
@@ -145,6 +146,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,15 +161,15 @@ class MacOSBuilder extends UnixBuilderBase
|
|||||||
}
|
}
|
||||||
$this->buildEmbed();
|
$this->buildEmbed();
|
||||||
}
|
}
|
||||||
|
if ($enableFrankenphp) {
|
||||||
|
logger()->info('building frankenphp');
|
||||||
|
$this->buildFrankenphp();
|
||||||
|
}
|
||||||
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
|
$shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared'))));
|
||||||
if (!empty($shared_extensions)) {
|
if (!empty($shared_extensions)) {
|
||||||
logger()->info('Building shared extensions ...');
|
logger()->info('Building shared extensions ...');
|
||||||
$this->buildSharedExts();
|
$this->buildSharedExts();
|
||||||
}
|
}
|
||||||
if ($enableFrankenphp) {
|
|
||||||
logger()->info('building frankenphp');
|
|
||||||
$this->buildFrankenphp();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPHP(int $build_target = BUILD_TARGET_NONE)
|
public function testPHP(int $build_target = BUILD_TARGET_NONE)
|
||||||
@@ -189,6 +194,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
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,12 +6,11 @@ namespace SPC\builder\unix;
|
|||||||
|
|
||||||
use SPC\builder\BuilderBase;
|
use SPC\builder\BuilderBase;
|
||||||
use SPC\builder\linux\SystemUtil as LinuxSystemUtil;
|
use SPC\builder\linux\SystemUtil as LinuxSystemUtil;
|
||||||
|
use SPC\exception\SPCException;
|
||||||
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;
|
||||||
@@ -122,6 +121,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');
|
||||||
@@ -209,6 +218,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');
|
||||||
@@ -257,6 +267,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
|
|
||||||
protected function buildFrankenphp(): void
|
protected function buildFrankenphp(): void
|
||||||
{
|
{
|
||||||
|
GlobalEnvManager::addPathIfNotExists(GoXcaddy::getPath());
|
||||||
$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');
|
||||||
@@ -268,11 +279,8 @@ 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 = '';
|
$dynamic_exports = '';
|
||||||
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
|
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
|
||||||
@@ -303,24 +311,17 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
$cflags .= ' -Wno-error=missing-profile';
|
$cflags .= ' -Wno-error=missing-profile';
|
||||||
$libs .= ' -lgcov';
|
$libs .= ' -lgcov';
|
||||||
}
|
}
|
||||||
$env = [
|
$env = [...[
|
||||||
'CGO_ENABLED' => '1',
|
'CGO_ENABLED' => '1',
|
||||||
'CGO_CFLAGS' => clean_spaces($cflags),
|
'CGO_CFLAGS' => clean_spaces($cflags),
|
||||||
'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}",
|
'CGO_LDFLAGS' => "{$this->arch_ld_flags} {$staticFlags} {$config['ldflags']} {$libs}",
|
||||||
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
|
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
|
||||||
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . $debugFlags .
|
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . $debugFlags .
|
||||||
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
|
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
|
||||||
"{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .
|
"v{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " .
|
||||||
"-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}",
|
"-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}",
|
||||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
||||||
];
|
], ...GoXcaddy::getEnvironment()];
|
||||||
foreach (GoXcaddy::getEnvironment() as $key => $value) {
|
|
||||||
if ($key === 'PATH') {
|
|
||||||
GlobalEnvManager::addPathIfNotExists($value);
|
|
||||||
} else {
|
|
||||||
$env[$key] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
shell()->cd(BUILD_BIN_PATH)
|
shell()->cd(BUILD_BIN_PATH)
|
||||||
->setEnv($env)
|
->setEnv($env)
|
||||||
->exec("xcaddy build --output frankenphp {$xcaddyModules}");
|
->exec("xcaddy build --output frankenphp {$xcaddyModules}");
|
||||||
@@ -333,4 +334,20 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seek php-src/config.log when building PHP, add it to exception.
|
||||||
|
*/
|
||||||
|
protected function seekPhpSrcLogFileOnException(callable $callback): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$callback();
|
||||||
|
} catch (SPCException $e) {
|
||||||
|
if (file_exists(SOURCE_PATH . '/php-src/config.log')) {
|
||||||
|
$e->addExtraLogFile('php-src config.log', 'php-src.config.log');
|
||||||
|
copy(SOURCE_PATH . '/php-src/config.log', SPC_LOGS_DIR . '/php-src.config.log');
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,17 +20,17 @@ trait libxml2
|
|||||||
"-DZLIB_INCLUDE_DIR={$this->getIncludeDir()}",
|
"-DZLIB_INCLUDE_DIR={$this->getIncludeDir()}",
|
||||||
'-DLIBXML2_WITH_ZLIB=OFF',
|
'-DLIBXML2_WITH_ZLIB=OFF',
|
||||||
)
|
)
|
||||||
->optionalLib('icu', ...cmake_boolean_args('LIBXML2_WITH_ICU'))
|
|
||||||
->optionalLib('xz', ...cmake_boolean_args('LIBXML2_WITH_LZMA'))
|
->optionalLib('xz', ...cmake_boolean_args('LIBXML2_WITH_LZMA'))
|
||||||
->addConfigureArgs(
|
->addConfigureArgs(
|
||||||
'-DLIBXML2_WITH_ICONV=ON',
|
'-DLIBXML2_WITH_ICONV=ON',
|
||||||
|
'-DLIBXML2_WITH_ICU=OFF', // optional, but discouraged: https://gitlab.gnome.org/GNOME/libxml2/-/blob/master/README.md
|
||||||
'-DLIBXML2_WITH_PYTHON=OFF',
|
'-DLIBXML2_WITH_PYTHON=OFF',
|
||||||
'-DLIBXML2_WITH_PROGRAMS=OFF',
|
'-DLIBXML2_WITH_PROGRAMS=OFF',
|
||||||
'-DLIBXML2_WITH_TESTS=OFF',
|
'-DLIBXML2_WITH_TESTS=OFF',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this instanceof LinuxLibraryBase) {
|
if ($this instanceof LinuxLibraryBase) {
|
||||||
$cmake->addConfigureArgs('-DIconv_IS_BUILD_IN=OFF');
|
$cmake->addConfigureArgs('-DIconv_IS_BUILT_IN=OFF');
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmake->build();
|
$cmake->build();
|
||||||
|
|||||||
@@ -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');
|
||||||
@@ -274,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
|||||||
namespace SPC\command;
|
namespace SPC\command;
|
||||||
|
|
||||||
use SPC\exception\ValidationException;
|
use SPC\exception\ValidationException;
|
||||||
|
use SPC\store\pkg\GoXcaddy;
|
||||||
|
use SPC\store\pkg\Zig;
|
||||||
use SPC\toolchain\ToolchainManager;
|
use SPC\toolchain\ToolchainManager;
|
||||||
use SPC\toolchain\ZigToolchain;
|
use SPC\toolchain\ZigToolchain;
|
||||||
use SPC\util\ConfigValidator;
|
use SPC\util\ConfigValidator;
|
||||||
@@ -63,7 +65,7 @@ class CraftCommand extends BuildCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// install go and xcaddy for frankenphp
|
// install go and xcaddy for frankenphp
|
||||||
if (in_array('frankenphp', $craft['sapi'])) {
|
if (in_array('frankenphp', $craft['sapi']) && !GoXcaddy::isInstalled()) {
|
||||||
$retcode = $this->runCommand('install-pkg', 'go-xcaddy');
|
$retcode = $this->runCommand('install-pkg', 'go-xcaddy');
|
||||||
if ($retcode !== 0) {
|
if ($retcode !== 0) {
|
||||||
$this->output->writeln('<error>craft go-xcaddy failed</error>');
|
$this->output->writeln('<error>craft go-xcaddy failed</error>');
|
||||||
@@ -71,7 +73,7 @@ class CraftCommand extends BuildCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// install zig if requested
|
// install zig if requested
|
||||||
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
if (ToolchainManager::getToolchainClass() === ZigToolchain::class && !Zig::isInstalled()) {
|
||||||
$retcode = $this->runCommand('install-pkg', 'zig');
|
$retcode = $this->runCommand('install-pkg', 'zig');
|
||||||
if ($retcode !== 0) {
|
if ($retcode !== 0) {
|
||||||
$this->output->writeln('<error>craft zig failed</error>');
|
$this->output->writeln('<error>craft zig failed</error>');
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ class LinuxToolCheckList
|
|||||||
'base-devel' => 'automake',
|
'base-devel' => 'automake',
|
||||||
'gettext-devel' => 'gettextize',
|
'gettext-devel' => 'gettextize',
|
||||||
'gettext-dev' => 'gettextize',
|
'gettext-dev' => 'gettextize',
|
||||||
'perl-IPC-Cmd' => '/usr/share/doc/perl-IPC-Cmd',
|
'perl-IPC-Cmd' => '/usr/share/perl5/vendor_perl/IPC/Cmd.pm',
|
||||||
|
'perl-Time-Piece' => '/usr/lib64/perl5/Time/Piece.pm',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @noinspection PhpUnused */
|
/** @noinspection PhpUnused */
|
||||||
@@ -65,7 +66,7 @@ class LinuxToolCheckList
|
|||||||
$required = match ($distro['dist']) {
|
$required = match ($distro['dist']) {
|
||||||
'alpine' => self::TOOLS_ALPINE,
|
'alpine' => self::TOOLS_ALPINE,
|
||||||
'redhat' => self::TOOLS_RHEL,
|
'redhat' => self::TOOLS_RHEL,
|
||||||
'centos' => array_merge(self::TOOLS_RHEL, ['perl-IPC-Cmd']),
|
'centos' => array_merge(self::TOOLS_RHEL, ['perl-IPC-Cmd', 'perl-Time-Piece']),
|
||||||
'arch' => self::TOOLS_ARCH,
|
'arch' => self::TOOLS_ARCH,
|
||||||
default => self::TOOLS_DEBIAN,
|
default => self::TOOLS_DEBIAN,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,6 +29,18 @@ class PkgConfigCheck
|
|||||||
return CheckResult::ok($pkgconf);
|
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')]
|
#[AsFixItem('install-pkgconfig')]
|
||||||
public function installPkgConfig(): bool
|
public function installPkgConfig(): bool
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ class FileSystem
|
|||||||
public static function convertWinPathToMinGW(string $path): string
|
public static function convertWinPathToMinGW(string $path): string
|
||||||
{
|
{
|
||||||
if (preg_match('/^[A-Za-z]:/', $path)) {
|
if (preg_match('/^[A-Za-z]:/', $path)) {
|
||||||
$path = '/' . strtolower(substr($path, 0, 1)) . '/' . str_replace('\\', '/', substr($path, 2));
|
$path = '/' . strtolower($path[0]) . '/' . str_replace('\\', '/', substr($path, 2));
|
||||||
}
|
}
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
@@ -314,8 +314,13 @@ class FileSystem
|
|||||||
$sub_file = self::convertPath($dir . '/' . $v);
|
$sub_file = self::convertPath($dir . '/' . $v);
|
||||||
if (is_dir($sub_file) && $recursive) {
|
if (is_dir($sub_file) && $recursive) {
|
||||||
# 如果是 目录 且 递推 , 则递推添加下级文件
|
# 如果是 目录 且 递推 , 则递推添加下级文件
|
||||||
$list = array_merge($list, self::scanDirFiles($sub_file, $recursive, $relative));
|
$sub_list = self::scanDirFiles($sub_file, $recursive, $relative);
|
||||||
} elseif (is_file($sub_file) || is_dir($sub_file) && !$recursive && $include_dir) {
|
if (is_array($sub_list)) {
|
||||||
|
foreach ($sub_list as $item) {
|
||||||
|
$list[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif (is_file($sub_file) || (is_dir($sub_file) && !$recursive && $include_dir)) {
|
||||||
# 如果是 文件 或 (是 目录 且 不递推 且 包含目录)
|
# 如果是 文件 或 (是 目录 且 不递推 且 包含目录)
|
||||||
if (is_string($relative) && mb_strpos($sub_file, $relative) === 0) {
|
if (is_string($relative) && mb_strpos($sub_file, $relative) === 0) {
|
||||||
$list[] = ltrim(mb_substr($sub_file, mb_strlen($relative)), '/\\');
|
$list[] = ltrim(mb_substr($sub_file, mb_strlen($relative)), '/\\');
|
||||||
@@ -440,7 +445,7 @@ class FileSystem
|
|||||||
public static function writeFile(string $path, mixed $content, ...$args): bool|int|string
|
public static function writeFile(string $path, mixed $content, ...$args): bool|int|string
|
||||||
{
|
{
|
||||||
$dir = pathinfo(self::convertPath($path), PATHINFO_DIRNAME);
|
$dir = pathinfo(self::convertPath($path), PATHINFO_DIRNAME);
|
||||||
if (!is_dir($dir) && !mkdir($dir, 0755, true)) {
|
if (!is_dir($dir) && !mkdir($dir, 0755, true) && !is_dir($dir)) {
|
||||||
throw new FileSystemException('Write file failed, cannot create parent directory: ' . $dir);
|
throw new FileSystemException('Write file failed, cannot create parent directory: ' . $dir);
|
||||||
}
|
}
|
||||||
return file_put_contents($path, $content, ...$args);
|
return file_put_contents($path, $content, ...$args);
|
||||||
|
|||||||
@@ -30,10 +30,14 @@ abstract class CustomPackage
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the environment variables this package needs to be usable.
|
* Get the environment variables this package needs to be usable.
|
||||||
* PATH needs to be appended, rather than replaced.
|
|
||||||
*/
|
*/
|
||||||
abstract public static function getEnvironment(): array;
|
abstract public static function getEnvironment(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PATH required to use this package.
|
||||||
|
*/
|
||||||
|
abstract public static function getPath(): ?string;
|
||||||
|
|
||||||
abstract public static function isInstalled(): bool;
|
abstract public static function isInstalled(): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,18 +13,7 @@ class GoXcaddy extends CustomPackage
|
|||||||
{
|
{
|
||||||
public static function isInstalled(): bool
|
public static function isInstalled(): bool
|
||||||
{
|
{
|
||||||
$arch = arch2gnu(php_uname('m'));
|
$folder = PKG_ROOT_PATH . '/go-xcaddy';
|
||||||
$os = match (PHP_OS_FAMILY) {
|
|
||||||
'Windows' => 'win',
|
|
||||||
'Darwin' => 'macos',
|
|
||||||
'BSD' => 'freebsd',
|
|
||||||
default => 'linux',
|
|
||||||
};
|
|
||||||
|
|
||||||
$packageName = "go-xcaddy-{$arch}-{$os}";
|
|
||||||
$pkgroot = PKG_ROOT_PATH;
|
|
||||||
$folder = "{$pkgroot}/{$packageName}";
|
|
||||||
|
|
||||||
return is_dir($folder) && is_file("{$folder}/bin/go") && is_file("{$folder}/bin/xcaddy");
|
return is_dir($folder) && is_file("{$folder}/bin/go") && is_file("{$folder}/bin/xcaddy");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +48,7 @@ class GoXcaddy extends CustomPackage
|
|||||||
'macos' => 'darwin',
|
'macos' => 'darwin',
|
||||||
default => throw new \InvalidArgumentException('Unsupported OS: ' . $name),
|
default => throw new \InvalidArgumentException('Unsupported OS: ' . $name),
|
||||||
};
|
};
|
||||||
$go_version = '1.24.4';
|
$go_version = '1.25.0';
|
||||||
$config = [
|
$config = [
|
||||||
'type' => 'url',
|
'type' => 'url',
|
||||||
'url' => "https://go.dev/dl/go{$go_version}.{$os}-{$arch}.tar.gz",
|
'url' => "https://go.dev/dl/go{$go_version}.{$os}-{$arch}.tar.gz",
|
||||||
@@ -70,15 +59,15 @@ class GoXcaddy extends CustomPackage
|
|||||||
public function extract(string $name): void
|
public function extract(string $name): void
|
||||||
{
|
{
|
||||||
$pkgroot = PKG_ROOT_PATH;
|
$pkgroot = PKG_ROOT_PATH;
|
||||||
$go_exec = "{$pkgroot}/{$name}/bin/go";
|
$go_exec = "{$pkgroot}/go-xcaddy/bin/go";
|
||||||
$xcaddy_exec = "{$pkgroot}/{$name}/bin/xcaddy";
|
$xcaddy_exec = "{$pkgroot}/go-xcaddy/bin/xcaddy";
|
||||||
if (file_exists($go_exec) && file_exists($xcaddy_exec)) {
|
if (file_exists($go_exec) && file_exists($xcaddy_exec)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$lock = json_decode(FileSystem::readFile(LockFile::LOCK_FILE), true);
|
$lock = json_decode(FileSystem::readFile(LockFile::LOCK_FILE), true);
|
||||||
$source_type = $lock[$name]['source_type'];
|
$source_type = $lock[$name]['source_type'];
|
||||||
$filename = DOWNLOAD_PATH . '/' . ($lock[$name]['filename'] ?? $lock[$name]['dirname']);
|
$filename = DOWNLOAD_PATH . '/' . ($lock[$name]['filename'] ?? $lock[$name]['dirname']);
|
||||||
$extract = $lock[$name]['move_path'] ?? "{$pkgroot}/{$name}";
|
$extract = $lock[$name]['move_path'] ?? "{$pkgroot}/go-xcaddy";
|
||||||
|
|
||||||
FileSystem::extractPackage($name, $source_type, $filename, $extract);
|
FileSystem::extractPackage($name, $source_type, $filename, $extract);
|
||||||
|
|
||||||
@@ -91,9 +80,9 @@ class GoXcaddy extends CustomPackage
|
|||||||
// install xcaddy without using musl tools, xcaddy build requires dynamic linking
|
// install xcaddy without using musl tools, xcaddy build requires dynamic linking
|
||||||
shell()
|
shell()
|
||||||
->appendEnv([
|
->appendEnv([
|
||||||
'PATH' => "{$pkgroot}/{$name}/bin:" . $sanitizedPath,
|
'PATH' => "{$pkgroot}/go-xcaddy/bin:" . $sanitizedPath,
|
||||||
'GOROOT' => "{$pkgroot}/{$name}",
|
'GOROOT' => "{$pkgroot}/go-xcaddy",
|
||||||
'GOBIN' => "{$pkgroot}/{$name}/bin",
|
'GOBIN' => "{$pkgroot}/go-xcaddy/bin",
|
||||||
'GOPATH' => "{$pkgroot}/go",
|
'GOPATH' => "{$pkgroot}/go",
|
||||||
])
|
])
|
||||||
->exec('CC=cc go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest');
|
->exec('CC=cc go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest');
|
||||||
@@ -101,22 +90,17 @@ class GoXcaddy extends CustomPackage
|
|||||||
|
|
||||||
public static function getEnvironment(): array
|
public static function getEnvironment(): array
|
||||||
{
|
{
|
||||||
$arch = arch2gnu(php_uname('m'));
|
$packageName = 'go-xcaddy';
|
||||||
$os = match (PHP_OS_FAMILY) {
|
|
||||||
'Windows' => 'win',
|
|
||||||
'Darwin' => 'macos',
|
|
||||||
'BSD' => 'freebsd',
|
|
||||||
default => 'linux',
|
|
||||||
};
|
|
||||||
|
|
||||||
$packageName = "go-xcaddy-{$arch}-{$os}";
|
|
||||||
$pkgroot = PKG_ROOT_PATH;
|
$pkgroot = PKG_ROOT_PATH;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'PATH' => "{$pkgroot}/{$packageName}/bin",
|
|
||||||
'GOROOT' => "{$pkgroot}/{$packageName}",
|
'GOROOT' => "{$pkgroot}/{$packageName}",
|
||||||
'GOBIN' => "{$pkgroot}/{$packageName}/bin",
|
'GOBIN' => "{$pkgroot}/{$packageName}/bin",
|
||||||
'GOPATH' => "{$pkgroot}/go",
|
'GOPATH' => "{$pkgroot}/go",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getPath(): ?string
|
||||||
|
{
|
||||||
|
return PKG_ROOT_PATH . '/go-xcaddy/bin';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class Zig extends CustomPackage
|
|||||||
public function extract(string $name): void
|
public function extract(string $name): void
|
||||||
{
|
{
|
||||||
$pkgroot = PKG_ROOT_PATH;
|
$pkgroot = PKG_ROOT_PATH;
|
||||||
$zig_bin_dir = "{$pkgroot}/{$name}";
|
$zig_bin_dir = "{$pkgroot}/zig";
|
||||||
|
|
||||||
$files = ['zig', 'zig-cc', 'zig-c++', 'zig-ar', 'zig-ld.lld', 'zig-ranlib', 'zig-objcopy'];
|
$files = ['zig', 'zig-cc', 'zig-c++', 'zig-ar', 'zig-ld.lld', 'zig-ranlib', 'zig-objcopy'];
|
||||||
$all_exist = true;
|
$all_exist = true;
|
||||||
@@ -120,7 +120,7 @@ class Zig extends CustomPackage
|
|||||||
$lock = json_decode(FileSystem::readFile(LockFile::LOCK_FILE), true);
|
$lock = json_decode(FileSystem::readFile(LockFile::LOCK_FILE), true);
|
||||||
$source_type = $lock[$name]['source_type'];
|
$source_type = $lock[$name]['source_type'];
|
||||||
$filename = DOWNLOAD_PATH . '/' . ($lock[$name]['filename'] ?? $lock[$name]['dirname']);
|
$filename = DOWNLOAD_PATH . '/' . ($lock[$name]['filename'] ?? $lock[$name]['dirname']);
|
||||||
$extract = "{$pkgroot}/{$name}";
|
$extract = "{$pkgroot}/zig";
|
||||||
|
|
||||||
FileSystem::extractPackage($name, $source_type, $filename, $extract);
|
FileSystem::extractPackage($name, $source_type, $filename, $extract);
|
||||||
|
|
||||||
@@ -129,34 +129,12 @@ class Zig extends CustomPackage
|
|||||||
|
|
||||||
public static function getEnvironment(): array
|
public static function getEnvironment(): array
|
||||||
{
|
{
|
||||||
$arch = arch2gnu(php_uname('m'));
|
return [];
|
||||||
$os = match (PHP_OS_FAMILY) {
|
|
||||||
'Windows' => 'win',
|
|
||||||
'Darwin' => 'macos',
|
|
||||||
'BSD' => 'freebsd',
|
|
||||||
default => 'linux',
|
|
||||||
};
|
|
||||||
|
|
||||||
$packageName = "zig-{$arch}-{$os}";
|
|
||||||
$path = PKG_ROOT_PATH . "/{$packageName}";
|
|
||||||
|
|
||||||
return [
|
|
||||||
'PATH' => $path,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getPath(): string
|
public static function getPath(): ?string
|
||||||
{
|
{
|
||||||
$arch = arch2gnu(php_uname('m'));
|
return PKG_ROOT_PATH . '/zig';
|
||||||
$os = match (PHP_OS_FAMILY) {
|
|
||||||
'Windows' => 'win',
|
|
||||||
'Darwin' => 'macos',
|
|
||||||
'BSD' => 'freebsd',
|
|
||||||
default => 'linux',
|
|
||||||
};
|
|
||||||
|
|
||||||
$packageName = "zig-{$arch}-{$os}";
|
|
||||||
return PKG_ROOT_PATH . "/{$packageName}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createZigCcScript(string $bin_dir): void
|
private function createZigCcScript(string $bin_dir): void
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||||
BUILDROOT_ABS="$(realpath "$SCRIPT_DIR/../../buildroot/include" 2>/dev/null || true)"
|
BUILDROOT_ABS="$(realpath "$SCRIPT_DIR/../../../buildroot/include" 2>/dev/null || true)"
|
||||||
PARSED_ARGS=()
|
PARSED_ARGS=()
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ class ZigToolchain implements ToolchainInterface
|
|||||||
|
|
||||||
public function afterInit(): void
|
public function afterInit(): void
|
||||||
{
|
{
|
||||||
if (!is_dir(Zig::getEnvironment()['PATH'])) {
|
if (!Zig::isInstalled()) {
|
||||||
throw new EnvironmentException('You are building with zig, but zig is not installed, please install zig first. (You can use `doctor` command to install it)');
|
throw new EnvironmentException('You are building with zig, but zig is not installed, please install zig first. (You can use `doctor` command to install it)');
|
||||||
}
|
}
|
||||||
GlobalEnvManager::addPathIfNotExists(Zig::getEnvironment()['PATH']);
|
GlobalEnvManager::addPathIfNotExists(Zig::getPath());
|
||||||
f_passthru('ulimit -n 2048'); // zig opens extra file descriptors, so when a lot of extensions are built statically, 1024 is not enough
|
f_passthru('ulimit -n 2048'); // zig opens extra file descriptors, so when a lot of extensions are built statically, 1024 is not enough
|
||||||
$cflags = getenv('SPC_DEFAULT_C_FLAGS') ?: '';
|
$cflags = getenv('SPC_DEFAULT_C_FLAGS') ?: '';
|
||||||
$cxxflags = getenv('SPC_DEFAULT_CXX_FLAGS') ?: '';
|
$cxxflags = getenv('SPC_DEFAULT_CXX_FLAGS') ?: '';
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -4,20 +4,40 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
assert(function_exists('gettext'));
|
assert(function_exists('gettext'));
|
||||||
assert(function_exists('bindtextdomain'));
|
assert(function_exists('bindtextdomain'));
|
||||||
|
assert(function_exists('bind_textdomain_codeset'));
|
||||||
assert(function_exists('textdomain'));
|
assert(function_exists('textdomain'));
|
||||||
|
|
||||||
if (!is_dir('locale/en_US/LC_MESSAGES/')) {
|
foreach (['en_US', 'en_GB'] as $lc) {
|
||||||
mkdir('locale/en_US/LC_MESSAGES/', 0755, true);
|
$dir = "locale/{$lc}/LC_MESSAGES";
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
mkdir($dir, 0755, true);
|
||||||
}
|
}
|
||||||
if (!file_exists('locale/en_US/LC_MESSAGES/test.mo')) {
|
$mo = '3hIElQAAAAACAAAAHAAAACwAAAAFAAAAPAAAAAAAAABQAAAABgAAAFEAAAAXAQAAWAAAAAcAAABwAQAAAQAAAAAAAAAAAAAAAgAAAAAAAAAA56S65L6LAFByb2plY3QtSWQtVmVyc2lvbjogUEFDS0FHRSBWRVJTSU9OClJlcG9ydC1Nc2dpZC1CdWdzLVRvOiAKUE8tUmV2aXNpb24tRGF0ZTogWUVBUi1NTy1EQSBITzpNSytaT05FCkxhc3QtVHJhbnNsYXRvcjogRlVMTCBOQU1FIDxFTUFJTEBBRERSRVNTPgpMYW5ndWFnZS1UZWFtOiBMQU5HVUFHRSA8TExAbGkub3JnPgpMYW5ndWFnZTogCk1JTUUtVmVyc2lvbjogMS4wCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA4Yml0CgBFeGFtcGxlAA==';
|
||||||
$mo = '3hIElQAAAAACAAAAHAAAACwAAAAFAAAAPAAAAAAAAABQAAAABgAAAFEAAAAXAQAAWAAAAAcAAABwAQAAAQAAAAAAAAAAAAAAAgAAAAAAAAAA56S65L6LAFByb2plY3QtSWQtVmVyc2lvbjogUEFDS0FHRSBWRVJTSU9OClJlcG9ydC1Nc2dpZC1CdWdzLVRvOiAKUE8tUmV2aXNpb24tRGF0ZTogWUVBUi1NTy1EQSBITzpNSStaT05FCkxhc3QtVHJhbnNsYXRvcjogRlVMTCBOQU1FIDxFTUFJTEBBRERSRVNTPgpMYW5ndWFnZS1UZWFtOiBMQU5HVUFHRSA8TExAbGkub3JnPgpMYW5ndWFnZTogCk1JTUUtVmVyc2lvbjogMS4wCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA4Yml0CgBFeGFtcGxlAA==';
|
$path = "{$dir}/test.mo";
|
||||||
file_put_contents('locale/en_US/LC_MESSAGES/test.mo', base64_decode($mo));
|
if (!file_exists($path)) {
|
||||||
|
file_put_contents($path, base64_decode($mo));
|
||||||
}
|
}
|
||||||
putenv('LANG=en_US');
|
}
|
||||||
assert(setlocale(LC_ALL, 'en_US.utf-8') === 'en_US.utf-8');
|
|
||||||
|
// Probe for an available English locale
|
||||||
|
$candidates = [
|
||||||
|
'en_US.UTF-8', 'en_US.utf8', 'en_US.utf-8', 'en_US',
|
||||||
|
'en_GB.UTF-8', 'en_GB.utf8', 'en_GB.utf-8', 'en_GB',
|
||||||
|
'English_United States.65001', 'English_United States.1252',
|
||||||
|
'English_United Kingdom.65001', 'English_United Kingdom.1252',
|
||||||
|
];
|
||||||
|
|
||||||
|
$locale = setlocale(LC_ALL, $candidates);
|
||||||
|
assert($locale !== false);
|
||||||
|
|
||||||
|
putenv('LC_ALL=' . $locale);
|
||||||
|
putenv('LANG=' . $locale);
|
||||||
|
putenv('LANGUAGE=' . (stripos($locale, 'US') !== false ? 'en_US:en_GB' : 'en_GB:en_US'));
|
||||||
|
|
||||||
$domain = 'test';
|
$domain = 'test';
|
||||||
bindtextdomain($domain, 'locale/');
|
bindtextdomain($domain, 'locale/');
|
||||||
|
bind_textdomain_codeset($domain, 'UTF-8');
|
||||||
textdomain($domain);
|
textdomain($domain);
|
||||||
|
|
||||||
assert(gettext(json_decode('"\u793a\u4f8b"', true)) === 'Example');
|
$src = json_decode('"\u793a\u4f8b"', true);
|
||||||
|
assert(gettext($src) === 'Example');
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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