mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-03 14:55:39 +08:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d303348d9 | ||
|
|
2a2f4120b9 | ||
|
|
15f8887f14 | ||
|
|
fe945ab3ea | ||
|
|
e2b6f4cedd | ||
|
|
d82c86cf62 | ||
|
|
9df2867175 | ||
|
|
5c803d1553 | ||
|
|
d45b1853f8 | ||
|
|
1ac621fb9c | ||
|
|
4e74ac1937 | ||
|
|
959734ac31 | ||
|
|
166f3de52f | ||
|
|
e3adfff16f | ||
|
|
7cbc374278 | ||
|
|
129041402d | ||
|
|
9ac578dfd6 | ||
|
|
ef709a169b | ||
|
|
2eeba33f94 | ||
|
|
f4b2b9ae7d | ||
|
|
e44efb2a54 | ||
|
|
598f6d55c5 | ||
|
|
a2c5c7e6e6 | ||
|
|
4f6e646812 | ||
|
|
a79564f685 | ||
|
|
a77e49cbc9 | ||
|
|
cefb737fd2 | ||
|
|
8c8aba2dd5 | ||
|
|
97b18e9121 | ||
|
|
ddc9cc2237 | ||
|
|
aff803f334 |
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}"
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
"lib-suggests-unix": [
|
"lib-suggests-unix": [
|
||||||
"brotli",
|
"brotli",
|
||||||
"watcher"
|
"watcher"
|
||||||
|
],
|
||||||
|
"lib-depends-macos": [
|
||||||
|
"libxml2"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"micro": {
|
"micro": {
|
||||||
|
|||||||
@@ -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.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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -182,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
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -189,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
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ 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 +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');
|
||||||
@@ -209,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');
|
||||||
@@ -257,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');
|
||||||
@@ -268,11 +278,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') {
|
||||||
@@ -315,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');
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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