From dcb3d916103525ea2907c9cf5de4f582a9c72337 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 2 Jun 2023 21:39:32 +0800 Subject: [PATCH 001/296] update ext-support.md --- ext-support.md | 120 ++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/ext-support.md b/ext-support.md index 5889ff1e..659aa6dd 100644 --- a/ext-support.md +++ b/ext-support.md @@ -6,66 +6,66 @@ > - no with issue link: not supported yet due to issue > - partial with issue link: supported but not perfect due to issue -| | Linux | macOS | Windows | -|------------|---------------------------------------------------------------------|----------------------------------------------------------------|---------| -| apcu | yes, untested | yes, untested | | -| bcmath | yes | yes | | -| bz2 | yes | yes | | -| calendar | yes | yes | | -| ctype | yes | yes | | -| curl | yes | yes | | -| dba | yes | yes | | -| dom | yes | yes | | -| enchant | | | | -| event | yes | yes | | -| exif | yes | yes | | -| ffi | | yes, [docs]() | | -| filter | yes | yes | | -| fileinfo | yes | yes | | -| ftp | yes | yes | | -| gd | yes | yes | | -| gettext | | | | -| gmp | yes | yes | | -| iconv | yes | yes | | -| imagick | yes | yes | | -| inotify | yes | yes | | -| intl | | | | -| mbstring | yes | yes | | -| mbregex | yes | yes | | -| mcrypt | | [no](https://github.com/crazywhalecc/static-php-cli/issues/32) | | -| mongodb | yes | yes | | -| mysqli | yes | yes | | -| mysqlnd | yes | yes | | -| openssl | yes | yes | | -| password-argon2 | | | | -| pcntl | yes | yes | | -| pdo | yes | yes | | -| pdo_mysql | yes | yes | | -| pdo_sqlite | yes | yes | | -| pdo_pgsql | | | | -| phar | yes | yes | | -| posix | yes | yes | | -| protobuf | yes | yes | | -| readline | yes, untested | yes, untested | | -| redis | yes | yes | | -| session | yes | yes | | -| shmop | yes | yes | | -| simplexml | yes | yes | | -| soap | yes | yes | | -| sockets | yes | yes | | -| sodium | yes | yes | | -| sqlite3 | yes | yes | | -| ssh2 | yes, untested | yes, untested | | -| swow | yes | yes | | -| swoole | [partial](https://github.com/crazywhalecc/static-php-cli/issues/51) | yes | | -| tokenizer | yes | yes | | -| xlswriter | | | | -| xml | yes | yes | | -| xmlreader | yes, untested | yes, untested | | -| xmlwriter | yes, untested | yes, untested | | -| zip | yes, untested | yes, untested | | -| zlib | yes | yes | | -| zstd | yes | yes | | +| | Linux | macOS | Windows | +|-----------------|---------------------------------------------------------------------|----------------------------------------------------------------|---------| +| apcu | yes, untested | yes, untested | | +| bcmath | yes | yes | | +| bz2 | yes | yes | | +| calendar | yes | yes | | +| ctype | yes | yes | | +| curl | yes | yes | | +| dba | yes | yes | | +| dom | yes | yes | | +| enchant | | | | +| event | yes | yes | | +| exif | yes | yes | | +| ffi | | yes, [docs]() | | +| filter | yes | yes | | +| fileinfo | yes | yes | | +| ftp | yes | yes | | +| gd | yes | yes | | +| gettext | | | | +| gmp | yes | yes | | +| iconv | yes | yes | | +| imagick | yes | yes | | +| inotify | yes | yes | | +| intl | [partial](https://github.com/crazywhalecc/static-php-cli/issues/66) | yes | | +| mbstring | yes | yes | | +| mbregex | yes | yes | | +| mcrypt | | [no](https://github.com/crazywhalecc/static-php-cli/issues/32) | | +| mongodb | yes | yes | | +| mysqli | yes | yes | | +| mysqlnd | yes | yes | | +| openssl | yes | yes | | +| password-argon2 | | | | +| pcntl | yes | yes | | +| pdo | yes | yes | | +| pdo_mysql | yes | yes | | +| pdo_sqlite | yes | yes | | +| pdo_pgsql | | | | +| phar | yes | yes | | +| posix | yes | yes | | +| protobuf | yes | yes | | +| readline | yes, untested | yes, untested | | +| redis | yes | yes | | +| session | yes | yes | | +| shmop | yes | yes | | +| simplexml | yes | yes | | +| soap | yes | yes | | +| sockets | yes | yes | | +| sodium | yes | yes | | +| sqlite3 | yes | yes | | +| ssh2 | yes, untested | yes, untested | | +| swow | yes | yes | | +| swoole | [partial](https://github.com/crazywhalecc/static-php-cli/issues/51) | yes | | +| tokenizer | yes | yes | | +| xlswriter | yes | yes | | +| xml | yes | yes | | +| xmlreader | yes, untested | yes, untested | | +| xmlwriter | yes, untested | yes, untested | | +| zip | yes, untested | yes, untested | | +| zlib | yes | yes | | +| zstd | yes | yes | | ## Additional Requirements From aa9ec6e50e1b1199557c185b215efdaa85a796f8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 2 Jun 2023 21:40:17 +0800 Subject: [PATCH 002/296] add xlswriter support --- config/ext.json | 9 +++++++++ config/source.json | 10 ++++++++++ src/SPC/builder/extension/xlswriter.php | 17 +++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/SPC/builder/extension/xlswriter.php diff --git a/config/ext.json b/config/ext.json index 7a7b3b0f..c3e53780 100644 --- a/config/ext.json +++ b/config/ext.json @@ -367,6 +367,15 @@ "tokenizer": { "type": "builtin" }, + "xlswriter": { + "type": "external", + "source": "xlswriter", + "arg-type": "custom", + "ext-depends": [ + "zlib", + "zip" + ] + }, "xml": { "type": "builtin", "arg-type": "custom", diff --git a/config/source.json b/config/source.json index a5ede620..3f6fb14d 100644 --- a/config/source.json +++ b/config/source.json @@ -391,6 +391,16 @@ "path": "LICENSE" } }, + "xlswriter": { + "type": "url", + "url": "http://pecl.php.net/get/xlswriter", + "path": "php-src/ext/xlswriter", + "filename": "xlswriter.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "xz": { "type": "filelist", "url": "https://tukaani.org/xz/", diff --git a/src/SPC/builder/extension/xlswriter.php b/src/SPC/builder/extension/xlswriter.php new file mode 100644 index 00000000..37fbf970 --- /dev/null +++ b/src/SPC/builder/extension/xlswriter.php @@ -0,0 +1,17 @@ + Date: Fri, 2 Jun 2023 23:00:48 +0800 Subject: [PATCH 003/296] fix xml and intl depend order --- config/lib.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/lib.json b/config/lib.json index 18f71244..f7f2a86d 100644 --- a/config/lib.json +++ b/config/lib.json @@ -264,7 +264,8 @@ ], "lib-suggests": [ "xz", - "zlib" + "zlib", + "icu" ], "lib-suggests-windows": [ "icu", From 3db9c70e1b9f54fcef59734ed0d8ef44fa32c14b Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 2 Jun 2023 23:39:01 +0800 Subject: [PATCH 004/296] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d4f436ff..357dc8cc 100755 --- a/README.md +++ b/README.md @@ -71,9 +71,9 @@ If you are using English, see [English README](README-en.md). git clone https://github.com/crazywhalecc/static-php-cli.git ``` -如果你本机没有安装 PHP,你可以通过命令下载静态编译好的 php-cli 和 Composer。 +如果你本机没有安装 PHP,你需要先使用包管理(例如 brew、apt、yum、apk 等)安装 php。 -下载的 php 和 Composer 将保存为 `bin/php` 和 `bin/composer`。 +你也可以通过 `bin/setup-runtime` 命令下载静态编译好的 php-cli 和 Composer。下载的 php 和 Composer 将保存为 `bin/php` 和 `bin/composer`。 ```bash cd static-php-cli From 0e33380df5657a88e06960160bcb294b164ebf33 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 2 Jun 2023 23:40:49 +0800 Subject: [PATCH 005/296] Update README-en.md --- README-en.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README-en.md b/README-en.md index 6627e9d9..5ce5cf82 100755 --- a/README-en.md +++ b/README-en.md @@ -76,8 +76,9 @@ Clone repo first: git clone https://github.com/crazywhalecc/static-php-cli.git ``` -If you have not installed php on your system, you can download single-file php binary and composer first. +If you have not installed php on your system, you can use package management to install PHP (such as brew, apt, yum, apk etc.). +And you can also download single-file php binary and composer first. The PHP runtime for static-php-cli itself will be downloaded at `bin/php`, and composer is at `bin/composer`. ```bash From 74a34362c3c3bb9fe166fc1d6e618b03683bad1d Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 2 Jun 2023 23:42:23 +0800 Subject: [PATCH 006/296] Update README-en.md --- README-en.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README-en.md b/README-en.md index 5ce5cf82..78c17df6 100755 --- a/README-en.md +++ b/README-en.md @@ -78,12 +78,13 @@ git clone https://github.com/crazywhalecc/static-php-cli.git If you have not installed php on your system, you can use package management to install PHP (such as brew, apt, yum, apk etc.). -And you can also download single-file php binary and composer first. +And you can also download single-file php binary and composer using command `bin/setup-runtime`. The PHP runtime for static-php-cli itself will be downloaded at `bin/php`, and composer is at `bin/composer`. ```bash cd static-php-cli chmod +x bin/setup-runtime +# It will download php-cli from self-hosted server and composer from getcomposer.org ./bin/setup-runtime # Use this php runtime to run static-php-cli compiler From c49e6ba0a2a60ba86652b57cfabb64190cdba919 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 15 Jun 2023 22:22:07 +0800 Subject: [PATCH 007/296] fix libwebp version (imagemagick with webp-1.3.1-rc1 crashed) --- config/source.json | 4 ++-- src/SPC/ConsoleApplication.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/source.json b/config/source.json index 3f6fb14d..804d8a35 100644 --- a/config/source.json +++ b/config/source.json @@ -212,8 +212,8 @@ } }, "libwebp": { - "type": "ghtagtar", - "repo": "webmproject/libwebp", + "type": "url", + "url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.0.tar.gz", "license": { "type": "file", "path": "COPYING" diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 9253aa15..c4ecf50b 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -16,7 +16,7 @@ use Symfony\Component\Console\Command\ListCommand; */ class ConsoleApplication extends Application { - public const VERSION = '2.0-rc1'; + public const VERSION = '2.0-rc2'; /** * @throws \ReflectionException From fdf36ad7263e6d2779bb26c327eca0e83c519355 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 27 Jun 2023 00:59:10 +0800 Subject: [PATCH 008/296] fix mongodb library dependency --- config/ext.json | 7 +++---- src/SPC/builder/extension/mongodb.php | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/config/ext.json b/config/ext.json index c3e53780..e160d93a 100644 --- a/config/ext.json +++ b/config/ext.json @@ -166,12 +166,11 @@ "type": "external", "source": "mongodb", "arg-type": "custom", - "lib-depends": [ - "zstd" - ], "lib-suggests": [ "icu", - "openssl" + "openssl", + "zstd", + "zlib" ] }, "mysqli": { diff --git a/src/SPC/builder/extension/mongodb.php b/src/SPC/builder/extension/mongodb.php index a33b1b9e..2096de05 100644 --- a/src/SPC/builder/extension/mongodb.php +++ b/src/SPC/builder/extension/mongodb.php @@ -13,16 +13,15 @@ class mongodb extends Extension public function getUnixConfigureArg(): string { $arg = ' --enable-mongodb '; - $arg .= ' --with-mongodb-system-libs=no '; + $arg .= ' --with-mongodb-system-libs=no --with-mongodb-client-side-encryption=no '; $arg .= ' --with-mongodb-sasl=no '; if ($this->builder->getLib('openssl')) { $arg .= '--with-mongodb-ssl=openssl'; } - if ($this->builder->getLib('icu')) { - $arg .= ' --with-mongodb-icu=yes '; - } else { - $arg .= ' --with-mongodb-icu=no '; - } + $arg .= $this->builder->getLib('icu') ? ' --with-mongodb-icu=yes ' : ' --with-mongodb-icu=no '; + $arg .= $this->builder->getLib('zstd') ? ' --with-mongodb-zstd=yes ' : ' --with-mongodb-zstd=no '; + // $arg .= $this->builder->getLib('snappy') ? ' --with-mongodb-snappy=yes ' : ' --with-mongodb-snappy=no '; + $arg .= $this->builder->getLib('zlib') ? ' --with-mongodb-zlib=yes ' : ' --with-mongodb-zlib=bundled '; return $arg; } } From b8524715966a1be1b0dfea8a7cd80fd6a8a5f81e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 28 Jun 2023 18:38:14 +0800 Subject: [PATCH 009/296] add manual doctors --- src/SPC/doctor/AsCheckItem.php | 3 +- src/SPC/doctor/AsFixItem.php | 2 +- src/SPC/doctor/CheckListHandler.php | 53 ++++++++++++++++++----------- src/SPC/doctor/CheckResult.php | 12 +++---- src/SPC/doctor/item/OSCheckList.php | 4 +-- 5 files changed, 44 insertions(+), 30 deletions(-) diff --git a/src/SPC/doctor/AsCheckItem.php b/src/SPC/doctor/AsCheckItem.php index 6c20e38c..0417bcfa 100644 --- a/src/SPC/doctor/AsCheckItem.php +++ b/src/SPC/doctor/AsCheckItem.php @@ -12,7 +12,8 @@ class AsCheckItem public function __construct( public string $item_name, public ?string $limit_os = null, - public int $level = 100 + public int $level = 100, + public bool $manual = false, ) { } } diff --git a/src/SPC/doctor/AsFixItem.php b/src/SPC/doctor/AsFixItem.php index 92f5e35e..eb26d872 100644 --- a/src/SPC/doctor/AsFixItem.php +++ b/src/SPC/doctor/AsFixItem.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace SPC\doctor; -#[\Attribute(\Attribute::TARGET_METHOD)] +#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class AsFixItem { public function __construct(public string $name) diff --git a/src/SPC/doctor/CheckListHandler.php b/src/SPC/doctor/CheckListHandler.php index b2f53e45..f627e632 100644 --- a/src/SPC/doctor/CheckListHandler.php +++ b/src/SPC/doctor/CheckListHandler.php @@ -24,9 +24,20 @@ class CheckListHandler * @throws FileSystemException * @throws RuntimeException */ - public function __construct(private InputInterface $input, private OutputInterface $output) + public function __construct(private InputInterface $input, private OutputInterface $output, bool $include_manual = false) { - $this->loadCheckList(); + $this->loadCheckList($include_manual); + } + + public function runSingleCheck(string $item_name, int $fix_policy = FIX_POLICY_DIE): void + { + foreach ($this->check_list as $item) { + if ($item->item_name === $item_name) { + $this->check_list = [$item]; + break; + } + } + $this->runCheck($fix_policy); } /** @@ -44,7 +55,7 @@ class CheckListHandler $this->output->writeln('skipped'); } elseif ($result instanceof CheckResult) { if ($result->isOK()) { - $this->output->writeln('ok'); + $this->output->writeln($result->getMessage() ?? 'ok'); continue; } // Failed @@ -85,28 +96,30 @@ class CheckListHandler * @throws RuntimeException * @throws FileSystemException */ - private function loadCheckList(): void + private function loadCheckList(bool $include_manual = false): void { foreach (FileSystem::getClassesPsr4(__DIR__ . '/item', 'SPC\\doctor\\item') as $class) { $ref = new \ReflectionClass($class); foreach ($ref->getMethods() as $method) { - $attr = $method->getAttributes(AsCheckItem::class); - if (isset($attr[0])) { - /** @var AsCheckItem $instance */ - $instance = $attr[0]->newInstance(); - $instance->callback = [new $class(), $method->getName()]; - $this->check_list[] = $instance; - continue; - } - $attr = $method->getAttributes(AsFixItem::class); - if (isset($attr[0])) { - /** @var AsFixItem $instance */ - $instance = $attr[0]->newInstance(); - // Redundant fix item - if (isset($this->fix_map[$instance->name])) { - throw new RuntimeException('Redundant doctor fix item: ' . $instance->name); + $attr = $method->getAttributes(); + foreach ($attr as $a) { + if (is_a($a->getName(), AsCheckItem::class, true)) { + /** @var AsCheckItem $instance */ + $instance = $a->newInstance(); + if (!$include_manual && $instance->manual) { + continue; + } + $instance->callback = [new $class(), $method->getName()]; + $this->check_list[] = $instance; + } elseif (is_a($a->getName(), AsFixItem::class, true)) { + /** @var AsFixItem $instance */ + $instance = $a->newInstance(); + // Redundant fix item + if (isset($this->fix_map[$instance->name])) { + throw new RuntimeException('Redundant doctor fix item: ' . $instance->name); + } + $this->fix_map[$instance->name] = [new $class(), $method->getName()]; } - $this->fix_map[$instance->name] = [new $class(), $method->getName()]; } } } diff --git a/src/SPC/doctor/CheckResult.php b/src/SPC/doctor/CheckResult.php index fef036e4..4a1394d4 100644 --- a/src/SPC/doctor/CheckResult.php +++ b/src/SPC/doctor/CheckResult.php @@ -6,21 +6,21 @@ namespace SPC\doctor; class CheckResult { - public function __construct(private string $message = '', private string $fix_item = '', private array $fix_params = []) + public function __construct(private bool $ok, private ?string $message = null, private string $fix_item = '', private array $fix_params = []) { } public static function fail(string $message, string $fix_item = '', array $fix_params = []): CheckResult { - return new static($message, $fix_item, $fix_params); + return new static(false, $message, $fix_item, $fix_params); } - public static function ok(): CheckResult + public static function ok(?string $message = null): CheckResult { - return new static(); + return new static(true, $message); } - public function getMessage(): string + public function getMessage(): ?string { return $this->message; } @@ -37,7 +37,7 @@ class CheckResult public function isOK(): bool { - return empty($this->message); + return $this->ok; } public function setFixItem(string $fix_item = '', array $fix_params = []) diff --git a/src/SPC/doctor/item/OSCheckList.php b/src/SPC/doctor/item/OSCheckList.php index 1bab92cd..5d074793 100644 --- a/src/SPC/doctor/item/OSCheckList.php +++ b/src/SPC/doctor/item/OSCheckList.php @@ -12,12 +12,12 @@ class OSCheckList { use UnixSystemUtilTrait; - #[AsCheckItem('if current os are supported', level: 999)] + #[AsCheckItem('if current OS are supported', level: 999)] public function checkOS(): ?CheckResult { if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux'])) { return CheckResult::fail('Current OS is not supported'); } - return CheckResult::ok(); + return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . ', supported'); } } From d5aea9f7d66bf3f2c31185782724a4aa08c6c2ef Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Fri, 30 Jun 2023 14:57:10 +0800 Subject: [PATCH 010/296] =?UTF-8?q?=E7=A7=BB=E9=99=A4=20quick=20start?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quickstart/linux/README.md | 34 ------------ quickstart/linux/alpine-3.16-init.sh | 40 -------------- quickstart/linux/connection-static-php-cli.sh | 11 ---- quickstart/linux/debian-11-init.sh | 41 --------------- quickstart/linux/run-alpine-3.16-container.sh | 25 --------- quickstart/linux/run-debian-11-container.sh | 25 --------- quickstart/prepare.sh | 52 ------------------- 7 files changed, 228 deletions(-) delete mode 100644 quickstart/linux/README.md delete mode 100644 quickstart/linux/alpine-3.16-init.sh delete mode 100644 quickstart/linux/connection-static-php-cli.sh delete mode 100644 quickstart/linux/debian-11-init.sh delete mode 100644 quickstart/linux/run-alpine-3.16-container.sh delete mode 100644 quickstart/linux/run-debian-11-container.sh delete mode 100644 quickstart/prepare.sh diff --git a/quickstart/linux/README.md b/quickstart/linux/README.md deleted file mode 100644 index c6090a30..00000000 --- a/quickstart/linux/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# 快速启动容器环境 - -> 提供了 debian 11 构建 和 alpine 构建环境 -> 任意选一个就可以 - -## debian 11 构建环境 - -```bash - -# 启动 debian 11 容器环境 -sh quickstart/linux/run-debian-11-container.sh - -# 进入容器 -sh quickstart/linux/connection-static-php-cli.sh - -# 准备构建基础软件 -sh quickstart/linux/debian-11-init.sh - -``` - -## aline 构建环境 - -```bash - -# 启动 alpine 容器环境 -sh quickstart/linux/run-alpine-3.16-container.sh - -# 进入容器 -sh sh quickstart/linux/connection-static-php-cli.sh - -# 准备构建基础软件 -sh quickstart/linux/alpine-3.16-init.sh - -``` \ No newline at end of file diff --git a/quickstart/linux/alpine-3.16-init.sh b/quickstart/linux/alpine-3.16-init.sh deleted file mode 100644 index 8aed86b6..00000000 --- a/quickstart/linux/alpine-3.16-init.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -cd ${__DIR__} - - -# use china mirror -# bash quickstart/linux/x86_64/alpine-3.16-init.sh --mirror china -mirror='' -while [ $# -gt 0 ]; do - case "$1" in - --mirror) - mirror="$2" - shift - ;; - --*) - echo "Illegal option $1" - ;; - esac - shift $(( $# > 0 ? 1 : 0 )) -done - -case "$mirror" in - china) - test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save - sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories - ;; - -esac - - -apk update - -apk add vim alpine-sdk xz autoconf automake linux-headers clang-dev clang lld libtool cmake bison re2c gettext coreutils -apk add bash p7zip zip unzip flex pkgconf ca-certificates -apk add wget git curl \ No newline at end of file diff --git a/quickstart/linux/connection-static-php-cli.sh b/quickstart/linux/connection-static-php-cli.sh deleted file mode 100644 index daabc010..00000000 --- a/quickstart/linux/connection-static-php-cli.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) - -cd ${__DIR__} - -docker exec -it static-php-cli-dev-1 sh diff --git a/quickstart/linux/debian-11-init.sh b/quickstart/linux/debian-11-init.sh deleted file mode 100644 index dbd8478c..00000000 --- a/quickstart/linux/debian-11-init.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -cd ${__DIR__} - -# use china mirror -# bash quickstart/linux/x86_64/debian-11-init.sh --mirror china -mirror='' -while [ $# -gt 0 ]; do - case "$1" in - --mirror) - mirror="$2" - shift - ;; - --*) - echo "Illegal option $1" - ;; - esac - shift $(( $# > 0 ? 1 : 0 )) -done - -case "$mirror" in - china) - test -f /etc/apt/sources.list.save || cp /etc/apt/sources.list /etc/apt/sources.list.save - sed -i "s@deb.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list && \ - sed -i "s@security.debian.org@mirrors.ustc.edu.cn@g" /etc/apt/sources.list - ;; - -esac - - -apt update -y -apt install -y git curl wget ca-certificates -apt install -y xz-utils autoconf automake lld libtool cmake bison re2c gettext coreutils lzip zip unzip -apt install -y pkg-config bzip2 flex p7zip -apt install -y musl-tools g++ -apt install -y clang diff --git a/quickstart/linux/run-alpine-3.16-container.sh b/quickstart/linux/run-alpine-3.16-container.sh deleted file mode 100644 index fa3ea0e5..00000000 --- a/quickstart/linux/run-alpine-3.16-container.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../ - pwd -) -cd ${__DIR__} - - -{ - docker stop static-php-cli-dev-1 -} || { - echo $? -} -cd ${__DIR__} -IMAGE=alpine:3.16 - -cd ${__DIR__} -docker run --rm --name static-php-cli-dev-1 -d -v ${__PROJECT__}:/work -w /work $IMAGE tail -f /dev/null - diff --git a/quickstart/linux/run-debian-11-container.sh b/quickstart/linux/run-debian-11-container.sh deleted file mode 100644 index c00ae1a6..00000000 --- a/quickstart/linux/run-debian-11-container.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../ - pwd -) -cd ${__DIR__} - - -{ - docker stop static-php-cli-dev-1 -} || { - echo $? -} -cd ${__DIR__} -IMAGE=debian:11 - -cd ${__DIR__} -docker run --rm --name static-php-cli-dev-1 -d -v ${__PROJECT__}:/work -w /work $IMAGE tail -f /dev/null - diff --git a/quickstart/prepare.sh b/quickstart/prepare.sh deleted file mode 100644 index 9f4669d1..00000000 --- a/quickstart/prepare.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../ - pwd -) -cd ${__PROJECT__} - -OS=$(uname -s) -ARCH=$(uname -m) - -if [[ $OS = "Linux" && -f /etc/os-release ]]; then - OS_NAME=$(cat /etc/os-release | grep '^ID=' | awk -F '=' '{print $2}') - # debian ubuntu alpine -fi - -composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ - -chmod +x bin/spc - -./bin/spc fetch --all --debug - -./bin/spc list-ext - -EXTENSIONS="calendar,ctype,exif,fileinfo,filter,ftp" -EXTENSIONS="${EXTENSIONS},session,tokenizer" -EXTENSIONS="${EXTENSIONS},phar,posix" -EXTENSIONS="${EXTENSIONS},iconv" -EXTENSIONS="${EXTENSIONS},xml,dom,simplexml,xmlwriter,xmlreader" -EXTENSIONS="${EXTENSIONS},phar,posix" -EXTENSIONS="${EXTENSIONS},soap" -EXTENSIONS="${EXTENSIONS},mbstring,mbregex" -EXTENSIONS="${EXTENSIONS},openssl" -EXTENSIONS="${EXTENSIONS},sockets,gmp,bcmath" -EXTENSIONS="${EXTENSIONS},pcntl" -EXTENSIONS="${EXTENSIONS},curl" -EXTENSIONS="${EXTENSIONS},zlib,zip,bz2" -EXTENSIONS="${EXTENSIONS},gd" -EXTENSIONS="${EXTENSIONS},redis" -EXTENSIONS="${EXTENSIONS},pdo,pdo_mysql,pdo_sqlite" -EXTENSIONS="${EXTENSIONS},mysqlnd,sqlite3" -EXTENSIONS="${EXTENSIONS},mongodb" -# EXTENSIONS="${EXTENSIONS},swoole" -EXTENSIONS="${EXTENSIONS},swow" - -./bin/spc build "${EXTENSIONS}" --build-cli --cc=clang --cxx=clang++ --debug -# ./bin/spc build "${EXTENSIONS}" --build-cli --cc=gcc --cxx=g++ --debug From 9806422279e245830d9e9b43ad55c62c41bfe13b Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Fri, 30 Jun 2023 15:00:25 +0800 Subject: [PATCH 011/296] =?UTF-8?q?=E8=A7=A3=E5=86=B3pecl=20http=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=9C=B0=E5=9D=80=E8=A2=AB=E5=8A=AB=E6=8C=81=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/source.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/source.json b/config/source.json index 804d8a35..f5662d63 100644 --- a/config/source.json +++ b/config/source.json @@ -8,7 +8,7 @@ }, "apcu": { "type": "url", - "url": "http://pecl.php.net/get/APCu", + "url": "https://pecl.php.net/get/APCu", "path": "php-src/ext/apcu", "filename": "apcu.tgz", "license": { @@ -63,7 +63,7 @@ }, "ext-ssh2": { "type": "url", - "url": "http://pecl.php.net/get/ssh2", + "url": "https://pecl.php.net/get/ssh2", "path": "php-src/ext/ssh2", "filename": "ssh2.tgz", "license": { @@ -117,7 +117,7 @@ }, "inotify": { "type": "url", - "url": "http://pecl.php.net/get/inotify", + "url": "https://pecl.php.net/get/inotify", "path": "php-src/ext/inotify", "filename": "inotify.tgz", "license": { @@ -327,7 +327,7 @@ }, "protobuf": { "type": "url", - "url": "http://pecl.php.net/get/protobuf", + "url": "https://pecl.php.net/get/protobuf", "path": "php-src/ext/protobuf", "filename": "protobuf.tgz", "license": { @@ -393,7 +393,7 @@ }, "xlswriter": { "type": "url", - "url": "http://pecl.php.net/get/xlswriter", + "url": "https://pecl.php.net/get/xlswriter", "path": "php-src/ext/xlswriter", "filename": "xlswriter.tgz", "license": { From dac14ae16e38252e3d5b7eb6f63c6e53144376e1 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Fri, 30 Jun 2023 20:36:51 +0800 Subject: [PATCH 012/296] =?UTF-8?q?=E6=B7=BB=E5=8A=A0pgsql=20=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SPC/builder/linux/library/postgresql.php | 12 +++ src/SPC/builder/macos/library/postgresql.php | 12 +++ src/SPC/builder/unix/library/postgresql.php | 98 ++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 src/SPC/builder/linux/library/postgresql.php create mode 100644 src/SPC/builder/macos/library/postgresql.php create mode 100644 src/SPC/builder/unix/library/postgresql.php diff --git a/src/SPC/builder/linux/library/postgresql.php b/src/SPC/builder/linux/library/postgresql.php new file mode 100644 index 00000000..04fb76e7 --- /dev/null +++ b/src/SPC/builder/linux/library/postgresql.php @@ -0,0 +1,12 @@ +builder->configure_env; + $packages = 'openssl zlib icu-uc icu-io icu-i18n readline libxml-2.0 libzstd'; + + $output = shell()->execWithResult($envs . ' pkg-config --cflags-only-I --static ' . $packages); + if (!empty($output[1][0])) { + $cppflags = $output[1][0]; + $envs .= " CPPFLAGS=\"{$cppflags}\""; + } + $output = shell()->execWithResult($envs . ' pkg-config --libs-only-L --static ' . $packages); + if (!empty($output[1][0])) { + $ldflags = $output[1][0]; + $envs .= " LDFLAGS=\"{$ldflags}\" "; + } + $output = shell()->execWithResult($envs . ' pkg-config --libs-only-l --static ' . $packages); + if (!empty($output[1][0])) { + $libs = $output[1][0]; + $envs .= " LIBS=\"{$libs}\" "; + } + + FileSystem::resetDir($this->source_dir . '/build'); + + # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile + shell()->cd($this->source_dir . '/build')->exec( + <<<'EOF' + sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile +EOF + ); + + shell()->cd($this->source_dir . '/build') + ->exec( + <<cd($this->source_dir . '/build')->exec( + <<<'EOF' + make -C src/bin/pg_config install + make -C src/include install + + make -C src/common install + + make -C src/backend/port install + make -C src/port install + + make -C src/backend/libpq install + make -C src/interfaces/libpq install + +EOF + ); + + shell()->cd($this->source_dir . '/build')->exec( + << Date: Fri, 30 Jun 2023 20:53:18 +0800 Subject: [PATCH 013/296] =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0pgsql=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/ext.json | 11 +++++++++-- config/lib.json | 13 ++++++++++++- config/source.json | 3 ++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/config/ext.json b/config/ext.json index e160d93a..cc6b067d 100644 --- a/config/ext.json +++ b/config/ext.json @@ -211,12 +211,19 @@ }, "pdo_pgsql": { "type": "builtin", - "arg-type": "with", + "arg-type": "with-prefix", "ext-depends": [ "pdo" ], "lib-depends": [ - "pq" + "postgresql" + ] + }, + "pgsql": { + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "postgresql" ] }, "pdo_sqlite": { diff --git a/config/lib.json b/config/lib.json index f7f2a86d..1d572794 100644 --- a/config/lib.json +++ b/config/lib.json @@ -381,7 +381,18 @@ "postgresql": { "source": "postgresql", "static-libs-unix": [ - "libpg.a" + "libpq.a", + "libpgport.a", + "libpgcommon.a" + ], + "lib-depends": [ + "libiconv", + "libxml2", + "zstd", + "openssl", + "zlib", + "readline", + "icu" ] }, "pthreads4w": { diff --git a/config/source.json b/config/source.json index f5662d63..e28376db 100644 --- a/config/source.json +++ b/config/source.json @@ -319,7 +319,8 @@ } }, "postgresql": { - "type": "custom", + "type": "url", + "url": "https://ftp.postgresql.org/pub/source/v15.1/postgresql-15.1.tar.gz", "license": { "type": "file", "path": "COPYRIGHT" From 9c2ea79beceb6086168f476b339fb1b9071d5dd0 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Fri, 30 Jun 2023 21:00:49 +0800 Subject: [PATCH 014/296] update pgsql config --- src/SPC/builder/unix/library/postgresql.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 5fc19bef..3f48e7a9 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -18,20 +18,21 @@ trait postgresql { [$libdir, , $destdir] = SEPARATED_PATH; $builddir = BUILD_ROOT_PATH; - $envs = $this->builder->configure_env; + $env = $this->builder->configure_env; + $envs = $env; $packages = 'openssl zlib icu-uc icu-io icu-i18n readline libxml-2.0 libzstd'; - $output = shell()->execWithResult($envs . ' pkg-config --cflags-only-I --static ' . $packages); + $output = shell()->execWithResult($env . ' pkg-config --cflags-only-I --static ' . $packages); if (!empty($output[1][0])) { $cppflags = $output[1][0]; $envs .= " CPPFLAGS=\"{$cppflags}\""; } - $output = shell()->execWithResult($envs . ' pkg-config --libs-only-L --static ' . $packages); + $output = shell()->execWithResult($env . ' pkg-config --libs-only-L --static ' . $packages); if (!empty($output[1][0])) { $ldflags = $output[1][0]; $envs .= " LDFLAGS=\"{$ldflags}\" "; } - $output = shell()->execWithResult($envs . ' pkg-config --libs-only-l --static ' . $packages); + $output = shell()->execWithResult($env . ' pkg-config --libs-only-l --static ' . $packages); if (!empty($output[1][0])) { $libs = $output[1][0]; $envs .= " LIBS=\"{$libs}\" "; From 78c1484570a06e630cd544f9e4ed9319b3247692 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Sat, 1 Jul 2023 13:01:53 +0800 Subject: [PATCH 015/296] =?UTF-8?q?=E8=A7=A3=E5=86=B3debian=20=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8B=20pgsql=20=E6=9E=84=E5=BB=BA=E5=85=B1?= =?UTF-8?q?=E4=BA=AB=E5=BA=93=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SPC/builder/unix/library/postgresql.php | 47 +++++++++++++++------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 3f48e7a9..7efa2559 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -43,7 +43,18 @@ trait postgresql # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile shell()->cd($this->source_dir . '/build')->exec( <<<'EOF' - sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile + sed -i.backup "s/invokes exit'; exit 1;/invokes exit';/" ../src/interfaces/libpq/Makefile +EOF + ); + + shell()->cd($this->source_dir . '/build')->exec( + <<<'EOF' + sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib +EOF + ); + shell()->cd($this->source_dir . '/build')->exec( + <<<'EOF' + sed -i.backup "441 s/^/#$/" ../src/Makefile.shlib EOF ); @@ -71,22 +82,32 @@ EOF --without-tcl EOF ); + // 方便调试, + shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/bin/pg_config install'); + shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/include install'); + shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/common install'); + shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/backend/port install'); + shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/port install'); + shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/backend/libpq install'); + shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/interfaces/libpq install'); - shell()->cd($this->source_dir . '/build')->exec( - <<<'EOF' - make -C src/bin/pg_config install - make -C src/include install + /* + shell()->cd($this->source_dir . '/build')->exec( + <<<'EOF' + make -C src/bin/pg_config install + make -C src/include install - make -C src/common install + make -C src/common install - make -C src/backend/port install - make -C src/port install + make -C src/backend/port install + make -C src/port install - make -C src/backend/libpq install - make -C src/interfaces/libpq install - -EOF - ); + make -C src/backend/libpq install + make -C src/interfaces/libpq install + + EOF + ); + */ shell()->cd($this->source_dir . '/build')->exec( << Date: Sat, 1 Jul 2023 17:31:46 +0800 Subject: [PATCH 016/296] =?UTF-8?q?pgsql=20=20=E7=A6=81=E7=94=A8=20?= =?UTF-8?q?=E4=BE=9D=E8=B5=96libzstd=20icu=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/lib.json | 4 +--- src/SPC/builder/unix/library/postgresql.php | 24 +++------------------ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/config/lib.json b/config/lib.json index 1d572794..40422539 100644 --- a/config/lib.json +++ b/config/lib.json @@ -388,11 +388,9 @@ "lib-depends": [ "libiconv", "libxml2", - "zstd", "openssl", "zlib", - "readline", - "icu" + "readline" ] }, "pthreads4w": { diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 7efa2559..056797e8 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -20,7 +20,7 @@ trait postgresql $builddir = BUILD_ROOT_PATH; $env = $this->builder->configure_env; $envs = $env; - $packages = 'openssl zlib icu-uc icu-io icu-i18n readline libxml-2.0 libzstd'; + $packages = 'openssl zlib readline libxml-2.0 '; // icu-uc icu-io icu-i18n libzstd $output = shell()->execWithResult($env . ' pkg-config --cflags-only-I --static ' . $packages); if (!empty($output[1][0])) { @@ -30,7 +30,7 @@ trait postgresql $output = shell()->execWithResult($env . ' pkg-config --libs-only-L --static ' . $packages); if (!empty($output[1][0])) { $ldflags = $output[1][0]; - $envs .= " LDFLAGS=\"{$ldflags}\" "; + $envs .= " LDFLAGS=\"{$ldflags} -static\" "; } $output = shell()->execWithResult($env . ' pkg-config --libs-only-l --static ' . $packages); if (!empty($output[1][0])) { @@ -73,7 +73,7 @@ EOF --with-libxml \\ --without-libxslt \\ --without-lz4 \\ - --with-zstd \\ + --without-zstd \\ --without-perl \\ --without-python \\ --without-pam \\ @@ -91,24 +91,6 @@ EOF shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/backend/libpq install'); shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/interfaces/libpq install'); - /* - shell()->cd($this->source_dir . '/build')->exec( - <<<'EOF' - make -C src/bin/pg_config install - make -C src/include install - - make -C src/common install - - make -C src/backend/port install - make -C src/port install - - make -C src/backend/libpq install - make -C src/interfaces/libpq install - - EOF - ); - */ - shell()->cd($this->source_dir . '/build')->exec( << Date: Sat, 1 Jul 2023 18:04:42 +0800 Subject: [PATCH 017/296] =?UTF-8?q?pgsql=20=20=E7=A6=81=E7=94=A8=20?= =?UTF-8?q?=E4=BE=9D=E8=B5=96libzstd=20icu=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SPC/builder/unix/library/postgresql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 056797e8..e370a394 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -68,7 +68,7 @@ EOF --enable-coverage=no \\ --with-ssl=openssl \\ --with-readline \\ - --with-icu \\ + --without-icu \\ --without-ldap \\ --with-libxml \\ --without-libxslt \\ From cc5974d07d055d52a069fcebbdf1037a25c14356 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 16 Jul 2023 17:53:37 +0800 Subject: [PATCH 018/296] add download cache builder --- .github/workflows/download-cache.yml | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/download-cache.yml diff --git a/.github/workflows/download-cache.yml b/.github/workflows/download-cache.yml new file mode 100644 index 00000000..6f16de43 --- /dev/null +++ b/.github/workflows/download-cache.yml @@ -0,0 +1,40 @@ +name: archive download sources weekly + +on: + workflow_dispatch: + schedule: + - * 14 * * 5 + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + download: + name: cache download sources + runs-on: ubuntu-latest + strategy: + matrix: + php-version: [ "8.0", "8.1", "8.2" ] + steps: + - uses: actions/checkout@v3 + + # Cache composer dependencies + - id: cache-composer-deps + uses: actions/cache@v3 + with: + path: vendor + key: composer-dependencies + + # If there's no Composer cache, install dependencies + - if: steps.cache-composer-deps.outputs.cache-hit != 'true' + run: composer update --no-dev + + # If there's no dependencies cache, fetch sources, with or without debug + - if: steps.cache-download.outputs.cache-hit != 'true' + run: ./bin/spc download --with-php=${{ matrix.php-version }} --all --debug + + # Upload downloaded files + - uses: actions/upload-artifact@v3 + with: + name: download-files + path: downloads/ From a66e22d9edc20c0965e4463d2365e8475016ffa8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 16 Jul 2023 17:54:30 +0800 Subject: [PATCH 019/296] fix cron --- .github/workflows/download-cache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/download-cache.yml b/.github/workflows/download-cache.yml index 6f16de43..47607d92 100644 --- a/.github/workflows/download-cache.yml +++ b/.github/workflows/download-cache.yml @@ -3,7 +3,7 @@ name: archive download sources weekly on: workflow_dispatch: schedule: - - * 14 * * 5 + - cron: "* 14 * * 5" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From bc750733d55e3793a7d87a37103747cd610878f4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 16 Jul 2023 17:55:20 +0800 Subject: [PATCH 020/296] mark php version --- .github/workflows/download-cache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/download-cache.yml b/.github/workflows/download-cache.yml index 47607d92..86b4322e 100644 --- a/.github/workflows/download-cache.yml +++ b/.github/workflows/download-cache.yml @@ -36,5 +36,5 @@ jobs: # Upload downloaded files - uses: actions/upload-artifact@v3 with: - name: download-files + name: download-files-${{ matrix.php-version }} path: downloads/ From 7d31c371e099010a48c99276c126d58d09a00ec9 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 16 Jul 2023 17:59:21 +0800 Subject: [PATCH 021/296] change gmp to github mirror --- config/source.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/source.json b/config/source.json index f5662d63..f531538a 100644 --- a/config/source.json +++ b/config/source.json @@ -91,9 +91,8 @@ } }, "gmp": { - "type": "filelist", - "url": "https://gmplib.org/download/gmp/", - "regex": "/href=\"(?gmp-(?[^\"]+)\\.tar\\.xz)\"/", + "type": "ghtagtar", + "repo": "alisw/GMP", "license": { "type": "text", "text": "Since version 6, GMP is distributed under the dual licenses, GNU LGPL v3 and GNU GPL v2. These licenses make the library free to use, share, and improve, and allow you to pass on the result. The GNU licenses give freedoms, but also set firm restrictions on the use with non-free programs." From f2e483540b9dbd68f84965fd26c19fc46a29fa81 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 16 Jul 2023 18:13:11 +0800 Subject: [PATCH 022/296] add opcache support --- ext-support.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ext-support.md b/ext-support.md index 659aa6dd..d4f8ed20 100644 --- a/ext-support.md +++ b/ext-support.md @@ -36,6 +36,7 @@ | mongodb | yes | yes | | | mysqli | yes | yes | | | mysqlnd | yes | yes | | +| opcache | yes | yes | | | openssl | yes | yes | | | password-argon2 | | | | | pcntl | yes | yes | | From 388f54787809e540d460c8a0686648958b45dcc3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 17:59:44 +0800 Subject: [PATCH 023/296] add document --- README-en.md | 6 +++++- README.md | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README-en.md b/README-en.md index 78c17df6..c1539721 100755 --- a/README-en.md +++ b/README-en.md @@ -37,7 +37,11 @@ Here is the architecture support status, where `CI` represents support for GitHu Currently supported PHP versions for compilation are: `7.4`, `8.0`, `8.1`, `8.2`. -## Usage +## Docs + +docs here: . + +## Simple Usage Please first select the extension you want to compile based on the extension list below. diff --git a/README.md b/README.md index 357dc8cc..848e50dc 100755 --- a/README.md +++ b/README.md @@ -36,6 +36,10 @@ If you are using English, see [English README](README-en.md). 目前支持编译的 PHP 版本为:`7.4`,`8.0`,`8.1`,`8.2`。 +## 文档 + +点击这里查看文档:。 + ## 使用 请先根据下方扩展列表选择你要编译的扩展。 From 57e3193a2a2098111677cb88ee08a104ab4a8d9c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 18:01:45 +0800 Subject: [PATCH 024/296] add document --- README-en.md | 2 +- README.md | 2 +- ext-support.md | 111 +------------------------------------------------ 3 files changed, 3 insertions(+), 112 deletions(-) diff --git a/README-en.md b/README-en.md index c1539721..5546b0bf 100755 --- a/README-en.md +++ b/README-en.md @@ -53,7 +53,7 @@ If you don't compile yourself, you can download pre-compiled artifact from Actio ### Supported Extensions -[Supported Extension List](/ext-support.md) +[Supported Extension List](https://static-php-cli.zhamao.me/en/guide/extensions.html) > If there is no extension you need here, you can submit an issue. diff --git a/README.md b/README.md index 848e50dc..7b8af154 100755 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ If you are using English, see [English README](README-en.md). ### 支持的扩展情况 -[扩展支持列表](/ext-support.md) +[扩展支持列表](https://static-php-cli.zhamao.me/zh/guide/extensions.html) > 如果这里没有你需要的扩展,可以提交 Issue。 diff --git a/ext-support.md b/ext-support.md index d4f8ed20..19102e5a 100644 --- a/ext-support.md +++ b/ext-support.md @@ -1,112 +1,3 @@ # Extension List -> - yes: supported and tested -> - untested: supported, but not tested -> - empty: not supported yet -> - no with issue link: not supported yet due to issue -> - partial with issue link: supported but not perfect due to issue - -| | Linux | macOS | Windows | -|-----------------|---------------------------------------------------------------------|----------------------------------------------------------------|---------| -| apcu | yes, untested | yes, untested | | -| bcmath | yes | yes | | -| bz2 | yes | yes | | -| calendar | yes | yes | | -| ctype | yes | yes | | -| curl | yes | yes | | -| dba | yes | yes | | -| dom | yes | yes | | -| enchant | | | | -| event | yes | yes | | -| exif | yes | yes | | -| ffi | | yes, [docs]() | | -| filter | yes | yes | | -| fileinfo | yes | yes | | -| ftp | yes | yes | | -| gd | yes | yes | | -| gettext | | | | -| gmp | yes | yes | | -| iconv | yes | yes | | -| imagick | yes | yes | | -| inotify | yes | yes | | -| intl | [partial](https://github.com/crazywhalecc/static-php-cli/issues/66) | yes | | -| mbstring | yes | yes | | -| mbregex | yes | yes | | -| mcrypt | | [no](https://github.com/crazywhalecc/static-php-cli/issues/32) | | -| mongodb | yes | yes | | -| mysqli | yes | yes | | -| mysqlnd | yes | yes | | -| opcache | yes | yes | | -| openssl | yes | yes | | -| password-argon2 | | | | -| pcntl | yes | yes | | -| pdo | yes | yes | | -| pdo_mysql | yes | yes | | -| pdo_sqlite | yes | yes | | -| pdo_pgsql | | | | -| phar | yes | yes | | -| posix | yes | yes | | -| protobuf | yes | yes | | -| readline | yes, untested | yes, untested | | -| redis | yes | yes | | -| session | yes | yes | | -| shmop | yes | yes | | -| simplexml | yes | yes | | -| soap | yes | yes | | -| sockets | yes | yes | | -| sodium | yes | yes | | -| sqlite3 | yes | yes | | -| ssh2 | yes, untested | yes, untested | | -| swow | yes | yes | | -| swoole | [partial](https://github.com/crazywhalecc/static-php-cli/issues/51) | yes | | -| tokenizer | yes | yes | | -| xlswriter | yes | yes | | -| xml | yes | yes | | -| xmlreader | yes, untested | yes, untested | | -| xmlwriter | yes, untested | yes, untested | | -| zip | yes, untested | yes, untested | | -| zlib | yes | yes | | -| zstd | yes | yes | | - -## Additional Requirements - -- phpmicro requires PHP >= 8.0 -- swoole >= 5.0 requires PHP >= 8.0 -- swow requires PHP >= 8.0 - -## Typical Extension List Example - -Here are some extension list example for different use. - -- For general use: `"bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,ftp,filter,gd,iconv,xml,mbstring,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip"` -- For static-php-cli self: `"posix,pcntl,phar,tokenizer,iconv,zlib"` -- For static-php-cli self (with dev dependencies): `"posix,pcntl,phar,tokenizer,iconv,zlib,xml,dom,xmlwriter,xmlreader,fileinfo"` -- Minimum, with no extension: `""` - -Compile with all supported extensions (exclude `swow`, `swoole`, because these will change the default behavior of php): - -```bash -bin/spc build --build-all bcmath,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,mbregex,mbstring,mongodb,mysqli,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,protobuf,redis,session,shmop,simplexml,soap,sockets,sqlite3,tokenizer,xml,xmlreader,xmlwriter,yaml,zip,zlib,zstd --with-libs=libjpeg,freetype,libwebp,libavif --debug -``` - -## Additional Libraries - -Some extensions have soft dependencies, you can enable extra features by adding these libs using `--with-libs`. - -For example, to compile with gd extension, with `libwebp, libgif, libavif, libjpeg, freetype` extra features: - -```bash -bin/spc build gd --with-libs=libjpeg,freetype,libwebp,libavif --build-cli -``` - -> If you don't add them, your compilation will not enable these features. - -## Limitations - -- swow and swoole cannot be compiled at the same time. -- openssl needs manual configuration for ssl certificate. (TODO: I will write a wiki about it) -- some extensions need system configuration, e.g. `curl` and `openssl` will search ssl certificate on your system. - -## Bugs and TODOs - -See [#32](https://github.com/crazywhalecc/static-php-cli/issues/32). +See: [Docs - Extensions](https://static-php-cli.zhamao.me/en/guide/extensions.html) From fc7ac921e2ef46d56ae640e3fa85ce44656e4c3e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 18:39:34 +0800 Subject: [PATCH 025/296] add document contributing guide --- README-en.md | 2 ++ README.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README-en.md b/README-en.md index 5546b0bf..f01dc761 100755 --- a/README-en.md +++ b/README-en.md @@ -221,6 +221,8 @@ The basic principles for contributing are as follows: camelCase and underscore formats should be followed, and mixing within the same module is prohibited. - When compiling external libraries and creating patches, compatibility with different operating systems should be considered. +If you want to contribute document content, please go to [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs). + ## Sponsor this project You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). diff --git a/README.md b/README.md index 7b8af154..e3766483 100755 --- a/README.md +++ b/README.md @@ -204,6 +204,8 @@ cat micro.sfx code.php > single-app && chmod +x single-app 另外,添加新扩展的贡献方式,可以参考下方 `进阶`。 +如果你想贡献文档内容,请到项目仓库 [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs) 贡献。 + ## 赞助本项目 你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。 From 63287dd9c4e2b565dc905c6ae0f80d0a7688260d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 20:26:48 +0800 Subject: [PATCH 026/296] add linux tool check --- src/SPC/doctor/item/LinuxToolCheckList.php | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/SPC/doctor/item/LinuxToolCheckList.php diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php new file mode 100644 index 00000000..6d69bd6e --- /dev/null +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -0,0 +1,72 @@ + [ + 'make', 'bison', 'flex', + 'git', 'autoconf', 'automake', + 'tar', 'unzip', 'gzip', + 'bzip2', 'cmake', + ], + 'alpine' => [ + 'make', 'bison', 'flex', + 'git', 'autoconf', 'automake', + 'tar', 'unzip', 'gzip', + 'bzip2', 'cmake', 'gcc', + ] + }; + $missing = []; + foreach ($required as $cmd) { + if ($this->findCommand($cmd) === null) { + $missing[] = $cmd; + } + } + if (!empty($missing)) { + return match ($distro['dist']) { + 'ubuntu', 'alpine', 'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]), + default => CheckResult::fail(implode(', ', $missing) . ' not installed on your system'), + }; + } + return CheckResult::ok(); + } + + #[AsFixItem('install-linux-tools')] + public function fixBuildTools(array $distro, array $missing): bool + { + $install_cmd = match ($distro['dist']) { + 'ubuntu', 'debian' => 'apt install -y', + 'alpine' => 'apk add', + default => throw new RuntimeException('Current linux distro is not supported for auto-install musl packages'), + }; + $prefix = ''; + if (get_current_user() !== 'root') { + $prefix = 'sudo '; + logger()->warning('Current user is not root, using sudo for running command'); + } + try { + shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', $missing)); + } catch (RuntimeException) { + return false; + } + return true; + } +} From 8b48cf7f70cda84ddcdee18cde4707914f03f32a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 20:28:08 +0800 Subject: [PATCH 027/296] add linux tool check --- src/SPC/doctor/item/LinuxToolCheckList.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 6d69bd6e..d5db242e 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -21,18 +21,18 @@ class LinuxToolCheckList $distro = SystemUtil::getOSRelease(); $required = match ($distro['dist']) { - 'ubuntu', 'debian' => [ - 'make', 'bison', 'flex', - 'git', 'autoconf', 'automake', - 'tar', 'unzip', 'gzip', - 'bzip2', 'cmake', - ], 'alpine' => [ 'make', 'bison', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'gcc', - ] + ], + default => [ + 'make', 'bison', 'flex', + 'git', 'autoconf', 'automake', + 'tar', 'unzip', 'gzip', + 'bzip2', 'cmake', + ], }; $missing = []; foreach ($required as $cmd) { From 67b073776cbb1e0067af4622032aefc1cf894e72 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 20:29:02 +0800 Subject: [PATCH 028/296] add linux tool check --- src/SPC/builder/linux/LinuxBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 8aee51ce..486d5afb 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -21,7 +21,7 @@ class LinuxBuilder extends BuilderBase use UnixBuilderTrait; /** @var string[] Linux 环境下编译依赖的命令 */ - public const REQUIRED_COMMANDS = ['make', 'bison', 'flex', 'pkg-config', 'git', 'autoconf', 'automake', 'tar', 'unzip', /* 'xz', 好像不需要 */ 'gzip', 'bzip2', 'cmake']; + public const REQUIRED_COMMANDS = ['make', 'bison', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', /* 'xz', 好像不需要 */ 'gzip', 'bzip2', 'cmake']; /** @var string 使用的 libc */ public string $libc; From 0afc8ea2c3dff40f7574170e3b890728f5028a2c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 20:31:42 +0800 Subject: [PATCH 029/296] add linux tool check --- src/SPC/doctor/item/LinuxToolCheckList.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index d5db242e..3f4d1bfb 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -26,6 +26,7 @@ class LinuxToolCheckList 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'gcc', + 'g++', ], default => [ 'make', 'bison', 'flex', From 7408781d13d3dde6e0378ff56cb29b46a43b753c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 20:58:48 +0800 Subject: [PATCH 030/296] add linux-header installer for alpine --- src/SPC/doctor/item/LinuxToolCheckList.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 3f4d1bfb..e0268807 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -50,6 +50,19 @@ class LinuxToolCheckList return CheckResult::ok(); } + #[AsCheckItem('if necessary packages are installed', limit_os: 'Linux')] + public function checkSystemOSPackages(): ?CheckResult + { + $distro = SystemUtil::getOSRelease(); + if ($distro['dist'] === 'alpine') { + // check linux-headers installation + if (!file_exists('/usr/include/linux/mman.h')) { + return CheckResult::fail('linux-headers not installed on your system', 'install-linux-tools', ['alpine', ['linux-headers']]); + } + } + return CheckResult::ok(); + } + #[AsFixItem('install-linux-tools')] public function fixBuildTools(array $distro, array $missing): bool { From 5cf105c3a50b1238698630dfc6c10a44c314ccd7 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 20:59:59 +0800 Subject: [PATCH 031/296] fix distro --- src/SPC/doctor/item/LinuxToolCheckList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index e0268807..bfd143d6 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -57,7 +57,7 @@ class LinuxToolCheckList if ($distro['dist'] === 'alpine') { // check linux-headers installation if (!file_exists('/usr/include/linux/mman.h')) { - return CheckResult::fail('linux-headers not installed on your system', 'install-linux-tools', ['alpine', ['linux-headers']]); + return CheckResult::fail('linux-headers not installed on your system', 'install-linux-tools', [$distro, ['linux-headers']]); } } return CheckResult::ok(); From a3b09c69ccf216ccc5d91269ae68acd2a35e032f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 21:05:39 +0800 Subject: [PATCH 032/296] correct alpine build commands --- src/SPC/doctor/item/LinuxToolCheckList.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index bfd143d6..b8b92ff0 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -26,13 +26,13 @@ class LinuxToolCheckList 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'gcc', - 'g++', + 'g++', 'patch', ], default => [ 'make', 'bison', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', - 'bzip2', 'cmake', + 'bzip2', 'cmake', 'patch', ], }; $missing = []; From 08efc81cf075fac957e55b47b793dc249ba3acc4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 21:10:49 +0800 Subject: [PATCH 033/296] add --auto-fix option --- src/SPC/command/DoctorCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SPC/command/DoctorCommand.php b/src/SPC/command/DoctorCommand.php index bf914f32..1db5e180 100644 --- a/src/SPC/command/DoctorCommand.php +++ b/src/SPC/command/DoctorCommand.php @@ -10,11 +10,16 @@ use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand('doctor', 'Diagnose whether the current environment can compile normally')] class DoctorCommand extends BaseCommand { + public function configure() + { + $this->addOption('auto-fix', null, null, 'Automatically fix failed items (if possible)'); + } + public function handle(): int { try { $checker = new CheckListHandler($this->input, $this->output); - $checker->runCheck(FIX_POLICY_PROMPT); + $checker->runCheck($this->input->getOption('auto-fix') ? FIX_POLICY_AUTOFIX : FIX_POLICY_PROMPT); $this->output->writeln('Doctor check complete !'); } catch (\Throwable $e) { $this->output->writeln('' . $e->getMessage() . ''); From 1912ae36e62bc384e3ec4e4367dcb53984c559d5 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 21:11:06 +0800 Subject: [PATCH 034/296] separate system tools list --- src/SPC/doctor/item/LinuxToolCheckList.php | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index b8b92ff0..f563e79f 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -15,25 +15,29 @@ class LinuxToolCheckList { use UnixSystemUtilTrait; + public const TOOLS_ALPINE = [ + 'make', 'bison', 'flex', + 'git', 'autoconf', 'automake', + 'tar', 'unzip', 'gzip', + 'bzip2', 'cmake', 'gcc', + 'g++', 'patch', + ]; + + public const TOOLS_DEBIAN = [ + 'make', 'bison', 'flex', + 'git', 'autoconf', 'automake', + 'tar', 'unzip', 'gzip', + 'bzip2', 'cmake', 'patch', + ]; + #[AsCheckItem('if necessary tools are installed', limit_os: 'Linux')] public function checkCliTools(): ?CheckResult { $distro = SystemUtil::getOSRelease(); $required = match ($distro['dist']) { - 'alpine' => [ - 'make', 'bison', 'flex', - 'git', 'autoconf', 'automake', - 'tar', 'unzip', 'gzip', - 'bzip2', 'cmake', 'gcc', - 'g++', 'patch', - ], - default => [ - 'make', 'bison', 'flex', - 'git', 'autoconf', 'automake', - 'tar', 'unzip', 'gzip', - 'bzip2', 'cmake', 'patch', - ], + 'alpine' => self::TOOLS_ALPINE, + default => self::TOOLS_DEBIAN, }; $missing = []; foreach ($required as $cmd) { From 41f49c20ff4d0093c8f08f412e4ae44f6d3fc458 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 21:36:50 +0800 Subject: [PATCH 035/296] add --from-zip command to download locally --- src/SPC/command/DownloadCommand.php | 42 ++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 640030f9..b0aa770d 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -4,11 +4,13 @@ declare(strict_types=1); namespace SPC\command; +use SPC\builder\traits\UnixSystemUtilTrait; use SPC\exception\DownloaderException; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\Config; use SPC\store\Downloader; +use SPC\store\FileSystem; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -18,6 +20,8 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand('download', 'Download required sources', ['fetch'])] class DownloadCommand extends BaseCommand { + use UnixSystemUtilTrait; + protected string $php_major_ver; public function configure() @@ -28,12 +32,13 @@ class DownloadCommand extends BaseCommand $this->addOption('with-php', null, InputOption::VALUE_REQUIRED, 'version in major.minor format like 8.1', '8.1'); $this->addOption('clean', null, null, 'Clean old download cache and source before fetch'); $this->addOption('all', 'A', null, 'Fetch all sources that static-php-cli needed'); + $this->addOption('from-zip', 'Z', InputOption::VALUE_REQUIRED, 'Fetch from zip archive'); } public function initialize(InputInterface $input, OutputInterface $output) { // --all 等于 "" "",也就是所有东西都要下载 - if ($input->getOption('all') || $input->getOption('clean')) { + if ($input->getOption('all') || $input->getOption('clean') || $input->getOption('from-zip')) { $input->setArgument('sources', ''); } parent::initialize($input, $output); @@ -66,6 +71,41 @@ class DownloadCommand extends BaseCommand return 0; } + // --from-zip + if ($path = $this->getOption('from-zip')) { + if (!file_exists($path)) { + logger()->critical('File ' . $path . ' not exist or not a zip archive.'); + return 1; + } + // remove old download files first + if (is_dir(DOWNLOAD_PATH)) { + logger()->warning('You are doing some operations that not recoverable: removing directories below'); + logger()->warning(DOWNLOAD_PATH); + logger()->alert('I will remove these dir after 5 seconds !'); + sleep(5); + f_passthru((PHP_OS_FAMILY === 'Windows' ? 'rmdir /s /q ' : 'rm -rf ') . DOWNLOAD_PATH); + } + // unzip command check + if (PHP_OS_FAMILY !== 'Windows' && !$this->findCommand('unzip')) { + logger()->critical('Missing unzip command, you need to install it first !'); + logger()->critical('You can use "bin/spc doctor" command to check and install required tools'); + return 1; + } + // create downloads + FileSystem::createDir(DOWNLOAD_PATH); + try { + f_passthru('cd ' . DOWNLOAD_PATH . ' && unzip ' . escapeshellarg($path)); + if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { + throw new RuntimeException('.lock.json not exist in "downloads/"'); + } + } catch (RuntimeException $e) { + logger()->critical('Extract failed: ' . $e->getMessage()); + return 1; + } + logger()->info('Extract success'); + return 0; + } + // Define PHP major version $ver = $this->php_major_ver = $this->getOption('with-php') ?? '8.1'; define('SPC_BUILD_PHP_VERSION', $ver); From 8505feaa66dbb489cf1853f7ecaa034b47c9bb18 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 21:41:26 +0800 Subject: [PATCH 036/296] fix createDir not working --- src/SPC/command/DownloadCommand.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index b0aa770d..f25fefcc 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -10,7 +10,6 @@ use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\Config; use SPC\store\Downloader; -use SPC\store\FileSystem; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -92,9 +91,12 @@ class DownloadCommand extends BaseCommand return 1; } // create downloads - FileSystem::createDir(DOWNLOAD_PATH); try { - f_passthru('cd ' . DOWNLOAD_PATH . ' && unzip ' . escapeshellarg($path)); + if (PHP_OS_FAMILY !== 'Windows') { + f_passthru('mkdir ' . DOWNLOAD_PATH . ' && cd ' . DOWNLOAD_PATH . ' && unzip ' . escapeshellarg($path)); + } + // Windows TODO + if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { throw new RuntimeException('.lock.json not exist in "downloads/"'); } From b84c68fe11cc1f3940f61480756933ac2a02c4f2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 17 Jul 2023 21:44:17 +0800 Subject: [PATCH 037/296] add doctor linux support --- README-en.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-en.md b/README-en.md index f01dc761..b9ffac03 100755 --- a/README-en.md +++ b/README-en.md @@ -104,7 +104,7 @@ Basic usage for building php and micro with some extensions: cd static-php-cli composer update chmod +x bin/spc -# Check system tool dependencies, fix them automatically (only support macOS) (TODO: Linux distro support) +# Check system tool dependencies, fix them automatically ./bin/spc doctor # fetch all libraries ./bin/spc fetch --all diff --git a/README.md b/README.md index e3766483..a26c91fb 100755 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ chmod +x bin/setup-runtime cd static-php-cli composer update chmod +x bin/spc -# 检查环境依赖,并根据提示的命令安装缺失的编译工具(目前仅支持 macOS,Linux 后续会支持) +# 检查环境依赖,并根据提示的命令安装缺失的编译工具 ./bin/spc doctor # 拉取所有依赖库 ./bin/spc fetch --all From e522258693b741c6a587ddc6daa2d37679bfec0e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 20 Jul 2023 01:15:05 +0800 Subject: [PATCH 038/296] fix libpng mac source bug --- src/SPC/builder/macos/library/libpng.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/macos/library/libpng.php b/src/SPC/builder/macos/library/libpng.php index 76a0645e..7b05dcd9 100644 --- a/src/SPC/builder/macos/library/libpng.php +++ b/src/SPC/builder/macos/library/libpng.php @@ -40,6 +40,7 @@ class libpng extends MacOSLibraryBase }; shell()->cd($this->source_dir) ->exec('chmod +x ./configure') + ->exec('chmod +x ./install-sh') ->exec( "{$this->builder->configure_env} ./configure " . "--host={$this->builder->gnu_arch}-apple-darwin " . From 97eff64b5bd4372c5ab17378f3ad9a8fe6e3c763 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 20 Jul 2023 01:15:28 +0800 Subject: [PATCH 039/296] add micro:combine command --- src/SPC/command/MicroCombineCommand.php | 116 ++++++++++++++++++++++++ src/SPC/store/FileSystem.php | 14 +++ 2 files changed, 130 insertions(+) create mode 100644 src/SPC/command/MicroCombineCommand.php diff --git a/src/SPC/command/MicroCombineCommand.php b/src/SPC/command/MicroCombineCommand.php new file mode 100644 index 00000000..2da6df49 --- /dev/null +++ b/src/SPC/command/MicroCombineCommand.php @@ -0,0 +1,116 @@ +addArgument('file', InputArgument::REQUIRED, 'The php or phar file to be combined'); + $this->addOption('with-micro', 'M', InputOption::VALUE_REQUIRED, 'Customize your micro.sfx file'); + $this->addOption('with-ini-set', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'ini to inject into micro.sfx when combining'); + $this->addOption('with-ini-file', 'N', InputOption::VALUE_REQUIRED, 'ini file to inject into micro.sfx when combining'); + $this->addOption('output', 'O', InputOption::VALUE_REQUIRED, 'Customize your output binary file name'); + } + + public function handle(): int + { + // 0. Initialize path variables + $internal = FileSystem::convertPath(BUILD_ROOT_PATH . '/bin/micro.sfx'); + $micro_file = $this->input->getOption('with-micro'); + $file = $this->getArgument('file'); + $ini_set = $this->input->getOption('with-ini-set'); + $ini_file = $this->input->getOption('with-ini-file'); + $target_ini = []; + $output = $this->input->getOption('output') ?? 'my-app'; + $ini_part = ''; + // 1. Make sure specified micro.sfx file exists + if ($micro_file !== null && !file_exists($micro_file)) { + $this->output->writeln('The micro.sfx file you specified is incorrect or does not exist!'); + return 1; + } + // 2. Make sure buildroot/bin/micro.sfx exists + if ($micro_file === null && !file_exists($internal)) { + $this->output->writeln('You haven\'t compiled micro.sfx yet, please use "build" command and "--build-micro" to compile phpmicro first!'); + return 1; + } + // 3. Use buildroot/bin/micro.sfx + if ($micro_file === null) { + $micro_file = $internal; + } + // 4. Make sure php or phar file exists + if (!is_file(FileSystem::convertPath($file))) { + $this->output->writeln('The file to combine does not exist!'); + return 1; + } + // 5. Confirm ini files (ini-set has higher priority) + if ($ini_file !== null) { + // Check file exist first + if (!file_exists($ini_file)) { + $this->output->writeln('The ini file to combine does not exist! (' . $ini_file . ')'); + return 1; + } + $arr = parse_ini_file($ini_file); + if ($arr === false) { + $this->output->writeln('Cannot parse ini file'); + return 1; + } + $target_ini = array_merge($target_ini, $arr); + } + // 6. Confirm ini sets + if ($ini_set !== []) { + foreach ($ini_set as $item) { + $arr = parse_ini_string($item); + if ($arr === false) { + $this->output->writeln('--with-ini-set parse failed'); + return 1; + } + $target_ini = array_merge($target_ini, $arr); + } + } + // 7. Generate ini injection parts + if (!empty($target_ini)) { + $ini_str = $this->encodeINI($target_ini); + logger()->debug('Injecting ini parts: ' . PHP_EOL . $ini_str); + $ini_part = "\xfd\xf6\x69\xe6"; + $ini_part .= pack('N', strlen($ini_str)); + $ini_part .= $ini_str; + } + // 8. Combine ! + $output = FileSystem::isRelativePath($output) ? (WORKING_DIR . '/' . $output) : $output; + $file_target = file_get_contents($micro_file) . $ini_part . file_get_contents($file); + $result = file_put_contents($output, $file_target); + if ($result === false) { + $this->output->writeln('Combine failed.'); + return 1; + } + // 9. chmod +x + chmod($output, 0755); + $this->output->writeln('Combine success! Binary file: ' . $output . ''); + return 0; + } + + private function encodeINI(array $array): string + { + $res = []; + foreach ($array as $key => $val) { + if (is_array($val)) { + $res[] = "[{$key}]"; + foreach ($val as $skey => $sval) { + $res[] = "{$skey}=" . (is_numeric($sval) ? $sval : '"' . $sval . '"'); + } + } else { + $res[] = "{$key}=" . (is_numeric($val) ? $val : '"' . $val . '"'); + } + } + return implode("\n", $res); + } +} diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 6c4b515a..b8439dbe 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -439,6 +439,20 @@ class FileSystem self::$_extract_hook[$name][] = $callback; } + /** + * Check whether the path is a relative path (judging according to whether the first character is "/") + * + * @param string $path Path + */ + public static function isRelativePath(string $path): bool + { + // 适配 Windows 的多盘符目录形式 + if (DIRECTORY_SEPARATOR === '\\') { + return !(strlen($path) > 2 && ctype_alpha($path[0]) && $path[1] === ':'); + } + return strlen($path) > 0 && $path[0] !== '/'; + } + private static function emitSourceExtractHook(string $name) { foreach ((self::$_extract_hook[$name] ?? []) as $hook) { From c14421c9ca69506f7d1b68b2afbf41d2371f716b Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 20 Jul 2023 11:40:57 +0800 Subject: [PATCH 040/296] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a26c91fb..fbb6906d 100755 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ If you are using English, see [English README](README-en.md). 截屏2023-05-02 15 52 33 -[![Version](https://img.shields.io/badge/Version-2.0--rc1-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc2-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) From 7056280c570f8cf62ad6d5ca7c31d035ed17b488 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 20 Jul 2023 11:41:15 +0800 Subject: [PATCH 041/296] Update README-en.md --- README-en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-en.md b/README-en.md index b9ffac03..f676e7c0 100755 --- a/README-en.md +++ b/README-en.md @@ -11,7 +11,7 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro 截屏2023-05-02 15 52 33 -[![Version](https://img.shields.io/badge/Version-2.0--rc1-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc2-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) From 99cb8c77b763e65bad2568b7ca05762c13cd6e53 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 21 Jul 2023 09:47:39 +0800 Subject: [PATCH 042/296] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index fbb6906d..768ffec4 100755 --- a/README.md +++ b/README.md @@ -222,6 +222,4 @@ cat micro.sfx code.php > single-app && chmod +x single-app ## 进阶 -本项目重构分支为模块化编写。 - -TODO:这部分将在基础功能完成后编写完成。 +本项目重构分支为模块化编写。如果你对本项目感兴趣,想加入开发,可以参照文档的 [贡献指南](https://static-php-cli.zhamao.me) 贡献代码或文档。(TODO) From 9ea3b04e82c401539233f63d73efac374f687b42 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 21 Jul 2023 09:48:28 +0800 Subject: [PATCH 043/296] Update README-en.md --- README-en.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README-en.md b/README-en.md index f676e7c0..4a093c93 100755 --- a/README-en.md +++ b/README-en.md @@ -244,6 +244,6 @@ and comply with the corresponding project's LICENSE. ## Advanced -This project is pure open source project, and some modules are separated for developing. - -This section will be improved after refactor version released. +The refactoring branch of this project is written modularly. +If you are interested in this project and want to join the development, +you can refer to the [Contribution Guide](https://static-php-cli.zhamao.me) of the documentation to contribute code or documentation. (TODO) From 74c2cf824bf3237f9e1f92f2082925a0b0a88b63 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 21 Jul 2023 14:46:12 +0800 Subject: [PATCH 044/296] Update README.md, add branch name change notes --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 768ffec4..e5e9695f 100755 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ If you are using English, see [English README](README-en.md). [![](https://img.shields.io/badge/Extension%20Counter-50+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() +> 在项目发布最后一个 RC 版本后(可能不超过 5 个候选版),项目将会重命名 `refactor` 分支为 `main` 分支,请依赖的项目注意更改分支名称。 + ## 编译环境需求 是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。 From 8f259ffed94bbded953a1a0773975795cbcb67de Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 21 Jul 2023 14:46:45 +0800 Subject: [PATCH 045/296] Update README-en.md, add branch rename notes --- README-en.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README-en.md b/README-en.md index 4a093c93..85fa715a 100755 --- a/README-en.md +++ b/README-en.md @@ -19,6 +19,8 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro [![](https://img.shields.io/badge/Extension%20Counter-50+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() +> After the project releases the last RC version (maybe no more than 5 candidate releases), the project will rename the `refactor` branch to the `main` branch, please pay attention to changing the branch name for dependent projects. + ## Compilation Requirements Yes, this project is written in PHP, pretty funny. From 8ec88386340def58694d1c83a53130298e8dc1c9 Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 21 Jul 2023 16:34:40 +0800 Subject: [PATCH 046/296] bold --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 768ffec4..947a3dc6 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. -If you are using English, see [English README](README-en.md). +**If you are using English, see [English README](README-en.md).** 编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携!(cli SAPI) From a2cb5165d316447b38a2d2a94eada00e5b228d66 Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 21 Jul 2023 17:09:11 +0800 Subject: [PATCH 047/296] add english tips --- README-en.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README-en.md b/README-en.md index 85fa715a..284907ff 100755 --- a/README-en.md +++ b/README-en.md @@ -225,6 +225,11 @@ The basic principles for contributing are as follows: If you want to contribute document content, please go to [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs). +Part of the English document is written by me, and part is translated by Google, +and there may be inaccurate descriptions, strange or offensive expressions. +If you are a native English speaker, some corrections to the documentation are welcome. + + ## Sponsor this project You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). From bc978ecbde78ff02a36952d4a53fb8ace4963382 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 22 Jul 2023 15:07:53 +0800 Subject: [PATCH 048/296] add macOS support for pgsql --- src/SPC/builder/unix/library/postgresql.php | 4 +++- src/SPC/store/SourcePatcher.php | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index e370a394..09d1e25b 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\builder\linux\library\LinuxLibraryBase; +use SPC\builder\macos\library\MacOSLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; @@ -30,7 +32,7 @@ trait postgresql $output = shell()->execWithResult($env . ' pkg-config --libs-only-L --static ' . $packages); if (!empty($output[1][0])) { $ldflags = $output[1][0]; - $envs .= " LDFLAGS=\"{$ldflags} -static\" "; + $envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" "; } $output = shell()->execWithResult($env . ' pkg-config --libs-only-l --static ' . $packages); if (!empty($output[1][0])) { diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index aba47b92..dfefae54 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -88,6 +88,9 @@ class SourcePatcher if ($ssh2 = $builder->getExt('ssh2')) { $patch[] = ['ssh2 patch', '/-lssh2/', $ssh2->getLibFilesString()]; } + if ($pgsql = $builder->getExt('pgsql')) { + $patch[] = ['pgsql patch', '/-lpq/', $pgsql->getLibFilesString()]; + } $patch[] = ['disable capstone', '/have_capstone="yes"/', 'have_capstone="no"']; foreach ($patch as $item) { logger()->info('Patching configure: ' . $item[0]); From 47101d058bd7a26cfdb6df1df605b6e566425616 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 22 Jul 2023 16:12:12 +0800 Subject: [PATCH 049/296] reformat code --- src/SPC/builder/unix/library/postgresql.php | 101 +++++++++----------- 1 file changed, 43 insertions(+), 58 deletions(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 09d1e25b..eb3b388f 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; @@ -18,23 +17,23 @@ trait postgresql */ protected function build() { - [$libdir, , $destdir] = SEPARATED_PATH; $builddir = BUILD_ROOT_PATH; $env = $this->builder->configure_env; $envs = $env; - $packages = 'openssl zlib readline libxml-2.0 '; // icu-uc icu-io icu-i18n libzstd + $packages = 'openssl zlib readline libxml-2.0'; // icu-uc icu-io icu-i18n libzstd - $output = shell()->execWithResult($env . ' pkg-config --cflags-only-I --static ' . $packages); + $pkgconfig_executable = $builddir . '/bin/pkg-config'; + $output = shell()->execWithResult($env . " {$pkgconfig_executable} --cflags-only-I --static " . $packages); if (!empty($output[1][0])) { $cppflags = $output[1][0]; $envs .= " CPPFLAGS=\"{$cppflags}\""; } - $output = shell()->execWithResult($env . ' pkg-config --libs-only-L --static ' . $packages); + $output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-L --static " . $packages); if (!empty($output[1][0])) { $ldflags = $output[1][0]; $envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" "; } - $output = shell()->execWithResult($env . ' pkg-config --libs-only-l --static ' . $packages); + $output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-l --static " . $packages); if (!empty($output[1][0])) { $libs = $output[1][0]; $envs .= " LIBS=\"{$libs}\" "; @@ -43,62 +42,48 @@ trait postgresql FileSystem::resetDir($this->source_dir . '/build'); # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile - shell()->cd($this->source_dir . '/build')->exec( - <<<'EOF' - sed -i.backup "s/invokes exit'; exit 1;/invokes exit';/" ../src/interfaces/libpq/Makefile -EOF - ); - - shell()->cd($this->source_dir . '/build')->exec( - <<<'EOF' - sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib -EOF - ); - shell()->cd($this->source_dir . '/build')->exec( - <<<'EOF' - sed -i.backup "441 s/^/#$/" ../src/Makefile.shlib -EOF - ); + shell()->cd($this->source_dir . '/build') + ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile') + ->exec(' sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib') + ->exec('sed -i.backup "441 s/^/#$/" ../src/Makefile.shlib'); + // configure shell()->cd($this->source_dir . '/build') ->exec( - <<cd($this->source_dir . '/build')->exec($envs . ' make -C src/bin/pg_config install'); - shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/include install'); - shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/common install'); - shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/backend/port install'); - shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/port install'); - shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/backend/libpq install'); - shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/interfaces/libpq install'); - shell()->cd($this->source_dir . '/build')->exec( - <<cd($this->source_dir . '/build') + ->exec($envs . ' make -C src/bin/pg_config install') + ->exec($envs . ' make -C src/include install') + ->exec($envs . ' make -C src/common install') + ->exec($envs . ' make -C src/backend/port install') + ->exec($envs . ' make -C src/port install') + ->exec($envs . ' make -C src/backend/libpq install') + ->exec($envs . ' make -C src/interfaces/libpq install'); + + // remove dynamic libs + shell()->cd($this->source_dir . '/build') + ->exec("rm -rf {$builddir}/lib/*.so.*") + ->exec("rm -rf {$builddir}/lib/*.so") + ->exec("rm -rf {$builddir}/lib/*.dylib"); } } From cbc3adbec07609cd4d2f7532038b5d145d795852 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 22 Jul 2023 16:29:46 +0800 Subject: [PATCH 050/296] fix pgsql env problem --- src/SPC/builder/unix/library/postgresql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index eb3b388f..87456f22 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -50,7 +50,7 @@ trait postgresql // configure shell()->cd($this->source_dir . '/build') ->exec( - "{$env} ../configure " . + "{$envs} ../configure " . "--prefix={$builddir} " . '--disable-thread-safety ' . '--enable-coverage=no ' . From 4abe0064e6afd5e8b1214cad2cd07f5f16785c88 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 22 Jul 2023 17:33:38 +0800 Subject: [PATCH 051/296] add dev commands --- src/SPC/command/dev/AllExtCommand.php | 24 ++++++++++++++ src/SPC/command/dev/ExtInfoCommand.php | 43 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 src/SPC/command/dev/AllExtCommand.php create mode 100644 src/SPC/command/dev/ExtInfoCommand.php diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php new file mode 100644 index 00000000..253e1d79 --- /dev/null +++ b/src/SPC/command/dev/AllExtCommand.php @@ -0,0 +1,24 @@ +output->writeln(implode(',', array_keys(Config::getExts()))); + + return 0; + } +} diff --git a/src/SPC/command/dev/ExtInfoCommand.php b/src/SPC/command/dev/ExtInfoCommand.php new file mode 100644 index 00000000..d45478c8 --- /dev/null +++ b/src/SPC/command/dev/ExtInfoCommand.php @@ -0,0 +1,43 @@ +addArgument('extensions', InputArgument::REQUIRED, 'The extension name you need to get info'); + } + + public function handle(): int + { + $extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions')))); + + // 根据提供的扩展列表获取依赖库列表并编译 + foreach ($extensions as $extension) { + $this->output->writeln('[ ' . $extension . ' ]'); + [, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps([$extension]); + $lib_suggests = Config::getExt($extension, 'lib-suggests', []); + $ext_suggests = Config::getExt($extension, 'ext-suggests', []); + $this->output->writeln("lib-depends:\t" . implode(', ', $libraries) . ''); + $this->output->writeln("lib-suggests:\t" . implode(', ', $lib_suggests) . ''); + $this->output->writeln("ext-depends:\t" . implode(',', $not_included) . ''); + $this->output->writeln("ext-suggests:\t" . implode(', ', $ext_suggests) . ''); + if (Config::getExt($extension, 'unix-only', false)) { + $this->output->writeln("Unix only:\ttrue"); + } + $this->output->writeln(''); + } + + return 0; + } +} From f1eacac4fdf873be6a40389538e39a259ff47435 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 22 Jul 2023 17:34:33 +0800 Subject: [PATCH 052/296] change extension count --- README-en.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-en.md b/README-en.md index 284907ff..b150a816 100755 --- a/README-en.md +++ b/README-en.md @@ -16,7 +16,7 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) -[![](https://img.shields.io/badge/Extension%20Counter-50+-yellow.svg?style=flat-square)]() +[![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() > After the project releases the last RC version (maybe no more than 5 candidate releases), the project will rename the `refactor` branch to the `main` branch, please pay attention to changing the branch name for dependent projects. diff --git a/README.md b/README.md index fb05a4a4..cfa6b38b 100755 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) -[![](https://img.shields.io/badge/Extension%20Counter-50+-yellow.svg?style=flat-square)]() +[![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() > 在项目发布最后一个 RC 版本后(可能不超过 5 个候选版),项目将会重命名 `refactor` 分支为 `main` 分支,请依赖的项目注意更改分支名称。 From 0186ae5ff22b6090d5905bdefe0c4368fc29d911 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 23 Jul 2023 11:30:54 +0800 Subject: [PATCH 053/296] remove build upload downloads.zip, separated workflow instead --- .github/workflows/build-linux-x86_64.yml | 5 ----- .github/workflows/build-macos-x86_64.yml | 5 ----- 2 files changed, 10 deletions(-) diff --git a/.github/workflows/build-linux-x86_64.yml b/.github/workflows/build-linux-x86_64.yml index 0fbe82d8..f164efb3 100644 --- a/.github/workflows/build-linux-x86_64.yml +++ b/.github/workflows/build-linux-x86_64.yml @@ -115,8 +115,3 @@ jobs: buildroot/build-extensions.json buildroot/build-libraries.json - # Upload downloaded files - - uses: actions/upload-artifact@v3 - with: - name: download-files - path: downloads/ diff --git a/.github/workflows/build-macos-x86_64.yml b/.github/workflows/build-macos-x86_64.yml index d37900ec..3aa44541 100644 --- a/.github/workflows/build-macos-x86_64.yml +++ b/.github/workflows/build-macos-x86_64.yml @@ -115,8 +115,3 @@ jobs: buildroot/build-extensions.json buildroot/build-libraries.json - # Upload downloaded files - - uses: actions/upload-artifact@v3 - with: - name: download-files - path: downloads/ From 3745dfc931fbb188eb355f64d02a7be17446481f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 23 Jul 2023 22:54:32 +0800 Subject: [PATCH 054/296] fix #75 --- src/SPC/builder/macos/library/libxml2.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/SPC/builder/macos/library/libxml2.php b/src/SPC/builder/macos/library/libxml2.php index 1333c89f..53fa1e52 100644 --- a/src/SPC/builder/macos/library/libxml2.php +++ b/src/SPC/builder/macos/library/libxml2.php @@ -31,18 +31,16 @@ class libxml2 extends MacOSLibraryBase '-DBUILD_SHARED_LIBS=OFF ' . '-DLIBXML2_WITH_ICONV=ON ' . "-DLIBXML2_WITH_ZLIB={$enable_zlib} " . - "-DLIBXML2_WITH_ICU={$enable_icu} " . + '-DLIBXML2_WITH_ICU=OFF ' . "-DLIBXML2_WITH_LZMA={$enable_xz} " . '-DLIBXML2_WITH_PYTHON=OFF ' . '-DLIBXML2_WITH_PROGRAMS=OFF ' . '-DLIBXML2_WITH_TESTS=OFF ' . - '-DCMAKE_INSTALL_PREFIX=/ ' . - "-DCMAKE_INSTALL_LIBDIR={$lib} " . - "-DCMAKE_INSTALL_INCLUDEDIR={$include} " . + "-DCMAKE_INSTALL_PREFIX={$destdir} " . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec("make install DESTDIR={$destdir}"); + ->exec('make install'); } } From 65b0bd01c8c4114165d1ceec4228d7c198cdd973 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 23 Jul 2023 22:56:04 +0800 Subject: [PATCH 055/296] add auto-detect icu support for postgresql --- config/lib.json | 3 +++ src/SPC/builder/unix/library/postgresql.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/lib.json b/config/lib.json index 40422539..bc067ce1 100644 --- a/config/lib.json +++ b/config/lib.json @@ -391,6 +391,9 @@ "openssl", "zlib", "readline" + ], + "lib-suggests": [ + "icu" ] }, "pthreads4w": { diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 87456f22..40b39c41 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -57,7 +57,7 @@ trait postgresql '--with-ssl=openssl ' . '--with-readline ' . '--with-libxml ' . - '--without-icu ' . + ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . '--without-ldap ' . '--without-libxslt ' . '--without-lz4 ' . From 0e024a8c430baddf3e65ae85574482d6abc89779 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 23 Jul 2023 23:16:18 +0800 Subject: [PATCH 056/296] change default to docker (some c++ packages needed) --- .github/workflows/build-linux-x86_64.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-linux-x86_64.yml b/.github/workflows/build-linux-x86_64.yml index f164efb3..446f8f09 100644 --- a/.github/workflows/build-linux-x86_64.yml +++ b/.github/workflows/build-linux-x86_64.yml @@ -77,10 +77,10 @@ jobs: # If there's no dependencies cache, fetch sources, with or without debug - if: steps.cache-download.outputs.cache-hit != 'true' - run: CACHE_API_EXEC=yes ./bin/spc download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }} + run: CACHE_API_EXEC=yes ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }} # Run build command - - run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} + - run: ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} # Upload cli executable - if: ${{ inputs.build-cli == true }} From b8e6f9d1be1c7b22a493c33e87de37719cbb4e22 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 24 Jul 2023 23:49:52 +0800 Subject: [PATCH 057/296] add hasCppExtension check --- config/ext.json | 2 ++ src/SPC/builder/BuilderBase.php | 31 ++++++++++++++++++++++++++ src/SPC/builder/linux/LinuxBuilder.php | 3 ++- src/SPC/builder/macos/MacOSBuilder.php | 7 ++++-- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/config/ext.json b/config/ext.json index cc6b067d..16920649 100644 --- a/config/ext.json +++ b/config/ext.json @@ -138,6 +138,7 @@ }, "intl": { "type": "builtin", + "cpp-extension": true, "lib-depends": [ "icu" ] @@ -327,6 +328,7 @@ "type": "external", "source": "swoole", "arg-type": "custom", + "cpp-extension": true, "lib-depends": [ "openssl" ], diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 900bb4ed..fd1a2844 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -140,6 +140,37 @@ abstract class BuilderBase return $this->exts[$name] ?? null; } + /** + * 获取所有要编译的扩展对象 + * + * @return Extension[] + */ + public function getExts(): array + { + return $this->exts; + } + + /** + * 检查 C++ 扩展是否存在 + * + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + public function hasCppExtension(): bool + { + // judge cpp-extension + $exts = array_keys($this->getExts()); + $cpp = false; + foreach ($exts as $ext) { + if (Config::getExt($ext, 'cpp-extension', false) === true) { + $cpp = true; + break; + } + } + return $cpp; + } + /** * 设置本次 Builder 是否为仅编译库的模式 */ diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 486d5afb..b0237de8 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -139,7 +139,8 @@ class LinuxBuilder extends BuilderBase ) ); } - if ($this->getExt('swoole') || $this->getExt('intl')) { + + if ($this->hasCppExtension()) { $extra_libs .= ' -lstdc++'; } if ($this->getExt('imagick')) { diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 65b1a7f6..ed780691 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -118,12 +118,15 @@ class MacOSBuilder extends BuilderBase } /** - * @throws RuntimeException + * @param int $build_target build target + * @param bool $bloat just raw add all lib files * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $bloat = false): void { - $extra_libs = $this->getFrameworks(true) . ' ' . ($this->getExt('swoole') || $this->getExt('intl') ? '-lc++ ' : ''); + $extra_libs = $this->getFrameworks(true) . ' ' . ($this->hasCppExtension() ? '-lc++' : ''); if (!$bloat) { $extra_libs .= implode(' ', $this->getAllStaticLibFiles()); } else { From 778b0eadcd819a9149b43fc911aafb5e3d194230 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 25 Jul 2023 00:31:12 +0800 Subject: [PATCH 058/296] add default openssl.cnf path for macOS --- src/SPC/builder/macos/library/openssl.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index 7349e9ee..89c778a0 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -42,7 +42,8 @@ class openssl extends MacOSLibraryBase "{$this->builder->configure_env} ./Configure no-shared {$extra} " . '--prefix=/ ' . // use prefix=/ "--libdir={$lib} " . - " darwin64-{$this->builder->arch}-cc" + '--openssldir=/System/Library/OpenSSL ' . + "darwin64-{$this->builder->arch}-cc" ) ->exec('make clean') ->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"") From 956c87a6577062805cfd30b84d00d7dfff97d6f7 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 25 Jul 2023 21:44:53 +0800 Subject: [PATCH 059/296] add memcache support --- config/ext.json | 25 +++++++++++++++------ config/source.json | 10 +++++++++ src/SPC/builder/extension/memcache.php | 17 +++++++++++++++ src/SPC/store/SourcePatcher.php | 30 +++++++++++++++++++++++--- 4 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 src/SPC/builder/extension/memcache.php diff --git a/config/ext.json b/config/ext.json index 16920649..e7321203 100644 --- a/config/ext.json +++ b/config/ext.json @@ -163,6 +163,17 @@ "onig" ] }, + "memcache": { + "type": "external", + "source": "ext-memcache", + "arg-type": "custom", + "lib-depends": [ + "zlib" + ], + "ext-depends": [ + "session" + ] + }, "mongodb": { "type": "external", "source": "mongodb", @@ -220,13 +231,6 @@ "postgresql" ] }, - "pgsql": { - "type": "builtin", - "arg-type": "with-prefix", - "lib-depends": [ - "postgresql" - ] - }, "pdo_sqlite": { "type": "builtin", "arg-type": "with", @@ -238,6 +242,13 @@ "sqlite" ] }, + "pgsql": { + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "postgresql" + ] + }, "phar": { "type": "builtin", "ext-depends": [ diff --git a/config/source.json b/config/source.json index 8410e5bd..41f96367 100644 --- a/config/source.json +++ b/config/source.json @@ -61,6 +61,16 @@ "path": "LICENSE" } }, + "ext-memcache": { + "type": "url", + "url": "https://pecl.php.net/get/memcache", + "path": "php-src/ext/memcache", + "filename": "memcache.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-ssh2": { "type": "url", "url": "https://pecl.php.net/get/ssh2", diff --git a/src/SPC/builder/extension/memcache.php b/src/SPC/builder/extension/memcache.php new file mode 100644 index 00000000..2d2e2c94 --- /dev/null +++ b/src/SPC/builder/extension/memcache.php @@ -0,0 +1,17 @@ +getExt('pdo_sqlite')) { - // FileSystem::replaceFile() - // } + if ($builder->getExt('memcache')) { + FileSystem::replaceFile( + SOURCE_PATH . '/php-src/ext/memcache/config9.m4', + REPLACE_FILE_STR, + 'if test -d $abs_srcdir/src ; then', + 'if test -d $abs_srcdir/main ; then' + ); + FileSystem::replaceFile( + SOURCE_PATH . '/php-src/ext/memcache/config9.m4', + REPLACE_FILE_STR, + 'export CPPFLAGS="$CPPFLAGS $INCLUDES"', + 'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"' + ); + // add for in-tree building + file_put_contents( + SOURCE_PATH . '/php-src/ext/memcache/php_memcache.h', + <<<'EOF' +#ifndef PHP_MEMCACHE_H +#define PHP_MEMCACHE_H + +extern zend_module_entry memcache_module_entry; +#define phpext_memcache_ptr &memcache_module_entry + +#endif +EOF + ); + } } public static function patchSwow(): bool From c5a70f101a1434e93cfde94e2ba52d5ea8f79271 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 26 Jul 2023 00:01:12 +0800 Subject: [PATCH 060/296] fix macOS C++ space --- src/SPC/builder/macos/MacOSBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index ed780691..5e8fd6d7 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -126,7 +126,7 @@ class MacOSBuilder extends BuilderBase */ public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $bloat = false): void { - $extra_libs = $this->getFrameworks(true) . ' ' . ($this->hasCppExtension() ? '-lc++' : ''); + $extra_libs = $this->getFrameworks(true) . ' ' . ($this->hasCppExtension() ? '-lc++ ' : ''); if (!$bloat) { $extra_libs .= implode(' ', $this->getAllStaticLibFiles()); } else { From 1c8bbfbbdf860b4fc16042fee2b92308cc2543bd Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 26 Jul 2023 00:07:54 +0800 Subject: [PATCH 061/296] fix libevent bug --- src/SPC/builder/unix/library/libevent.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/unix/library/libevent.php b/src/SPC/builder/unix/library/libevent.php index bd8f3b76..66de81b7 100644 --- a/src/SPC/builder/unix/library/libevent.php +++ b/src/SPC/builder/unix/library/libevent.php @@ -22,6 +22,7 @@ trait libevent '-DEVENT__LIBRARY_TYPE=STATIC ' . '-DEVENT__DISABLE_BENCHMARK=ON ' . '-DEVENT__DISABLE_THREAD_SUPPORT=ON ' . + '-DEVENT__DISABLE_MBEDTLS=ON ' . '-DEVENT__DISABLE_TESTS=ON ' . '-DEVENT__DISABLE_SAMPLES=ON ' . '..' From 75b85c26dcfb6d7d90969df5466a00f30956dba9 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 26 Jul 2023 00:08:20 +0800 Subject: [PATCH 062/296] add memcached for macOS --- config/ext.json | 13 ++++++++ config/lib.json | 7 +++++ config/source.json | 19 ++++++++++++ src/SPC/builder/extension/memcached.php | 18 +++++++++++ .../builder/linux/library/libmemcached.php | 20 ++++++++++++ .../builder/macos/library/libmemcached.php | 31 +++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 src/SPC/builder/extension/memcached.php create mode 100644 src/SPC/builder/linux/library/libmemcached.php create mode 100644 src/SPC/builder/macos/library/libmemcached.php diff --git a/config/ext.json b/config/ext.json index e7321203..fd3a14c5 100644 --- a/config/ext.json +++ b/config/ext.json @@ -53,6 +53,19 @@ "sockets" ] }, + "memcached": { + "type": "external", + "source": "memcached", + "arg-type": "custom", + "cpp-extension": true, + "lib-depends": [ + "libmemcached" + ], + "ext-depends": [ + "session", + "zlib" + ] + }, "exif": { "type": "builtin" }, diff --git a/config/lib.json b/config/lib.json index bc067ce1..41be5156 100644 --- a/config/lib.json +++ b/config/lib.json @@ -462,6 +462,13 @@ "zconf.h" ] }, + "libmemcached": { + "source": "libmemcached", + "static-libs-unix": [ + "libmemcached.a", + "libmemcachedutil.a" + ] + }, "zstd": { "source": "zstd", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 41f96367..a9ada593 100644 --- a/config/source.json +++ b/config/source.json @@ -16,6 +16,25 @@ "path": "LICENSE" } }, + "memcached": { + "type": "url", + "url": "https://pecl.php.net/get/memcached", + "path": "php-src/ext/memcached", + "filename": "memcached.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, + "libmemcached": { + "type": "git", + "url": "https://github.com/crazywhalecc/libmemcached-macos.git", + "rev": "master", + "license": { + "type": "file", + "path": "COPYING" + } + }, "brotli": { "type": "ghtar", "repo": "google/brotli", diff --git a/src/SPC/builder/extension/memcached.php b/src/SPC/builder/extension/memcached.php new file mode 100644 index 00000000..49fb228d --- /dev/null +++ b/src/SPC/builder/extension/memcached.php @@ -0,0 +1,18 @@ +cd($this->source_dir) + ->exec('chmod +x configure') + ->exec( + "{$this->builder->configure_env} ./configure " . + '--enable-static --disable-shared ' . + '--disable-sasl ' . + "--prefix={$rootdir}" + ) + ->exec('make clean') + ->exec('sed -ie "s/-Werror//g" ' . $this->source_dir . '/Makefile') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install'); + } +} From 6d4755d8c98a62cf6295fbc94a13e775c872b325 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 27 Jul 2023 18:13:37 +0800 Subject: [PATCH 063/296] fix pgsql dependency --- config/ext.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index fd3a14c5..1332a2a0 100644 --- a/config/ext.json +++ b/config/ext.json @@ -238,7 +238,8 @@ "type": "builtin", "arg-type": "with-prefix", "ext-depends": [ - "pdo" + "pdo", + "pgsql" ], "lib-depends": [ "postgresql" From 50632f6527cdec007adbf6d0db7b21af86f7627b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 27 Jul 2023 18:11:08 +0800 Subject: [PATCH 064/296] fix libpng build bug for linux --- src/SPC/builder/linux/library/libpng.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index e3d0e2ce..888c5bdc 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -45,6 +45,7 @@ class libpng extends LinuxLibraryBase shell()->cd($this->source_dir) ->exec('chmod +x ./configure') + ->exec('chmod +x ./install-sh') ->exec( "{$this->builder->configure_env} ./configure " . "--host={$this->builder->gnu_arch}-unknown-linux " . From b698ae2f506804b3793dcd6b7533b54e7d55adfe Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 27 Jul 2023 18:42:05 +0800 Subject: [PATCH 065/296] add strip option (fix #97) --- src/SPC/command/BuildCliCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 6aad5509..298c0aa9 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -71,7 +71,7 @@ class BuildCliCommand extends BuildCommand // 执行扩展检测 $builder->proveExts($extensions); // strip - $builder->setStrip(false); + $builder->setStrip(!$this->getOption('no-strip')); // 构建 $builder->buildPHP($rule, $this->getOption('bloat')); // 统计时间 From 980da4ea0fc5a3e0524e3650b36b3e970d810a9c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 27 Jul 2023 18:46:37 +0800 Subject: [PATCH 066/296] fix mbregex without mbstring failed check (fix #96) --- config/ext.json | 5 +++-- src/SPC/builder/extension/mbregex.php | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config/ext.json b/config/ext.json index 1332a2a0..b25b9c72 100644 --- a/config/ext.json +++ b/config/ext.json @@ -165,8 +165,9 @@ }, "mbregex": { "type": "builtin", - "lib-depends": [ - "onig" + "arg-type": "custom", + "ext-depends": [ + "mbstring" ] }, "mbstring": { diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index 48d15128..6a4d1457 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -14,4 +14,9 @@ class mbregex extends Extension { return 'mbstring'; } + + public function getConfigureArg(): string + { + return ''; + } } From 6131e1881b301dd61950d6018fb438564a735aac Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 27 Jul 2023 22:22:06 +0800 Subject: [PATCH 067/296] enable compile optimization for other libraries --- src/SPC/builder/macos/MacOSBuilder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 5e8fd6d7..c41c944f 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -54,7 +54,7 @@ class MacOSBuilder extends BuilderBase 'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig/" ' . "CC='{$this->cc}' " . "CXX='{$this->cxx}' " . - "CFLAGS='{$this->arch_c_flags} -Wimplicit-function-declaration'"; + "CFLAGS='{$this->arch_c_flags} -Wimplicit-function-declaration -Os'"; // 创立 pkg-config 和放头文件的目录 f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true); @@ -212,7 +212,7 @@ class MacOSBuilder extends BuilderBase public function buildCli(string $extra_libs): void { $shell = shell()->cd(SOURCE_PATH . '/php-src'); - $shell->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os -fno-ident\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" cli"); + $shell->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" cli"); if ($this->strip) { $shell->exec('dsymutil -f sapi/cli/php')->exec('strip sapi/cli/php'); } From 752b88f62da5b9febc3f64bc2ed7b83bf1c2019f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 27 Jul 2023 23:18:44 +0800 Subject: [PATCH 068/296] prepare to release rc3, add dev:php-ver command --- src/SPC/ConsoleApplication.php | 2 +- src/SPC/command/dev/PhpVerCommand.php | 33 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/SPC/command/dev/PhpVerCommand.php diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index c4ecf50b..b073cd6a 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -16,7 +16,7 @@ use Symfony\Component\Console\Command\ListCommand; */ class ConsoleApplication extends Application { - public const VERSION = '2.0-rc2'; + public const VERSION = '2.0-rc3'; /** * @throws \ReflectionException diff --git a/src/SPC/command/dev/PhpVerCommand.php b/src/SPC/command/dev/PhpVerCommand.php new file mode 100644 index 00000000..cdd4cfa6 --- /dev/null +++ b/src/SPC/command/dev/PhpVerCommand.php @@ -0,0 +1,33 @@ +no_motd = true; + parent::initialize($input, $output); + } + + public function handle(): int + { + // Find php from source/php-src + $file = SOURCE_PATH . '/php-src/main/php_version.h'; + $result = preg_match('/#define PHP_VERSION "(\d+\.\d+\.\d+)"/', file_get_contents($file), $match); + if ($result === false) { + $this->output->writeln('PHP source not found, maybe you need to extract first ?'); + return 1; + } + $this->output->writeln('' . $match[1] . ''); + return 0; + } +} From f7730735c0b7eeb592eb0a57c85169023dc0a90a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 27 Jul 2023 23:23:57 +0800 Subject: [PATCH 069/296] prepare to release rc3 --- README-en.md | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README-en.md b/README-en.md index b150a816..7c83c2d8 100755 --- a/README-en.md +++ b/README-en.md @@ -11,7 +11,7 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro 截屏2023-05-02 15 52 33 -[![Version](https://img.shields.io/badge/Version-2.0--rc2-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc3-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) @@ -19,7 +19,7 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro [![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() -> After the project releases the last RC version (maybe no more than 5 candidate releases), the project will rename the `refactor` branch to the `main` branch, please pay attention to changing the branch name for dependent projects. +> The project has renamed the `refactor` branch to the `main` branch, please pay attention to changing the branch name for dependent projects. ## Compilation Requirements diff --git a/README.md b/README.md index cfa6b38b..1eabb465 100755 --- a/README.md +++ b/README.md @@ -12,14 +12,14 @@ Compile A Statically Linked PHP With Swoole and other Extensions. 截屏2023-05-02 15 52 33 -[![Version](https://img.shields.io/badge/Version-2.0--rc2-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc3-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() -> 在项目发布最后一个 RC 版本后(可能不超过 5 个候选版),项目将会重命名 `refactor` 分支为 `main` 分支,请依赖的项目注意更改分支名称。 +> 项目已重命名 `refactor` 分支为 `main` 分支,请依赖的项目注意更改分支名称。 ## 编译环境需求 From ea322c0d3b864c08f67185735a38cea14171a3a1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 28 Jul 2023 00:02:49 +0800 Subject: [PATCH 070/296] add extract command, add -U option (custom download source --- src/SPC/ConsoleApplication.php | 3 +- src/SPC/builder/BuilderBase.php | 58 +++---------------------- src/SPC/command/DownloadCommand.php | 28 +++++++++++- src/SPC/command/ExtractCommand.php | 35 +++++++++++++++ src/SPC/command/dev/PhpVerCommand.php | 2 +- src/SPC/store/Downloader.php | 4 +- src/SPC/store/SourceExtractor.php | 61 +++++++++++++++++++++++++++ 7 files changed, 132 insertions(+), 59 deletions(-) create mode 100644 src/SPC/command/ExtractCommand.php create mode 100644 src/SPC/store/SourceExtractor.php diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index b073cd6a..db03abef 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -7,7 +7,6 @@ namespace SPC; use SPC\command\DeployCommand; use SPC\store\FileSystem; use Symfony\Component\Console\Application; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\HelpCommand; use Symfony\Component\Console\Command\ListCommand; @@ -16,7 +15,7 @@ use Symfony\Component\Console\Command\ListCommand; */ class ConsoleApplication extends Application { - public const VERSION = '2.0-rc3'; + public const VERSION = '2.0-rc4'; /** * @throws \ReflectionException diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index fd1a2844..c9243ca0 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -9,6 +9,7 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; +use SPC\store\SourceExtractor; use SPC\util\CustomExt; use SPC\util\DependencyUtil; @@ -87,7 +88,7 @@ abstract class BuilderBase $lib->calcDependency(); } - $this->initSource(libs: $libraries); + SourceExtractor::initSource(libs: $libraries); // 构建库 foreach ($this->libs as $lib) { @@ -188,11 +189,11 @@ abstract class BuilderBase public function proveExts(array $extensions): void { CustomExt::loadCustomExt(); - $this->initSource(sources: ['php-src']); + SourceExtractor::initSource(sources: ['php-src']); if ($this->getPHPVersionID() >= 80000) { - $this->initSource(sources: ['micro']); + SourceExtractor::initSource(sources: ['micro']); } - $this->initSource(exts: $extensions); + SourceExtractor::initSource(exts: $extensions); foreach ($extensions as $extension) { $class = CustomExt::getExtClass($extension); $ext = new $class($extension, $this); @@ -221,6 +222,7 @@ abstract class BuilderBase * * @throws RuntimeException * @throws FileSystemException + * @throws WrongUsageException */ public function makeExtensionArgs(): string { @@ -292,52 +294,4 @@ abstract class BuilderBase ); } } - - protected function initSource(?array $sources = null, ?array $libs = null, ?array $exts = null): void - { - if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { - throw new WrongUsageException('Download lock file "downloads/.lock.json" not found, maybe you need to download sources first ?'); - } - $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true); - - $sources_extracted = []; - // source check exist - if (is_array($sources)) { - foreach ($sources as $source) { - $sources_extracted[$source] = true; - } - } - // lib check source exist - if (is_array($libs)) { - foreach ($libs as $lib) { - // get source name for lib - $source = Config::getLib($lib, 'source'); - $sources_extracted[$source] = true; - } - } - // ext check source exist - if (is_array($exts)) { - foreach ($exts as $ext) { - // get source name for ext - if (Config::getExt($ext, 'type') !== 'external') { - continue; - } - $source = Config::getExt($ext, 'source'); - $sources_extracted[$source] = true; - } - } - - // start check - foreach ($sources_extracted as $source => $item) { - if (!isset($lock[$source])) { - throw new WrongUsageException('Source [' . $source . '] not downloaded, you should download it first !'); - } - - // check source dir exist - $check = $lock[$source]['move_path'] === null ? SOURCE_PATH . '/' . $source : SOURCE_PATH . '/' . $lock[$source]['move_path']; - if (!is_dir($check)) { - FileSystem::extractSource($source, DOWNLOAD_PATH . '/' . ($lock[$source]['filename'] ?? $lock[$source]['dirname']), $lock[$source]['move_path']); - } - } - } } diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index f25fefcc..23522fda 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -31,6 +31,7 @@ class DownloadCommand extends BaseCommand $this->addOption('with-php', null, InputOption::VALUE_REQUIRED, 'version in major.minor format like 8.1', '8.1'); $this->addOption('clean', null, null, 'Clean old download cache and source before fetch'); $this->addOption('all', 'A', null, 'Fetch all sources that static-php-cli needed'); + $this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"'); $this->addOption('from-zip', 'Z', InputOption::VALUE_REQUIRED, 'Fetch from zip archive'); } @@ -139,14 +140,37 @@ class DownloadCommand extends BaseCommand } $chosen_sources = $sources; + // Process -U options + $custom_urls = []; + foreach ($this->input->getOption('custom-url') as $value) { + [$source_name, $url] = explode(':', $value, 2); + $custom_urls[$source_name] = $url; + } + // Download them f_mkdir(DOWNLOAD_PATH); $cnt = count($chosen_sources); $ni = 0; foreach ($chosen_sources as $source) { ++$ni; - logger()->info("Fetching source {$source} [{$ni}/{$cnt}]"); - Downloader::downloadSource($source, Config::getSource($source)); + if (isset($custom_urls[$source])) { + $config = Config::getSource($source); + $new_config = [ + 'type' => 'url', + 'url' => $custom_urls[$source], + ]; + if (isset($config['path'])) { + $new_config['path'] = $config['path']; + } + if (isset($config['filename'])) { + $new_config['filename'] = $config['filename']; + } + logger()->info("Fetching source {$source} from custom url [{$ni}/{$cnt}]"); + Downloader::downloadSource($source, $new_config, true); + } else { + logger()->info("Fetching source {$source} [{$ni}/{$cnt}]"); + Downloader::downloadSource($source, Config::getSource($source)); + } } // 打印拉取资源用时 $time = round(microtime(true) - START_TIME, 3); diff --git a/src/SPC/command/ExtractCommand.php b/src/SPC/command/ExtractCommand.php new file mode 100644 index 00000000..3a9f718a --- /dev/null +++ b/src/SPC/command/ExtractCommand.php @@ -0,0 +1,35 @@ +addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated'); + } + + public function handle(): int + { + $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); + if (empty($sources)) { + $this->output->writeln('sources cannot be empty, at least contain one !'); + return 1; + } + SourceExtractor::initSource(sources: $sources); + logger()->info('Extract done !'); + return 0; + } +} diff --git a/src/SPC/command/dev/PhpVerCommand.php b/src/SPC/command/dev/PhpVerCommand.php index cdd4cfa6..9b729da2 100644 --- a/src/SPC/command/dev/PhpVerCommand.php +++ b/src/SPC/command/dev/PhpVerCommand.php @@ -22,7 +22,7 @@ class PhpVerCommand extends BaseCommand { // Find php from source/php-src $file = SOURCE_PATH . '/php-src/main/php_version.h'; - $result = preg_match('/#define PHP_VERSION "(\d+\.\d+\.\d+)"/', file_get_contents($file), $match); + $result = preg_match('/#define PHP_VERSION "([^"]+)"/', file_get_contents($file), $match); if ($result === false) { $this->output->writeln('PHP source not found, maybe you need to extract first ?'); return 1; diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 39a22494..d8aada0f 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -265,7 +265,7 @@ class Downloader * @throws FileSystemException * @throws RuntimeException */ - public static function downloadSource(string $name, ?array $source = null): void + public static function downloadSource(string $name, ?array $source = null, bool $force = false): void { if ($source === null) { $source = Config::getSource($name); @@ -278,7 +278,7 @@ class Downloader $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true) ?? []; } // If lock file exists, skip downloading - if (isset($lock[$name])) { + if (isset($lock[$name]) && !$force) { if ($lock[$name]['source_type'] === 'archive' && file_exists(DOWNLOAD_PATH . '/' . $lock[$name]['filename'])) { logger()->notice("source [{$name}] already downloaded: " . $lock[$name]['filename']); return; diff --git a/src/SPC/store/SourceExtractor.php b/src/SPC/store/SourceExtractor.php new file mode 100644 index 00000000..8842b890 --- /dev/null +++ b/src/SPC/store/SourceExtractor.php @@ -0,0 +1,61 @@ + $item) { + if (Config::getSource($source) === null) { + throw new WrongUsageException("Source [{$source}] not exists, please check name and correct it !"); + } + if (!isset($lock[$source])) { + throw new WrongUsageException('Source [' . $source . '] not downloaded or not locked, you should download it first !'); + } + + // check source dir exist + $check = $lock[$source]['move_path'] === null ? SOURCE_PATH . '/' . $source : SOURCE_PATH . '/' . $lock[$source]['move_path']; + if (!is_dir($check)) { + FileSystem::extractSource($source, DOWNLOAD_PATH . '/' . ($lock[$source]['filename'] ?? $lock[$source]['dirname']), $lock[$source]['move_path']); + } + } + } +} From 725e6b25dcbe757a8f3c2986c64ca2b83b4cbc04 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 29 Jul 2023 19:01:14 +0800 Subject: [PATCH 071/296] Fix #111 --- config/ext.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index b25b9c72..f227caf9 100644 --- a/config/ext.json +++ b/config/ext.json @@ -208,7 +208,10 @@ }, "mysqlnd": { "type": "builtin", - "arg-type-windows": "with" + "arg-type-windows": "with", + "lib-depends": [ + "zlib" + ] }, "opcache": { "type": "builtin" From aaf712be3cee2ebcbd44936ca5cbc331f1f8731d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 28 Jul 2023 23:44:14 +0800 Subject: [PATCH 072/296] add comments --- src/SPC/builder/BuilderBase.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index c9243ca0..e6763049 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -185,6 +185,8 @@ abstract class BuilderBase * * @throws FileSystemException * @throws RuntimeException + * @throws \ReflectionException + * @throws WrongUsageException */ public function proveExts(array $extensions): void { From e909dd15b07aa6a0c17e9fa0790c8e279b9b5761 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 28 Jul 2023 23:45:39 +0800 Subject: [PATCH 073/296] add library, extension patch methods base --- src/SPC/builder/Extension.php | 27 +++ src/SPC/builder/LibraryBase.php | 9 + src/SPC/builder/linux/LinuxBuilder.php | 6 +- .../linux/library/LinuxLibraryBase.php | 1 + src/SPC/builder/macos/MacOSBuilder.php | 8 +- src/SPC/store/SourcePatcher.php | 181 ++++-------------- 6 files changed, 78 insertions(+), 154 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 7e81cb88..24118844 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -136,6 +136,33 @@ class Extension return ''; } + /** + * Patch code before ./buildconf + * If you need to patch some code, overwrite this and return true + */ + public function patchBeforeBuildconf(): bool + { + return false; + } + + /** + * Patch code before ./configure + * If you need to patch some code, overwrite this and return true + */ + public function patchBeforeConfigure(): bool + { + return false; + } + + /** + * Patch code before make + * If you need to patch some code, overwrite this and return true + */ + public function patchBeforeMake(): bool + { + return false; + } + /** * @throws RuntimeException */ diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index 7f234a5b..5b0828dd 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -135,6 +135,7 @@ abstract class LibraryBase // 传入 true,表明直接编译 if ($force_build) { logger()->info('Building required library [' . static::NAME . ']'); + $this->patchBeforeBuild(); $this->build(); return BUILD_STATUS_OK; } @@ -162,6 +163,14 @@ abstract class LibraryBase return BUILD_STATUS_ALREADY; } + /** + * Patch before build, overwrite this and return true to patch libs + */ + public function patchBeforeBuild(): bool + { + return false; + } + /** * 获取构建当前 lib 的 Builder 对象 */ diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index b0237de8..e088b0d6 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -169,11 +169,11 @@ class LinuxBuilder extends BuilderBase $envs = "{$envs} CFLAGS='{$cflags}' LIBS='-ldl -lpthread'"; - SourcePatcher::patchPHPBuildconf($this); + SourcePatcher::patchBeforeBuildconf($this); shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force'); - SourcePatcher::patchPHPConfigure($this); + SourcePatcher::patchBeforeConfigure($this); if ($this->getPHPVersionID() < 80000) { $json_74 = '--enable-json '; @@ -200,7 +200,7 @@ class LinuxBuilder extends BuilderBase $envs ); - SourcePatcher::patchPHPAfterConfigure($this); + SourcePatcher::patchBeforeMake($this); file_put_contents('/tmp/comment', $this->note_section); diff --git a/src/SPC/builder/linux/library/LinuxLibraryBase.php b/src/SPC/builder/linux/library/LinuxLibraryBase.php index 2712976b..e3d9878e 100644 --- a/src/SPC/builder/linux/library/LinuxLibraryBase.php +++ b/src/SPC/builder/linux/library/LinuxLibraryBase.php @@ -43,6 +43,7 @@ abstract class LinuxLibraryBase extends LibraryBase // 传入 true,表明直接编译 if ($force_build) { logger()->info('Building required library [' . static::NAME . ']'); + $this->patchBeforeBuild(); $this->build(); return BUILD_STATUS_OK; } diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index c41c944f..5e48629e 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -140,12 +140,12 @@ class MacOSBuilder extends BuilderBase ); } - // patch before configure - SourcePatcher::patchPHPBuildconf($this); + // patch before buildconf + SourcePatcher::patchBeforeBuildconf($this); shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force'); - SourcePatcher::patchPHPConfigure($this); + SourcePatcher::patchBeforeConfigure($this); if ($this->getLib('libxml2') || $this->getExt('iconv')) { $extra_libs .= ' -liconv'; @@ -177,7 +177,7 @@ class MacOSBuilder extends BuilderBase $this->configure_env ); - SourcePatcher::patchPHPAfterConfigure($this); + SourcePatcher::patchBeforeMake($this); $this->cleanMake(); diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 56b3c7b9..ecd3f05d 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -6,164 +6,47 @@ namespace SPC\store; use SPC\builder\BuilderBase; use SPC\builder\linux\LinuxBuilder; -use SPC\builder\linux\SystemUtil; -use SPC\builder\macos\MacOSBuilder; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; -use SPC\util\Util; class SourcePatcher { public static function init() { - FileSystem::addSourceExtractHook('swow', [SourcePatcher::class, 'patchSwow']); + // FileSystem::addSourceExtractHook('swow', [SourcePatcher::class, 'patchSwow']); FileSystem::addSourceExtractHook('micro', [SourcePatcher::class, 'patchMicro']); FileSystem::addSourceExtractHook('openssl', [SourcePatcher::class, 'patchOpenssl11Darwin']); } - public static function patchPHPBuildconf(BuilderBase $builder): void + /** + * Source patcher runner before buildconf + * + * @param BuilderBase $builder Builder + */ + public static function patchBeforeBuildconf(BuilderBase $builder): void { - if ($builder->getExt('curl')) { - logger()->info('patching before-configure for curl checks'); - $file1 = "AC_DEFUN([PHP_CHECK_LIBRARY], [\n $3\n])"; - $files = FileSystem::readFile(SOURCE_PATH . '/php-src/ext/curl/config.m4'); - $file2 = 'AC_DEFUN([PHP_CHECK_LIBRARY], [ - save_old_LDFLAGS=$LDFLAGS - ac_stuff="$5" - - save_ext_shared=$ext_shared - ext_shared=yes - PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS) - AC_CHECK_LIB([$1],[$2],[ - LDFLAGS=$save_old_LDFLAGS - ext_shared=$save_ext_shared - $3 - ],[ - LDFLAGS=$save_old_LDFLAGS - ext_shared=$save_ext_shared - unset ac_cv_lib_$1[]_$2 - $4 - ])dnl -])'; - file_put_contents(SOURCE_PATH . '/php-src/ext/curl/config.m4', $file1 . "\n" . $files . "\n" . $file2); - } - - if ($builder->getExt('memcache')) { - FileSystem::replaceFile( - SOURCE_PATH . '/php-src/ext/memcache/config9.m4', - REPLACE_FILE_STR, - 'if test -d $abs_srcdir/src ; then', - 'if test -d $abs_srcdir/main ; then' - ); - FileSystem::replaceFile( - SOURCE_PATH . '/php-src/ext/memcache/config9.m4', - REPLACE_FILE_STR, - 'export CPPFLAGS="$CPPFLAGS $INCLUDES"', - 'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"' - ); - // add for in-tree building - file_put_contents( - SOURCE_PATH . '/php-src/ext/memcache/php_memcache.h', - <<<'EOF' -#ifndef PHP_MEMCACHE_H -#define PHP_MEMCACHE_H - -extern zend_module_entry memcache_module_entry; -#define phpext_memcache_ptr &memcache_module_entry - -#endif -EOF - ); - } - } - - public static function patchSwow(): bool - { - if (Util::getPHPVersionID() >= 80000) { - if (PHP_OS_FAMILY === 'Windows') { - f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && mklink /D swow swow-src\ext'); - } else { - f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && ln -s swow-src/ext swow'); + foreach ($builder->getExts() as $ext) { + if ($ext->patchBeforeBuildconf() === true) { + logger()->info('Extension [' . $ext->getName() . '] patched before buildconf'); } - return true; - } - return false; - } - - public static function patchPHPConfigure(BuilderBase $builder): void - { - $frameworks = $builder instanceof MacOSBuilder ? ' ' . $builder->getFrameworks(true) . ' ' : ''; - $patch = []; - if ($curl = $builder->getExt('curl')) { - $patch[] = ['curl check', '/-lcurl/', $curl->getLibFilesString() . $frameworks]; - } - if ($bzip2 = $builder->getExt('bz2')) { - $patch[] = ['bzip2 check', '/-lbz2/', $bzip2->getLibFilesString() . $frameworks]; - } - if ($pdo_sqlite = $builder->getExt('pdo_sqlite')) { - $patch[] = ['pdo_sqlite linking', '/sqlite3_column_table_name=yes/', 'sqlite3_column_table_name=no']; - } - if ($event = $builder->getExt('event')) { - $patch[] = ['event check', '/-levent_openssl/', $event->getLibFilesString()]; - } - if ($readline = $builder->getExt('readline')) { - $patch[] = ['readline patch', '/-lncurses/', $readline->getLibFilesString()]; - } - if ($ssh2 = $builder->getExt('ssh2')) { - $patch[] = ['ssh2 patch', '/-lssh2/', $ssh2->getLibFilesString()]; - } - if ($pgsql = $builder->getExt('pgsql')) { - $patch[] = ['pgsql patch', '/-lpq/', $pgsql->getLibFilesString()]; - } - $patch[] = ['disable capstone', '/have_capstone="yes"/', 'have_capstone="no"']; - foreach ($patch as $item) { - logger()->info('Patching configure: ' . $item[0]); - FileSystem::replaceFile(SOURCE_PATH . '/php-src/configure', REPLACE_FILE_PREG, $item[1], $item[2]); } } - public static function patchUnixLibpng(): void + /** + * Source patcher runner before configure + * + * @param BuilderBase $builder Builder + * @throws FileSystemException + */ + public static function patchBeforeConfigure(BuilderBase $builder): void { - FileSystem::replaceFile( - SOURCE_PATH . '/libpng/configure', - REPLACE_FILE_STR, - '-lz', - BUILD_LIB_PATH . '/libz.a' - ); - if (SystemUtil::getOSRelease()['dist'] === 'alpine') { - FileSystem::replaceFile( - SOURCE_PATH . '/libpng/configure', - REPLACE_FILE_STR, - '-lm', - '/usr/lib/libm.a' - ); + foreach ($builder->getExts() as $ext) { + if ($ext->patchBeforeConfigure() === true) { + logger()->info('Extension [' . $ext->getName() . '] patched before configure'); + } } - } - - public static function patchUnixSsh2(): void - { - FileSystem::replaceFile( - SOURCE_PATH . '/php-src/configure', - REPLACE_FILE_STR, - '-lssh2', - BUILD_LIB_PATH . '/libssh2.a' - ); - } - - public static function patchCurlMacOS(): void - { - FileSystem::replaceFile( - SOURCE_PATH . '/curl/CMakeLists.txt', - REPLACE_FILE_PREG, - '/NOT COREFOUNDATION_FRAMEWORK/m', - 'FALSE' - ); - FileSystem::replaceFile( - SOURCE_PATH . '/curl/CMakeLists.txt', - REPLACE_FILE_PREG, - '/NOT SYSTEMCONFIGURATION_FRAMEWORK/m', - 'FALSE' - ); + // patch capstone + FileSystem::replaceFile(SOURCE_PATH . '/php-src/configure', REPLACE_FILE_PREG, '/have_capstone="yes"/', 'have_capstone="no"'); } public static function patchMicro(?array $list = null, bool $reverse = false): bool @@ -244,19 +127,23 @@ EOF return false; } - public static function patchPHPAfterConfigure(BuilderBase $param) + /** + * @throws FileSystemException + */ + public static function patchBeforeMake(BuilderBase $builder): void { - if ($param instanceof LinuxBuilder) { + // Try to fix debian environment build lack HAVE_STRLCAT problem + if ($builder instanceof LinuxBuilder) { FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_STRLCPY 1$/m', ''); FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_STRLCAT 1$/m', ''); } FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_OPENPTY 1$/m', ''); - // patch openssl3 with php8.0 bug - if (file_exists(SOURCE_PATH . '/openssl/VERSION.dat') && Util::getPHPVersionID() < 80100) { - $openssl_c = file_get_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c'); - $openssl_c = preg_replace('/REGISTER_LONG_CONSTANT\s*\(\s*"OPENSSL_SSLV23_PADDING"\s*.+;/', '', $openssl_c); - file_put_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c', $openssl_c); + // call extension patch before make + foreach ($builder->getExts() as $ext) { + if ($ext->patchBeforeMake() === true) { + logger()->info('Extension [' . $ext->getName() . '] patched before make'); + } } } } From 51ce2befd8263a8edfa0a355f2c4e9cea3922388 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 28 Jul 2023 23:47:22 +0800 Subject: [PATCH 074/296] add library, extension patches in separate classes --- src/SPC/builder/extension/bz2.php | 25 ++++++++++++ src/SPC/builder/extension/curl.php | 52 ++++++++++++++++++++++++ src/SPC/builder/extension/event.php | 16 ++++++++ src/SPC/builder/extension/memcache.php | 31 ++++++++++++++ src/SPC/builder/extension/openssl.php | 25 ++++++++++++ src/SPC/builder/extension/pdo_sqlite.php | 28 +++++++++++++ src/SPC/builder/extension/pgsql.php | 28 +++++++++++++ src/SPC/builder/extension/readline.php | 28 +++++++++++++ src/SPC/builder/extension/ssh2.php | 28 +++++++++++++ src/SPC/builder/extension/swow.php | 14 +++++++ src/SPC/builder/linux/library/libpng.php | 26 +++++++++--- src/SPC/builder/macos/library/curl.php | 27 ++++++++---- 12 files changed, 316 insertions(+), 12 deletions(-) create mode 100644 src/SPC/builder/extension/bz2.php create mode 100644 src/SPC/builder/extension/curl.php create mode 100644 src/SPC/builder/extension/openssl.php create mode 100644 src/SPC/builder/extension/pdo_sqlite.php create mode 100644 src/SPC/builder/extension/pgsql.php create mode 100644 src/SPC/builder/extension/readline.php create mode 100644 src/SPC/builder/extension/ssh2.php diff --git a/src/SPC/builder/extension/bz2.php b/src/SPC/builder/extension/bz2.php new file mode 100644 index 00000000..c11060f1 --- /dev/null +++ b/src/SPC/builder/extension/bz2.php @@ -0,0 +1,25 @@ +builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; + FileSystem::replaceFile(SOURCE_PATH . '/php-src/configure', REPLACE_FILE_PREG, '/-lbz2/', $this->getLibFilesString() . $frameworks); + return true; + } +} diff --git a/src/SPC/builder/extension/curl.php b/src/SPC/builder/extension/curl.php new file mode 100644 index 00000000..c733efeb --- /dev/null +++ b/src/SPC/builder/extension/curl.php @@ -0,0 +1,52 @@ +info('patching before-configure for curl checks'); + $file1 = "AC_DEFUN([PHP_CHECK_LIBRARY], [\n $3\n])"; + $files = FileSystem::readFile(SOURCE_PATH . '/php-src/ext/curl/config.m4'); + $file2 = 'AC_DEFUN([PHP_CHECK_LIBRARY], [ + save_old_LDFLAGS=$LDFLAGS + ac_stuff="$5" + + save_ext_shared=$ext_shared + ext_shared=yes + PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS) + AC_CHECK_LIB([$1],[$2],[ + LDFLAGS=$save_old_LDFLAGS + ext_shared=$save_ext_shared + $3 + ],[ + LDFLAGS=$save_old_LDFLAGS + ext_shared=$save_ext_shared + unset ac_cv_lib_$1[]_$2 + $4 + ])dnl +])'; + file_put_contents(SOURCE_PATH . '/php-src/ext/curl/config.m4', $file1 . "\n" . $files . "\n" . $file2); + return true; + } + + /** + * @throws FileSystemException + */ + public function patchBeforeConfigure(): bool + { + $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; + FileSystem::replaceFile(SOURCE_PATH . '/php-src/configure', REPLACE_FILE_PREG, '/-lcurl/', $this->getLibFilesString() . $frameworks); + return true; + } +} diff --git a/src/SPC/builder/extension/event.php b/src/SPC/builder/extension/event.php index bee7553c..5dd0bf75 100644 --- a/src/SPC/builder/extension/event.php +++ b/src/SPC/builder/extension/event.php @@ -5,6 +5,8 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\exception\FileSystemException; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('event')] @@ -23,4 +25,18 @@ class event extends Extension } return $arg; } + + /** + * @throws FileSystemException + */ + public function patchBeforeConfigure(): bool + { + FileSystem::replaceFile( + SOURCE_PATH . '/php-src/configure', + REPLACE_FILE_PREG, + '/-levent_openssl/', + $this->getLibFilesString() + ); + return true; + } } diff --git a/src/SPC/builder/extension/memcache.php b/src/SPC/builder/extension/memcache.php index 2d2e2c94..38d00be0 100644 --- a/src/SPC/builder/extension/memcache.php +++ b/src/SPC/builder/extension/memcache.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('memcache')] @@ -14,4 +15,34 @@ class memcache extends Extension { return '--enable-memcache --with-zlib-dir=' . BUILD_ROOT_PATH; } + + public function patchBeforeBuildconf(): bool + { + FileSystem::replaceFile( + SOURCE_PATH . '/php-src/ext/memcache/config9.m4', + REPLACE_FILE_STR, + 'if test -d $abs_srcdir/src ; then', + 'if test -d $abs_srcdir/main ; then' + ); + FileSystem::replaceFile( + SOURCE_PATH . '/php-src/ext/memcache/config9.m4', + REPLACE_FILE_STR, + 'export CPPFLAGS="$CPPFLAGS $INCLUDES"', + 'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"' + ); + // add for in-tree building + file_put_contents( + SOURCE_PATH . '/php-src/ext/memcache/php_memcache.h', + <<<'EOF' +#ifndef PHP_MEMCACHE_H +#define PHP_MEMCACHE_H + +extern zend_module_entry memcache_module_entry; +#define phpext_memcache_ptr &memcache_module_entry + +#endif +EOF + ); + return true; + } } diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php new file mode 100644 index 00000000..447011da --- /dev/null +++ b/src/SPC/builder/extension/openssl.php @@ -0,0 +1,25 @@ +getLibFilesString() + ); + return true; + } +} diff --git a/src/SPC/builder/extension/readline.php b/src/SPC/builder/extension/readline.php new file mode 100644 index 00000000..a5b09ea8 --- /dev/null +++ b/src/SPC/builder/extension/readline.php @@ -0,0 +1,28 @@ +getLibFilesString() + ); + return true; + } +} diff --git a/src/SPC/builder/extension/ssh2.php b/src/SPC/builder/extension/ssh2.php new file mode 100644 index 00000000..cf966ae6 --- /dev/null +++ b/src/SPC/builder/extension/ssh2.php @@ -0,0 +1,28 @@ +getLibFilesString() + ); + return true; + } +} diff --git a/src/SPC/builder/extension/swow.php b/src/SPC/builder/extension/swow.php index 97b5c337..515a81e1 100644 --- a/src/SPC/builder/extension/swow.php +++ b/src/SPC/builder/extension/swow.php @@ -6,6 +6,7 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\util\CustomExt; +use SPC\util\Util; #[CustomExt('swow')] class swow extends Extension @@ -17,4 +18,17 @@ class swow extends Extension $arg .= $this->builder->getLib('curl') ? ' --enable-swow-curl' : ' --disable-swow-curl'; return $arg; } + + public function patchBeforeBuildconf(): bool + { + if (Util::getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) { + if (PHP_OS_FAMILY === 'Windows') { + f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && mklink /D swow swow-src\ext'); + } else { + f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && ln -s swow-src/ext swow'); + } + return true; + } + return false; + } } diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index 888c5bdc..54f3357c 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -20,14 +20,34 @@ declare(strict_types=1); namespace SPC\builder\linux\library; +use SPC\builder\linux\SystemUtil; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; -use SPC\store\SourcePatcher; +use SPC\store\FileSystem; class libpng extends LinuxLibraryBase { public const NAME = 'libpng'; + public function patchBeforeBuild(): bool + { + FileSystem::replaceFile( + SOURCE_PATH . '/libpng/configure', + REPLACE_FILE_STR, + '-lz', + BUILD_LIB_PATH . '/libz.a' + ); + if (SystemUtil::getOSRelease()['dist'] === 'alpine') { + FileSystem::replaceFile( + SOURCE_PATH . '/libpng/configure', + REPLACE_FILE_STR, + '-lm', + '/usr/lib/libm.a' + ); + } + return true; + } + /** * @throws RuntimeException * @throws FileSystemException @@ -39,10 +59,6 @@ class libpng extends LinuxLibraryBase 'arm64' => '--enable-arm-neon ', default => '', }; - - // patch configure - SourcePatcher::patchUnixLibpng(); - shell()->cd($this->source_dir) ->exec('chmod +x ./configure') ->exec('chmod +x ./install-sh') diff --git a/src/SPC/builder/macos/library/curl.php b/src/SPC/builder/macos/library/curl.php index 5432aa87..fa031de5 100644 --- a/src/SPC/builder/macos/library/curl.php +++ b/src/SPC/builder/macos/library/curl.php @@ -20,19 +20,32 @@ declare(strict_types=1); namespace SPC\builder\macos\library; -use SPC\store\SourcePatcher; +use SPC\exception\FileSystemException; +use SPC\store\FileSystem; class curl extends MacOSLibraryBase { - use \SPC\builder\unix\library\curl { - build as unixBuild; - } + use \SPC\builder\unix\library\curl; public const NAME = 'curl'; - protected function build() + /** + * @throws FileSystemException + */ + public function patchBeforeBuild(): bool { - SourcePatcher::patchCurlMacOS(); - $this->unixBuild(); + FileSystem::replaceFile( + SOURCE_PATH . '/curl/CMakeLists.txt', + REPLACE_FILE_PREG, + '/NOT COREFOUNDATION_FRAMEWORK/m', + 'FALSE' + ); + FileSystem::replaceFile( + SOURCE_PATH . '/curl/CMakeLists.txt', + REPLACE_FILE_PREG, + '/NOT SYSTEMCONFIGURATION_FRAMEWORK/m', + 'FALSE' + ); + return true; } } From 2a197487d588d7d63e4f1d7e1a23cadfcd19ad0e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 1 Aug 2023 23:43:57 +0800 Subject: [PATCH 075/296] add php 8.3 support for phpmicro --- src/SPC/store/SourcePatcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index ecd3f05d..c15a83b2 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -86,7 +86,7 @@ class SourcePatcher } $patch_list = $list ?? $default; $patches = []; - $serial = ['80', '81', '82']; + $serial = ['80', '81', '82', '83']; foreach ($patch_list as $patchName) { if (file_exists(SOURCE_PATH . "/php-src/sapi/micro/patches/{$patchName}.patch")) { $patches[] = "sapi/micro/patches/{$patchName}.patch"; From 460238a6b07baa8dfc0058c68452c9812ec0f164 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 2 Aug 2023 22:14:45 +0800 Subject: [PATCH 076/296] add hardcoded ini injection on build process --- src/SPC/command/BuildCliCommand.php | 12 +++++++ src/SPC/store/SourcePatcher.php | 52 +++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 298c0aa9..b6cf3461 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -7,6 +7,7 @@ namespace SPC\command; use SPC\builder\BuilderProvider; use SPC\exception\ExceptionHandler; use SPC\exception\WrongUsageException; +use SPC\store\SourcePatcher; use SPC\util\DependencyUtil; use SPC\util\LicenseDumper; use Symfony\Component\Console\Attribute\AsCommand; @@ -27,6 +28,7 @@ class BuildCliCommand extends BuildCommand $this->addOption('build-all', null, null, 'build cli, micro, fpm'); $this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions'); $this->addOption('enable-zts', null, null, 'enable ZTS support'); + $this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI'); } public function handle(): int @@ -72,6 +74,16 @@ class BuildCliCommand extends BuildCommand $builder->proveExts($extensions); // strip $builder->setStrip(!$this->getOption('no-strip')); + // Process -I option + $custom_ini = []; + foreach ($this->input->getOption('with-hardcoded-ini') as $value) { + [$source_name, $ini_value] = explode('=', $value, 2); + $custom_ini[$source_name] = $ini_value; + logger()->info('Adding hardcoded INI [' . $source_name . ' = ' . $ini_value . ']'); + } + if (!empty($custom_ini)) { + SourcePatcher::patchHardcodedINI($custom_ini); + } // 构建 $builder->buildPHP($rule, $this->getOption('bloat')); // 统计时间 diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index c15a83b2..4bcc8d31 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -146,4 +146,56 @@ class SourcePatcher } } } + + /** + * @throws FileSystemException + */ + public static function patchHardcodedINI(array $ini = []): bool + { + $cli_c = SOURCE_PATH . '/php-src/sapi/cli/php_cli.c'; + $cli_c_bak = SOURCE_PATH . '/php-src/sapi/cli/php_cli.c.bak'; + $micro_c = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c'; + $micro_c_bak = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c.bak'; + + // Try to reverse backup file + $find_pattern = 'const char HARDCODED_INI[] ='; + $patch_str = ''; + foreach ($ini as $key => $value) { + $patch_str .= "\"{$key}={$value}\\n\"\n"; + } + $patch_str = "const char HARDCODED_INI[] =\n{$patch_str}"; + + // Detect backup, if we have backup, it means we need to reverse first + if (file_exists($cli_c_bak) || file_exists($micro_c_bak)) { + self::unpatchHardcodedINI(); + } + + // Backup it + $result = file_put_contents($cli_c_bak, file_get_contents($cli_c)); + $result = $result && file_put_contents($micro_c_bak, file_get_contents($micro_c)); + if ($result === false) { + return false; + } + + // Patch it + FileSystem::replaceFile($cli_c, REPLACE_FILE_STR, $find_pattern, $patch_str); + FileSystem::replaceFile($micro_c, REPLACE_FILE_STR, $find_pattern, $patch_str); + return true; + } + + public static function unpatchHardcodedINI(): bool + { + $cli_c = SOURCE_PATH . '/php-src/sapi/cli/php_cli.c'; + $cli_c_bak = SOURCE_PATH . '/php-src/sapi/cli/php_cli.c.bak'; + $micro_c = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c'; + $micro_c_bak = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c.bak'; + if (!file_exists($cli_c_bak) && !file_exists($micro_c_bak)) { + return false; + } + $result = file_put_contents($cli_c, file_get_contents($cli_c_bak)); + $result = $result && file_put_contents($micro_c, file_get_contents($micro_c_bak)); + @unlink($cli_c_bak); + @unlink($micro_c_bak); + return $result; + } } From 7a1433a994cc066f34613b3b21e2df0269d3541b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Sat, 5 Aug 2023 21:53:46 +0200 Subject: [PATCH 077/296] Fix output of ExtractCommand --- src/SPC/command/ExtractCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/ExtractCommand.php b/src/SPC/command/ExtractCommand.php index 3a9f718a..f107bf5e 100644 --- a/src/SPC/command/ExtractCommand.php +++ b/src/SPC/command/ExtractCommand.php @@ -25,7 +25,7 @@ class ExtractCommand extends BaseCommand { $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); if (empty($sources)) { - $this->output->writeln('sources cannot be empty, at least contain one !'); + $this->output->writeln('sources cannot be empty, at least contain one !'); return 1; } SourceExtractor::initSource(sources: $sources); From a1e4125ded529b0c20ebdc1e91e8902e8c9f98ce Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 6 Aug 2023 10:43:20 +0800 Subject: [PATCH 078/296] replace symfony console return values --- src/SPC/ConsoleApplication.php | 2 +- src/SPC/command/BaseCommand.php | 6 +++--- src/SPC/command/BuildCliCommand.php | 8 ++++---- src/SPC/command/BuildLibsCommand.php | 4 ++-- src/SPC/command/DeployCommand.php | 6 +++--- src/SPC/command/DoctorCommand.php | 4 ++-- src/SPC/command/DownloadCommand.php | 14 +++++++------- src/SPC/command/DumpLicenseCommand.php | 8 ++++---- src/SPC/command/ExtractCommand.php | 4 ++-- src/SPC/command/ListExtCommand.php | 2 +- src/SPC/command/MicroCombineCommand.php | 16 ++++++++-------- src/SPC/command/SortConfigCommand.php | 2 +- src/SPC/command/dev/AllExtCommand.php | 3 +-- src/SPC/command/dev/ExtInfoCommand.php | 3 +-- src/SPC/command/dev/PhpVerCommand.php | 4 ++-- 15 files changed, 42 insertions(+), 44 deletions(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index db03abef..598bdd10 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -15,7 +15,7 @@ use Symfony\Component\Console\Command\ListCommand; */ class ConsoleApplication extends Application { - public const VERSION = '2.0-rc4'; + public const VERSION = '2.0-rc5'; /** * @throws \ReflectionException diff --git a/src/SPC/command/BaseCommand.php b/src/SPC/command/BaseCommand.php index 11ea6215..fe3775e1 100644 --- a/src/SPC/command/BaseCommand.php +++ b/src/SPC/command/BaseCommand.php @@ -91,7 +91,7 @@ abstract class BaseCommand extends Command foreach ($msg as $v) { logger()->error($v); } - return self::FAILURE; + return static::FAILURE; } catch (\Throwable $e) { // 不开 debug 模式就不要再显示复杂的调试栈信息了 if ($this->getOption('debug')) { @@ -102,10 +102,10 @@ abstract class BaseCommand extends Command logger()->error($v); } } - return self::FAILURE; + return static::FAILURE; } } - return self::SUCCESS; + return static::SUCCESS; } protected function getOption(string $name): mixed diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index b6cf3461..f1427ed6 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -51,7 +51,7 @@ class BuildCliCommand extends BuildCommand $this->output->writeln("\t--build-micro\tBuild phpmicro SAPI"); $this->output->writeln("\t--build-fpm\tBuild php-fpm SAPI"); $this->output->writeln("\t--build-all\tBuild all SAPI: cli, micro, fpm"); - return 1; + return static::FAILURE; } try { // 构建对象 @@ -113,10 +113,10 @@ class BuildCliCommand extends BuildCommand $dumper = new LicenseDumper(); $dumper->addExts($extensions)->addLibs($libraries)->addSources(['php-src'])->dump(BUILD_ROOT_PATH . '/license'); logger()->info('License path' . $fixed . ': ' . $build_root_path . '/license/'); - return 0; + return static::SUCCESS; } catch (WrongUsageException $e) { logger()->critical($e->getMessage()); - return 1; + return static::FAILURE; } catch (\Throwable $e) { if ($this->getOption('debug')) { ExceptionHandler::getInstance()->handle($e); @@ -124,7 +124,7 @@ class BuildCliCommand extends BuildCommand logger()->critical('Build failed with ' . get_class($e) . ': ' . $e->getMessage()); logger()->critical('Please check with --debug option to see more details.'); } - return 1; + return static::FAILURE; } } } diff --git a/src/SPC/command/BuildLibsCommand.php b/src/SPC/command/BuildLibsCommand.php index d4a23a2a..cc1471eb 100644 --- a/src/SPC/command/BuildLibsCommand.php +++ b/src/SPC/command/BuildLibsCommand.php @@ -63,7 +63,7 @@ class BuildLibsCommand extends BuildCommand $time = round(microtime(true) - START_TIME, 3); logger()->info('Build libs complete, used ' . $time . ' s !'); - return 0; + return static::SUCCESS; } catch (\Throwable $e) { if ($this->getOption('debug')) { ExceptionHandler::getInstance()->handle($e); @@ -71,7 +71,7 @@ class BuildLibsCommand extends BuildCommand logger()->critical('Build failed with ' . get_class($e) . ': ' . $e->getMessage()); logger()->critical('Please check with --debug option to see more details.'); } - return 1; + return static::FAILURE; } } } diff --git a/src/SPC/command/DeployCommand.php b/src/SPC/command/DeployCommand.php index dc97b035..0409f0b0 100644 --- a/src/SPC/command/DeployCommand.php +++ b/src/SPC/command/DeployCommand.php @@ -60,7 +60,7 @@ class DeployCommand extends BaseCommand $ask = $this->getOption('overwrite') ? true : $prompt->requireBool('The file "' . $phar_path . '" already exists, do you want to overwrite it?' . PHP_EOL . 'If you want to, just Enter'); if (!$ask) { $this->output->writeln('User canceled.'); - return 1; + return static::FAILURE; } @unlink($phar_path); } @@ -97,7 +97,7 @@ class DeployCommand extends BaseCommand $phar->setStub($phar->createDefaultStub($stub)); } catch (\Throwable $e) { $this->output->writeln($e); - return 1; + return static::FAILURE; } $phar->addFromString('.prod', 'true'); $phar->stopBuffering(); @@ -114,7 +114,7 @@ class DeployCommand extends BaseCommand } chmod($phar_path, 0755); $this->output->writeln('Phar Executable: ' . $phar_path . ''); - return 0; + return static::SUCCESS; } private function progress(int $max = 0): ProgressBar diff --git a/src/SPC/command/DoctorCommand.php b/src/SPC/command/DoctorCommand.php index 1db5e180..eacaf26b 100644 --- a/src/SPC/command/DoctorCommand.php +++ b/src/SPC/command/DoctorCommand.php @@ -24,8 +24,8 @@ class DoctorCommand extends BaseCommand } catch (\Throwable $e) { $this->output->writeln('' . $e->getMessage() . ''); pcntl_signal(SIGINT, SIG_IGN); - return 1; + return static::FAILURE; } - return 0; + return static::SUCCESS; } } diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 23522fda..9d2e05a8 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -68,14 +68,14 @@ class DownloadCommand extends BaseCommand f_passthru('rm -rf ' . DOWNLOAD_PATH . '/*'); f_passthru('rm -rf ' . BUILD_ROOT_PATH . '/*'); } - return 0; + return static::FAILURE; } // --from-zip if ($path = $this->getOption('from-zip')) { if (!file_exists($path)) { logger()->critical('File ' . $path . ' not exist or not a zip archive.'); - return 1; + return static::FAILURE; } // remove old download files first if (is_dir(DOWNLOAD_PATH)) { @@ -89,7 +89,7 @@ class DownloadCommand extends BaseCommand if (PHP_OS_FAMILY !== 'Windows' && !$this->findCommand('unzip')) { logger()->critical('Missing unzip command, you need to install it first !'); logger()->critical('You can use "bin/spc doctor" command to check and install required tools'); - return 1; + return static::FAILURE; } // create downloads try { @@ -103,10 +103,10 @@ class DownloadCommand extends BaseCommand } } catch (RuntimeException $e) { logger()->critical('Extract failed: ' . $e->getMessage()); - return 1; + return static::FAILURE; } logger()->info('Extract success'); - return 0; + return static::SUCCESS; } // Define PHP major version @@ -115,7 +115,7 @@ class DownloadCommand extends BaseCommand preg_match('/^\d+\.\d+$/', $ver, $matches); if (!$matches) { logger()->error("bad version arg: {$ver}, x.y required!"); - return 1; + return static::FAILURE; } // Use shallow-clone can reduce git resource download @@ -175,6 +175,6 @@ class DownloadCommand extends BaseCommand // 打印拉取资源用时 $time = round(microtime(true) - START_TIME, 3); logger()->info('Download complete, used ' . $time . ' s !'); - return 0; + return static::SUCCESS; } } diff --git a/src/SPC/command/DumpLicenseCommand.php b/src/SPC/command/DumpLicenseCommand.php index 00f6f3fd..ea4d377a 100644 --- a/src/SPC/command/DumpLicenseCommand.php +++ b/src/SPC/command/DumpLicenseCommand.php @@ -50,7 +50,7 @@ class DumpLicenseCommand extends BaseCommand $this->output->writeln('Dump license with libraries: ' . implode(', ', $libraries)); $this->output->writeln('Dump license with' . ($this->getOption('without-php') ? 'out' : '') . ' php-src'); $this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir')); - return 0; + return static::SUCCESS; } if ($this->getOption('by-libs') !== null) { $libraries = array_map('trim', array_filter(explode(',', $this->getOption('by-libs')))); @@ -58,16 +58,16 @@ class DumpLicenseCommand extends BaseCommand $dumper->addLibs($libraries); $dumper->dump($this->getOption('dump-dir')); $this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir')); - return 0; + return static::SUCCESS; } if ($this->getOption('by-sources') !== null) { $sources = array_map('trim', array_filter(explode(',', $this->getOption('by-sources')))); $dumper->addSources($sources); $dumper->dump($this->getOption('dump-dir')); $this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir')); - return 0; + return static::SUCCESS; } $this->output->writeln('You must use one of "--by-extensions=", "--by-libs=", "--by-sources=" to dump'); - return 1; + return static::FAILURE; } } diff --git a/src/SPC/command/ExtractCommand.php b/src/SPC/command/ExtractCommand.php index f107bf5e..e9c69fdd 100644 --- a/src/SPC/command/ExtractCommand.php +++ b/src/SPC/command/ExtractCommand.php @@ -26,10 +26,10 @@ class ExtractCommand extends BaseCommand $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); if (empty($sources)) { $this->output->writeln('sources cannot be empty, at least contain one !'); - return 1; + return static::FAILURE; } SourceExtractor::initSource(sources: $sources); logger()->info('Extract done !'); - return 0; + return static::SUCCESS; } } diff --git a/src/SPC/command/ListExtCommand.php b/src/SPC/command/ListExtCommand.php index f12466db..d8547f07 100644 --- a/src/SPC/command/ListExtCommand.php +++ b/src/SPC/command/ListExtCommand.php @@ -21,6 +21,6 @@ class ListExtCommand extends BaseCommand foreach (Config::getExts() as $ext => $meta) { echo $ext . PHP_EOL; } - return 0; + return static::SUCCESS; } } diff --git a/src/SPC/command/MicroCombineCommand.php b/src/SPC/command/MicroCombineCommand.php index 2da6df49..2c209033 100644 --- a/src/SPC/command/MicroCombineCommand.php +++ b/src/SPC/command/MicroCombineCommand.php @@ -35,12 +35,12 @@ class MicroCombineCommand extends BaseCommand // 1. Make sure specified micro.sfx file exists if ($micro_file !== null && !file_exists($micro_file)) { $this->output->writeln('The micro.sfx file you specified is incorrect or does not exist!'); - return 1; + return static::FAILURE; } // 2. Make sure buildroot/bin/micro.sfx exists if ($micro_file === null && !file_exists($internal)) { $this->output->writeln('You haven\'t compiled micro.sfx yet, please use "build" command and "--build-micro" to compile phpmicro first!'); - return 1; + return static::FAILURE; } // 3. Use buildroot/bin/micro.sfx if ($micro_file === null) { @@ -49,19 +49,19 @@ class MicroCombineCommand extends BaseCommand // 4. Make sure php or phar file exists if (!is_file(FileSystem::convertPath($file))) { $this->output->writeln('The file to combine does not exist!'); - return 1; + return static::FAILURE; } // 5. Confirm ini files (ini-set has higher priority) if ($ini_file !== null) { // Check file exist first if (!file_exists($ini_file)) { $this->output->writeln('The ini file to combine does not exist! (' . $ini_file . ')'); - return 1; + return static::FAILURE; } $arr = parse_ini_file($ini_file); if ($arr === false) { $this->output->writeln('Cannot parse ini file'); - return 1; + return static::FAILURE; } $target_ini = array_merge($target_ini, $arr); } @@ -71,7 +71,7 @@ class MicroCombineCommand extends BaseCommand $arr = parse_ini_string($item); if ($arr === false) { $this->output->writeln('--with-ini-set parse failed'); - return 1; + return static::FAILURE; } $target_ini = array_merge($target_ini, $arr); } @@ -90,12 +90,12 @@ class MicroCombineCommand extends BaseCommand $result = file_put_contents($output, $file_target); if ($result === false) { $this->output->writeln('Combine failed.'); - return 1; + return static::FAILURE; } // 9. chmod +x chmod($output, 0755); $this->output->writeln('Combine success! Binary file: ' . $output . ''); - return 0; + return static::SUCCESS; } private function encodeINI(array $array): string diff --git a/src/SPC/command/SortConfigCommand.php b/src/SPC/command/SortConfigCommand.php index 3de55770..579b2a89 100644 --- a/src/SPC/command/SortConfigCommand.php +++ b/src/SPC/command/SortConfigCommand.php @@ -52,6 +52,6 @@ class SortConfigCommand extends BaseCommand return 1; } $this->output->writeln('sort success'); - return 0; + return static::SUCCESS; } } diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index 253e1d79..e04a984d 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -18,7 +18,6 @@ class AllExtCommand extends BaseCommand public function handle(): int { $this->output->writeln(implode(',', array_keys(Config::getExts()))); - - return 0; + return static::SUCCESS; } } diff --git a/src/SPC/command/dev/ExtInfoCommand.php b/src/SPC/command/dev/ExtInfoCommand.php index d45478c8..1175b2af 100644 --- a/src/SPC/command/dev/ExtInfoCommand.php +++ b/src/SPC/command/dev/ExtInfoCommand.php @@ -37,7 +37,6 @@ class ExtInfoCommand extends BaseCommand } $this->output->writeln(''); } - - return 0; + return static::SUCCESS; } } diff --git a/src/SPC/command/dev/PhpVerCommand.php b/src/SPC/command/dev/PhpVerCommand.php index 9b729da2..b307f1c5 100644 --- a/src/SPC/command/dev/PhpVerCommand.php +++ b/src/SPC/command/dev/PhpVerCommand.php @@ -25,9 +25,9 @@ class PhpVerCommand extends BaseCommand $result = preg_match('/#define PHP_VERSION "([^"]+)"/', file_get_contents($file), $match); if ($result === false) { $this->output->writeln('PHP source not found, maybe you need to extract first ?'); - return 1; + return static::FAILURE; } $this->output->writeln('' . $match[1] . ''); - return 0; + return static::SUCCESS; } } From f2cfe33cddf1029f8887ca91cce7900e08af4dda Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 6 Aug 2023 12:29:16 +0800 Subject: [PATCH 079/296] remove gotop (Why I needed it?) --- src/SPC/doctor/item/MacOSToolCheckList.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index cf564863..0d12ecd3 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -29,7 +29,6 @@ class MacOSToolCheckList 'xz', 'gzip', 'bzip2', - 'gotop', 'cmake', ]; From cf6125b9ccdd56bcfffdb3dfce3f3f3745b5664c Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 7 Aug 2023 11:38:12 +0800 Subject: [PATCH 080/296] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1eabb465..d93e1065 100755 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. 截屏2023-05-02 15 52 33 -[![Version](https://img.shields.io/badge/Version-2.0--rc3-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc4-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) From 1ed104d2f6e7b10dbd9460e2d131a1043fe08fca Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 7 Aug 2023 11:38:22 +0800 Subject: [PATCH 081/296] Update README-en.md --- README-en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-en.md b/README-en.md index 7c83c2d8..62763100 100755 --- a/README-en.md +++ b/README-en.md @@ -11,7 +11,7 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro 截屏2023-05-02 15 52 33 -[![Version](https://img.shields.io/badge/Version-2.0--rc3-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc4-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) From 7298e2441b25e914c507a3d176518898818f7a11 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 8 Aug 2023 19:22:22 +0800 Subject: [PATCH 082/296] remove list-ext command, use all-ext and alias to support its function --- src/SPC/ConsoleApplication.php | 13 +++++++--- src/SPC/command/ListExtCommand.php | 26 ------------------- src/SPC/command/dev/AllExtCommand.php | 5 ++-- .../command/{ => dev}/SortConfigCommand.php | 22 +++++++++++----- 4 files changed, 28 insertions(+), 38 deletions(-) delete mode 100644 src/SPC/command/ListExtCommand.php rename src/SPC/command/{ => dev}/SortConfigCommand.php (59%) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 598bdd10..c9f1814e 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC; -use SPC\command\DeployCommand; use SPC\store\FileSystem; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\HelpCommand; @@ -32,13 +31,19 @@ class ConsoleApplication extends Application // 通过扫描目录 src/static-php-cli/command/ 添加子命令 $commands = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/command', 'SPC\\command'); - $this->addCommands(array_map(function ($x) { return new $x(); }, array_filter($commands, function ($y) { - if (is_a($y, DeployCommand::class, true) && (class_exists('\\Phar') && \Phar::running() || !class_exists('\\Phar'))) { + $phar = class_exists('\\Phar') && \Phar::running() || !class_exists('\\Phar'); + $commands = array_filter($commands, function ($y) use ($phar) { + $archive_blacklist = [ + 'SPC\command\dev\SortConfigCommand', + 'SPC\command\DeployCommand', + ]; + if ($phar && in_array($y, $archive_blacklist)) { return false; } $reflection = new \ReflectionClass($y); return !$reflection->isAbstract() && !$reflection->isInterface(); - }))); + }); + $this->addCommands(array_map(function ($x) { return new $x(); }, $commands)); } /** diff --git a/src/SPC/command/ListExtCommand.php b/src/SPC/command/ListExtCommand.php deleted file mode 100644 index d8547f07..00000000 --- a/src/SPC/command/ListExtCommand.php +++ /dev/null @@ -1,26 +0,0 @@ - $meta) { - echo $ext . PHP_EOL; - } - return static::SUCCESS; - } -} diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index e04a984d..c8a18495 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -8,16 +8,17 @@ use SPC\command\BaseCommand; use SPC\store\Config; use Symfony\Component\Console\Attribute\AsCommand; -#[AsCommand('dev:ext-all', 'Dev command')] +#[AsCommand('dev:ext-all', 'Dev command', ['list-ext'])] class AllExtCommand extends BaseCommand { public function configure() { + $this->addOption('line', 'l', null, 'Show with separate lines'); } public function handle(): int { - $this->output->writeln(implode(',', array_keys(Config::getExts()))); + $this->output->writeln(implode($this->input->getOption('line') ? PHP_EOL : ',', array_keys(Config::getExts()))); return static::SUCCESS; } } diff --git a/src/SPC/command/SortConfigCommand.php b/src/SPC/command/dev/SortConfigCommand.php similarity index 59% rename from src/SPC/command/SortConfigCommand.php rename to src/SPC/command/dev/SortConfigCommand.php index 579b2a89..39e32f31 100644 --- a/src/SPC/command/SortConfigCommand.php +++ b/src/SPC/command/dev/SortConfigCommand.php @@ -2,8 +2,9 @@ declare(strict_types=1); -namespace SPC\command; +namespace SPC\command\dev; +use SPC\command\BaseCommand; use SPC\exception\FileSystemException; use SPC\exception\ValidationException; use SPC\store\FileSystem; @@ -12,9 +13,9 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; /** - * 修改 config 后对其 kv 进行排序的操作 + * Modify config file: sort lib, ext, source by name. */ -#[AsCommand('sort-config', 'After config edited, sort it by alphabet')] +#[AsCommand('dev:sort-config', 'After config edited, sort it by alphabet', ['sort-config'])] class SortConfigCommand extends BaseCommand { public function configure() @@ -33,19 +34,28 @@ class SortConfigCommand extends BaseCommand $file = json_decode(FileSystem::readFile(ROOT_DIR . '/config/lib.json'), true); ConfigValidator::validateLibs($file); ksort($file); - file_put_contents(ROOT_DIR . '/config/lib.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); + if (!file_put_contents(ROOT_DIR . '/config/lib.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))) { + $this->output->writeln('Write file lib.json failed!'); + return static::FAILURE; + } break; case 'source': $file = json_decode(FileSystem::readFile(ROOT_DIR . '/config/source.json'), true); ConfigValidator::validateSource($file); uksort($file, fn ($a, $b) => $a === 'php-src' ? -1 : ($b === 'php-src' ? 1 : ($a < $b ? -1 : 1))); - file_put_contents(ROOT_DIR . '/config/source.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); + if (!file_put_contents(ROOT_DIR . '/config/source.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))) { + $this->output->writeln('Write file source.json failed!'); + return static::FAILURE; + } break; case 'ext': $file = json_decode(FileSystem::readFile(ROOT_DIR . '/config/ext.json'), true); ConfigValidator::validateExts($file); ksort($file); - file_put_contents(ROOT_DIR . '/config/ext.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); + if (!file_put_contents(ROOT_DIR . '/config/ext.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))) { + $this->output->writeln('Write file ext.json failed!'); + return static::FAILURE; + } break; default: $this->output->writeln("invalid config name: {$name}"); From 4bab7ecfab950fb2c8559780fdad1a0d72954a5c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 8 Aug 2023 20:23:38 +0800 Subject: [PATCH 083/296] add laravel/prompts support, and change deploy commands and exception handlers --- composer.json | 13 +++--- src/SPC/command/DeployCommand.php | 58 ++++++++++++++++++++------ src/SPC/exception/ExceptionHandler.php | 3 +- src/SPC/store/FileSystem.php | 23 +--------- 4 files changed, 54 insertions(+), 43 deletions(-) diff --git a/composer.json b/composer.json index c7b9f9f9..ea8e8baf 100644 --- a/composer.json +++ b/composer.json @@ -9,16 +9,15 @@ } ], "require": { - "php": ">= 8.0", - "ext-tokenizer": "*", - "ext-iconv": "*", + "php": ">= 8.1", + "ext-pcntl": "*", + "ext-mbstring": "*", + "laravel/prompts": "dev-main", "symfony/console": "^6 || ^5 || ^4", - "zhamao/logger": "^1.0", - "crazywhalecc/cli-helper": "^0.1.0", - "nunomaduro/collision": "*", - "ext-pcntl": "*" + "zhamao/logger": "^1.0" }, "require-dev": { + "nunomaduro/collision": "*", "friendsofphp/php-cs-fixer": "^3.2 != 3.7.0", "phpstan/phpstan": "^1.1", "captainhook/captainhook": "^5.10", diff --git a/src/SPC/command/DeployCommand.php b/src/SPC/command/DeployCommand.php index 0409f0b0..5dd5ddee 100644 --- a/src/SPC/command/DeployCommand.php +++ b/src/SPC/command/DeployCommand.php @@ -4,14 +4,15 @@ declare(strict_types=1); namespace SPC\command; -use CliHelper\Tools\ArgFixer; -use CliHelper\Tools\DataProvider; -use CliHelper\Tools\SeekableArrayIterator; +use SPC\store\FileSystem; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; +use function Laravel\Prompts\confirm; +use function Laravel\Prompts\text; + #[AsCommand('deploy', 'Deploy static-php-cli self to an .phar application')] class DeployCommand extends BaseCommand { @@ -20,26 +21,51 @@ class DeployCommand extends BaseCommand $this->addArgument('target', InputArgument::OPTIONAL, 'The file or directory to pack.'); $this->addOption('auto-phar-fix', null, InputOption::VALUE_NONE, 'Automatically fix ini option.'); $this->addOption('overwrite', 'W', InputOption::VALUE_NONE, 'Overwrite existing files.'); + $this->addOption('with-no-dev', 'D', InputOption::VALUE_NONE, 'Automatically use non-dev composer dependencies to reduce size'); + $this->addOption('with-dev', 'd', InputOption::VALUE_NONE, 'Automatically use dev composer dependencies'); } public function handle(): int { - // 第一阶段流程:如果没有写path,将会提示输入要打包的path - $prompt = new ArgFixer($this->input, $this->output); + $composer = require ROOT_DIR . '/vendor/composer/installed.php'; + if (($composer['root']['dev'] ?? false) === true) { + if (!$this->getOption('with-no-dev')) { + $this->output->writeln('Current static-php-cli dependencies have installed dev-dependencies'); + $this->output->writeln('If you want to remove, you can choose "Yes" to run command "composer update --no-dev" to remove.'); + $this->output->writeln('Or choose "No", just pack, deploy.'); + $ask = confirm('Do you want to remove dev-dependencies to reduce size of phar file?'); + } elseif (!$this->getOption('with-dev')) { + $ask = true; + } else { + $ask = false; + } + if ($ask) { + [$code] = shell()->execWithResult('composer update --no-dev'); + if ($code !== 0) { + $this->output->writeln('"composer update --no-dev" failed with exit code [' . $code . ']'); + $this->output->writeln('You may need to run this command by your own.'); + return static::FAILURE; + } + $this->output->writeln('Update successfully, you need to re-run deploy command to pack.'); + return static::SUCCESS; + } + } // 首先得确认是不是关闭了readonly模式 if (ini_get('phar.readonly') == 1) { if ($this->getOption('auto-phar-fix')) { $ask = true; } else { - $ask = $prompt->requireBool('pack command needs "phar.readonly" = "Off" !' . PHP_EOL . 'If you want to automatically set it and continue, just Enter', true); + $this->output->writeln('pack command needs "phar.readonly" = "Off" !'); + $ask = confirm('Do you want to automatically set it and continue ?'); + // $ask = $prompt->requireBool('pack command needs "phar.readonly" = "Off" !' . PHP_EOL . 'If you want to automatically set it and continue, just Enter', true); } if ($ask) { global $argv; - $args = array_merge(['-d', 'phar.readonly=0'], $_SERVER['argv']); + $args = array_merge(['-d', 'phar.readonly=0'], $_SERVER['argv'], ['--no-motd']); if (function_exists('pcntl_exec')) { $this->output->writeln('Changing to phar.readonly=0 mode ...'); if (pcntl_exec(PHP_BINARY, $args) === false) { - throw new \PharException('切换到读写模式失败,请检查环境。'); + throw new \PharException('Switching to read write mode failed, please check the environment.'); } } else { $this->output->writeln('Now running command in child process.'); @@ -51,13 +77,19 @@ class DeployCommand extends BaseCommand // 获取路径 $path = WORKING_DIR; // 如果是目录,则将目录下的所有文件打包 - $phar_path = $prompt->requireArgument('target', 'Please input the phar target filename', 'static-php-cli.phar'); + $phar_path = text('Please input the phar target filename', default: '/tmp/static-php-cli.phar'); + // $phar_path = $prompt->requireArgument('target', 'Please input the phar target filename', 'static-php-cli.phar'); - if (DataProvider::isRelativePath($phar_path)) { - $phar_path = '/tmp/' . $phar_path; + if (FileSystem::isRelativePath($phar_path)) { + $phar_path = WORKING_DIR . '/' . $phar_path; } if (file_exists($phar_path)) { - $ask = $this->getOption('overwrite') ? true : $prompt->requireBool('The file "' . $phar_path . '" already exists, do you want to overwrite it?' . PHP_EOL . 'If you want to, just Enter'); + if (!$this->getOption('overwrite')) { + $this->output->writeln('The file "' . $phar_path . '" already exists.'); + $ask = confirm('Do you want to overwrite it?'); + } else { + $ask = true; + } if (!$ask) { $this->output->writeln('User canceled.'); return static::FAILURE; @@ -67,7 +99,7 @@ class DeployCommand extends BaseCommand $phar = new \Phar($phar_path); $phar->startBuffering(); - $all = DataProvider::scanDirFiles($path, true, true); + $all = FileSystem::scanDirFiles($path, true, true); $all = array_filter($all, function ($x) { $dirs = preg_match('/(^(config|src|vendor)\\/|^(composer\\.json|README\\.md|source\\.json|LICENSE|README-en\\.md)$)/', $x); diff --git a/src/SPC/exception/ExceptionHandler.php b/src/SPC/exception/ExceptionHandler.php index 40773da3..0f03efba 100644 --- a/src/SPC/exception/ExceptionHandler.php +++ b/src/SPC/exception/ExceptionHandler.php @@ -47,7 +47,8 @@ class ExceptionHandler logger()->error($e->getTraceAsString()); return; } - $this->whoops->handleException($e); + + logger()->critical('You can report this exception to static-php-cli GitHub repo.'); } } diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index b8439dbe..ab0028ef 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -320,28 +320,7 @@ class FileSystem foreach ($files as $v) { $pathinfo = pathinfo($v); if (($pathinfo['extension'] ?? '') == 'php') { - $path = rtrim($dir, '/') . '/' . rtrim($pathinfo['dirname'], './') . '/' . $pathinfo['basename']; - - // 过滤不包含类的文件 - $tokens = token_get_all(self::readFile($path)); - $found = false; - foreach ($tokens as $token) { - if (!is_array($token)) { - continue; - } - if ($token[0] === T_CLASS) { - $found = true; - break; - } - } - if (!$found) { - continue; - } - - if ($rule === null) { // 规则未设置回调时候,使用默认的识别过滤规则 - /*if (substr(file_get_contents($dir . '/' . $v), 6, 6) == '#plain') { - continue; - }*/ + if ($rule === null) { if (file_exists($dir . '/' . $pathinfo['basename'] . '.ignore')) { continue; } From 75417d15b7cdb1a9ccb5660ef5102de09f2afa7b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 8 Aug 2023 20:29:10 +0800 Subject: [PATCH 084/296] change laravel/prompts version --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ea8e8baf..4249d0d2 100644 --- a/composer.json +++ b/composer.json @@ -10,9 +10,9 @@ ], "require": { "php": ">= 8.1", - "ext-pcntl": "*", "ext-mbstring": "*", - "laravel/prompts": "dev-main", + "ext-pcntl": "*", + "laravel/prompts": "^0.1.3", "symfony/console": "^6 || ^5 || ^4", "zhamao/logger": "^1.0" }, From a6f07051c307c7216e34e8ca19f88d9aa24b0fab Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 8 Aug 2023 20:35:25 +0800 Subject: [PATCH 085/296] update readme about version and dependencies --- README-en.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-en.md b/README-en.md index 62763100..6da42a4f 100755 --- a/README-en.md +++ b/README-en.md @@ -24,7 +24,7 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro ## Compilation Requirements Yes, this project is written in PHP, pretty funny. -But static-php-cli runtime only requires an environment above PHP 8.0 and `tokenizer`, `iconv` extension. +But static-php-cli runtime only requires an environment above PHP 8.1 and `mbstring`, `pcntl` extension. Here is the architecture support status, where `CI` represents support for GitHub Action builds, `Local` represents support for local builds, and blank represents not currently supported. diff --git a/README.md b/README.md index d93e1065..638db39a 100755 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. ## 编译环境需求 是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。 -但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 tokenizer 扩展和 PHP 版本大于等于 8.0 即可。 +但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 mbstring、pcntl 扩展和 PHP 版本大于等于 8.1 即可。 下面是架构支持情况,`CI` 代表支持 GitHub Action 构建,`Local` 代表支持本地构建,空 代表暂不支持。 From 61d1507a4d680a3947f3cfea47cb67e47615b190 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 9 Aug 2023 11:00:01 +0800 Subject: [PATCH 086/296] add redis-session support --- config/ext.json | 5 ++++- src/SPC/builder/extension/redis.php | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/ext.json b/config/ext.json index f227caf9..6e52f57c 100644 --- a/config/ext.json +++ b/config/ext.json @@ -298,7 +298,10 @@ "redis": { "type": "external", "source": "redis", - "arg-type": "custom" + "arg-type": "custom", + "ext-suggests": [ + "session" + ] }, "session": { "type": "builtin" diff --git a/src/SPC/builder/extension/redis.php b/src/SPC/builder/extension/redis.php index 0c0d6600..ffe50d1d 100644 --- a/src/SPC/builder/extension/redis.php +++ b/src/SPC/builder/extension/redis.php @@ -12,7 +12,12 @@ class redis extends Extension { public function getUnixConfigureArg(): string { - $arg = '--enable-redis --disable-redis-session'; + $arg = '--enable-redis'; + if (!$this->builder->getExt('session')) { + $arg .= ' --disable-redis-session'; + } else { + $arg .= ' --enable-redis-session'; + } if ($this->builder->getLib('zstd')) { $arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"'; } From b97327d6d752c66be7401e28de498cfb1298ec26 Mon Sep 17 00:00:00 2001 From: Chuong Date: Fri, 18 Aug 2023 13:02:24 +0700 Subject: [PATCH 087/296] mongodb source.json change from tgz to zip since ver https://github.com/mongodb/mongo-php-driver/releases/tag/1.16.2 they don't support tgz anymore. --- config/source.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/source.json b/config/source.json index a9ada593..b550587c 100644 --- a/config/source.json +++ b/config/source.json @@ -295,7 +295,7 @@ "type": "ghrel", "repo": "mongodb/mongo-php-driver", "path": "php-src/ext/mongodb", - "match": "mongodb.+\\.tgz", + "match": "mongodb.+\\.zip", "license": { "type": "file", "path": "LICENSE" @@ -467,4 +467,4 @@ "path": "LICENSE" } } -} \ No newline at end of file +} From 2bc02bdaac5302f76716dd54a8da50d9e09ad137 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 18 Aug 2023 18:17:52 +0800 Subject: [PATCH 088/296] add glfw support for macOS --- config/ext.json | 8 ++++++++ config/source.json | 9 +++++++++ src/SPC/builder/extension/glfw.php | 24 ++++++++++++++++++++++++ src/SPC/builder/macos/library/glfw.php | 21 +++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 src/SPC/builder/extension/glfw.php create mode 100644 src/SPC/builder/macos/library/glfw.php diff --git a/config/ext.json b/config/ext.json index 6e52f57c..df9da7fa 100644 --- a/config/ext.json +++ b/config/ext.json @@ -135,6 +135,14 @@ "imagemagick" ] }, + "glfw": { + "type": "external", + "arg-type": "custom", + "source": "ext-glfw", + "lib-depends": [ + "glfw" + ] + }, "imap": { "type": "builtin", "arg-type": "with", diff --git a/config/source.json b/config/source.json index b550587c..b4ba3e74 100644 --- a/config/source.json +++ b/config/source.json @@ -6,6 +6,15 @@ "path": "LICENSE" } }, + "ext-glfw": { + "type": "git", + "url": "https://github.com/mario-deluna/php-glfw", + "rev": "master", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "apcu": { "type": "url", "url": "https://pecl.php.net/get/APCu", diff --git a/src/SPC/builder/extension/glfw.php b/src/SPC/builder/extension/glfw.php new file mode 100644 index 00000000..7a52bb7c --- /dev/null +++ b/src/SPC/builder/extension/glfw.php @@ -0,0 +1,24 @@ +cd(SOURCE_PATH . '/ext-glfw/vendor/glfw') + ->exec("{$this->builder->configure_env} cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF") + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + // patch pkgconf + $this->patchPkgconfPrefix(['glfw3.pc']); + } +} From a00f8945ba6fcc263a4d8bd0078f432f5a1b4a73 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 18 Aug 2023 18:17:57 +0800 Subject: [PATCH 089/296] add glfw support for macOS --- config/lib.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config/lib.json b/config/lib.json index 41be5156..03ff7bb3 100644 --- a/config/lib.json +++ b/config/lib.json @@ -15,6 +15,18 @@ "brotli" ] }, + "glfw": { + "source": "ext-glfw", + "static-libs-unix": [ + "libglfw3.a" + ], + "frameworks": [ + "CoreVideo", + "OpenGL", + "Cocoa", + "IOKit" + ] + }, "bzip2": { "source": "bzip2", "static-libs-unix": [ From cf22949f3b8f2585f1c988a3231e8fefff4f7cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 20 Aug 2023 14:23:29 +0200 Subject: [PATCH 090/296] minor: prevent warning when installing cmake with Homebrew --- src/SPC/doctor/item/MacOSToolCheckList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index 0d12ecd3..df1e6ed4 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -73,7 +73,7 @@ class MacOSToolCheckList { foreach ($missing as $cmd) { try { - shell(true)->exec('brew install ' . escapeshellarg($cmd)); + shell(true)->exec('brew install --formula ' . escapeshellarg($cmd)); } catch (RuntimeException) { return false; } From 585826b438c569122d30072b719b4215e57f2bb3 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 20 Aug 2023 20:32:07 +0800 Subject: [PATCH 091/296] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 638db39a..503498e0 100755 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. 截屏2023-05-02 15 52 33 -[![Version](https://img.shields.io/badge/Version-2.0--rc4-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc5-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) From 9c57ed6439d6c836b8ecc60bbebcb69b90376742 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 20 Aug 2023 20:32:28 +0800 Subject: [PATCH 092/296] Update README-en.md --- README-en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-en.md b/README-en.md index 6da42a4f..c5108c21 100755 --- a/README-en.md +++ b/README-en.md @@ -11,7 +11,7 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro 截屏2023-05-02 15 52 33 -[![Version](https://img.shields.io/badge/Version-2.0--rc4-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc5-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) From c8fa767576f43ab81ba57546a75903e8bf8a4dd3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 20 Aug 2023 19:51:45 +0800 Subject: [PATCH 093/296] Do some code quality check and fix #126 --- bin/setup-runtime | 18 +- bin/spc | 8 +- bin/spc-alpine-docker | 12 +- config/ext.json | 44 ++-- config/lib.json | 38 +-- config/source.json | 58 ++--- src/SPC/ConsoleApplication.php | 11 +- src/SPC/builder/BuilderBase.php | 131 ++++++---- src/SPC/builder/BuilderProvider.php | 18 +- src/SPC/builder/Extension.php | 3 +- src/SPC/builder/LibraryBase.php | 81 +++--- src/SPC/builder/extension/bz2.php | 4 +- src/SPC/builder/extension/curl.php | 7 +- src/SPC/builder/extension/event.php | 7 +- src/SPC/builder/extension/glfw.php | 4 + src/SPC/builder/extension/iconv.php | 23 ++ src/SPC/builder/extension/imagick.php | 11 + src/SPC/builder/extension/memcache.php | 10 +- src/SPC/builder/extension/pdo_sqlite.php | 3 +- src/SPC/builder/extension/pgsql.php | 3 +- src/SPC/builder/extension/readline.php | 3 +- src/SPC/builder/extension/ssh2.php | 3 +- src/SPC/builder/extension/swow.php | 4 + src/SPC/builder/linux/LinuxBuilder.php | 244 +++++++++--------- src/SPC/builder/linux/SystemUtil.php | 8 +- .../linux/library/LinuxLibraryBase.php | 6 +- src/SPC/builder/linux/library/icu.php | 2 +- src/SPC/builder/linux/library/libpng.php | 19 +- src/SPC/builder/linux/library/libxml2.php | 6 +- src/SPC/builder/linux/library/nghttp2.php | 13 +- src/SPC/builder/linux/library/openssl.php | 16 +- src/SPC/builder/macos/MacOSBuilder.php | 169 ++++++------ src/SPC/builder/macos/SystemUtil.php | 9 +- .../macos/library/MacOSLibraryBase.php | 5 +- src/SPC/builder/macos/library/curl.php | 6 +- src/SPC/builder/macos/library/glfw.php | 9 +- src/SPC/builder/macos/library/icu.php | 2 +- src/SPC/builder/macos/library/libffi.php | 31 +-- .../builder/macos/library/libmemcached.php | 2 +- src/SPC/builder/macos/library/libpng.php | 8 +- src/SPC/builder/macos/library/libxml2.php | 15 +- src/SPC/builder/macos/library/nghttp2.php | 11 +- src/SPC/builder/macos/library/openssl.php | 13 +- src/SPC/builder/traits/UnixBuilderTrait.php | 24 +- src/SPC/builder/traits/UnixLibraryTrait.php | 9 +- .../builder/traits/UnixSystemUtilTrait.php | 28 +- src/SPC/builder/unix/library/brotli.php | 6 + src/SPC/builder/unix/library/curl.php | 8 +- src/SPC/builder/unix/library/freetype.php | 13 +- src/SPC/builder/unix/library/gmp.php | 9 +- src/SPC/builder/unix/library/imagemagick.php | 9 +- src/SPC/builder/unix/library/libavif.php | 10 +- src/SPC/builder/unix/library/libevent.php | 9 +- src/SPC/builder/unix/library/libiconv.php | 2 +- src/SPC/builder/unix/library/libjpeg.php | 10 +- src/SPC/builder/unix/library/libsodium.php | 2 +- src/SPC/builder/unix/library/libssh2.php | 8 +- src/SPC/builder/unix/library/libwebp.php | 11 +- src/SPC/builder/unix/library/libyaml.php | 4 +- src/SPC/builder/unix/library/libzip.php | 8 +- src/SPC/builder/unix/library/ncurses.php | 2 +- src/SPC/builder/unix/library/onig.php | 9 +- src/SPC/builder/unix/library/pkgconfig.php | 16 +- src/SPC/builder/unix/library/postgresql.php | 2 +- src/SPC/builder/unix/library/readline.php | 9 +- src/SPC/builder/unix/library/sqlite.php | 2 +- src/SPC/builder/unix/library/xz.php | 11 +- src/SPC/builder/unix/library/zlib.php | 9 +- src/SPC/builder/unix/library/zstd.php | 8 +- src/SPC/command/BaseCommand.php | 21 +- src/SPC/command/BuildCliCommand.php | 36 +-- src/SPC/command/BuildCommand.php | 3 - src/SPC/command/BuildLibsCommand.php | 4 +- src/SPC/command/DeployCommand.php | 9 +- src/SPC/command/DoctorCommand.php | 2 +- src/SPC/command/DownloadCommand.php | 4 +- src/SPC/command/DumpLicenseCommand.php | 4 +- src/SPC/command/ExtractCommand.php | 12 +- src/SPC/command/MicroCombineCommand.php | 2 +- src/SPC/command/dev/AllExtCommand.php | 6 +- src/SPC/command/dev/ExtInfoCommand.php | 10 +- src/SPC/command/dev/PhpVerCommand.php | 2 +- src/SPC/command/dev/SortConfigCommand.php | 2 +- src/SPC/doctor/CheckListHandler.php | 10 +- src/SPC/doctor/CheckResult.php | 4 +- src/SPC/doctor/item/LinuxMuslCheck.php | 6 +- src/SPC/doctor/item/LinuxToolCheckList.php | 6 + src/SPC/exception/ExceptionHandler.php | 12 +- src/SPC/store/Config.php | 5 +- src/SPC/store/CurlHook.php | 2 +- src/SPC/store/Downloader.php | 121 +++------ src/SPC/store/FileSystem.php | 73 ++++-- src/SPC/store/SourceExtractor.php | 7 + src/SPC/store/SourcePatcher.php | 32 +-- src/SPC/store/source/PhpSource.php | 4 +- src/SPC/store/source/PostgreSQLSource.php | 15 +- src/SPC/util/ConfigValidator.php | 8 +- src/SPC/util/DependencyUtil.php | 11 +- src/SPC/util/Patcher.php | 12 +- src/SPC/util/UnixShell.php | 3 + src/globals/defines.php | 15 +- src/globals/functions.php | 22 +- src/globals/tests/bcmath.php | 2 - src/globals/tests/dom.php | 2 - 104 files changed, 1040 insertions(+), 785 deletions(-) create mode 100644 src/SPC/builder/extension/iconv.php diff --git a/bin/setup-runtime b/bin/setup-runtime index 48144f97..06ebd749 100755 --- a/bin/setup-runtime +++ b/bin/setup-runtime @@ -22,7 +22,7 @@ esac # set project dir __DIR__=$(cd "$(dirname "$0")" && pwd) -__PROJECT__=$(cd ${__DIR__}/../ && pwd) +__PROJECT__=$(cd "${__DIR__}"/../ && pwd) # set download dir __PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.6-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" @@ -52,17 +52,17 @@ china) esac -test -d ${__PROJECT__}/downloads || mkdir ${__PROJECT__}/downloads +test -d "${__PROJECT__}"/downloads || mkdir "${__PROJECT__}"/downloads # download static php binary -test -f ${__PROJECT__}/downloads/runtime.tar.gz || { echo "Downloading $__PHP_RUNTIME_URL__ ..." && curl -#fSL -o ${__PROJECT__}/downloads/runtime.tar.gz "$__PHP_RUNTIME_URL__" ; } -test -f ${__DIR__}/php || { tar -xf ${__PROJECT__}/downloads/runtime.tar.gz -C ${__DIR__}/ ; } -chmod +x ${__DIR__}/php +test -f "${__PROJECT__}"/downloads/runtime.tar.gz || { echo "Downloading $__PHP_RUNTIME_URL__ ..." && curl -#fSL -o "${__PROJECT__}"/downloads/runtime.tar.gz "$__PHP_RUNTIME_URL__" ; } +test -f "${__DIR__}"/php || { tar -xf "${__PROJECT__}"/downloads/runtime.tar.gz -C "${__DIR__}"/ ; } +chmod +x "${__DIR__}"/php # download composer -test -f ${__DIR__}/composer || curl -#fSL -o ${__DIR__}/composer "$__COMPOSER_URL__" -chmod +x ${__DIR__}/composer +test -f "${__DIR__}"/composer || curl -#fSL -o "${__DIR__}"/composer "$__COMPOSER_URL__" +chmod +x "${__DIR__}"/composer # sanity check for php and composer -${__DIR__}/php -v >/dev/null || { echo "Failed to run php" && exit 1; } -${__DIR__}/php ${__DIR__}/composer --version >/dev/null || { echo "Failed to run composer" && exit 1; } +"${__DIR__}"/php -v >/dev/null || { echo "Failed to run php" && exit 1; } +"${__DIR__}"/php "${__DIR__}"/composer --version >/dev/null || { echo "Failed to run composer" && exit 1; } echo "Setup runtime OK!" echo "runtime bin path needs to add manually by command below:" diff --git a/bin/spc b/bin/spc index 960f24ff..58749f61 100755 --- a/bin/spc +++ b/bin/spc @@ -1,6 +1,9 @@ #!/usr/bin/env php run(); + (new ConsoleApplication())->run(); } catch (Exception $e) { - \SPC\exception\ExceptionHandler::getInstance()->handle($e); + ExceptionHandler::getInstance()->handle($e); } diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index 7f444426..3d135791 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -2,18 +2,18 @@ # This file is using docker to run commands -self_dir=$(cd "$(dirname "$0")";pwd) - # Detect docker can run if ! which docker >/dev/null; then echo "Docker is not installed, please install docker first !" exit 1 fi DOCKER_EXECUTABLE="docker" +# shellcheck disable=SC2046 if [ $(id -u) -ne 0 ]; then if ! docker info > /dev/null 2>&1; then if [ "$SPC_USE_SUDO" != "yes" ]; then echo "Docker command requires sudo" + # shellcheck disable=SC2039 echo -n 'To use sudo to run docker, run "export SPC_USE_SUDO=yes" and run command again' exit 1 fi @@ -33,6 +33,7 @@ x86_64) ;; aarch64) ALPINE_FROM=multiarch/alpine:aarch64-edge + # shellcheck disable=SC2039 echo -e "\e[033m* Using different arch needs to setup qemu-static for docker !\e[0m" $DOCKER_EXECUTABLE run --rm --privileged multiarch/qemu-user-static:register --reset > /dev/null ;; @@ -65,10 +66,10 @@ ADD ./bin /app/bin RUN composer update --no-dev EOF ) - echo "$ALPINE_DOCKERFILE" > $(pwd)/Dockerfile + echo "$ALPINE_DOCKERFILE" > "$(pwd)"/Dockerfile $DOCKER_EXECUTABLE build -t cwcc-spc-$SPC_USE_ARCH . - rm $(pwd)/Dockerfile + rm "$(pwd)"/Dockerfile fi # Check if in ci (local terminal can execute with -it) @@ -79,4 +80,5 @@ else fi # Run docker -$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT=$(pwd) -v $(pwd)/config:/app/config -v $(pwd)/src:/app/src -v $(pwd)/buildroot:/app/buildroot -v $(pwd)/source:/app/source -v $(pwd)/downloads:/app/downloads cwcc-spc-$SPC_USE_ARCH bin/spc $@ +# shellcheck disable=SC2068 +$DOCKER_EXECUTABLE run --rm "$INTERACT" -e SPC_FIX_DEPLOY_ROOT="$(pwd)" -v "$(pwd)"/config:/app/config -v "$(pwd)"/src:/app/src -v "$(pwd)"/buildroot:/app/buildroot -v "$(pwd)"/source:/app/source -v "$(pwd)"/downloads:/app/downloads cwcc-spc-$SPC_USE_ARCH bin/spc $@ diff --git a/config/ext.json b/config/ext.json index df9da7fa..3bac3fa0 100644 --- a/config/ext.json +++ b/config/ext.json @@ -53,19 +53,6 @@ "sockets" ] }, - "memcached": { - "type": "external", - "source": "memcached", - "arg-type": "custom", - "cpp-extension": true, - "lib-depends": [ - "libmemcached" - ], - "ext-depends": [ - "session", - "zlib" - ] - }, "exif": { "type": "builtin" }, @@ -113,6 +100,14 @@ "gettext" ] }, + "glfw": { + "type": "external", + "arg-type": "custom", + "source": "ext-glfw", + "lib-depends": [ + "glfw" + ] + }, "gmp": { "type": "builtin", "arg-type": "with-prefix", @@ -135,14 +130,6 @@ "imagemagick" ] }, - "glfw": { - "type": "external", - "arg-type": "custom", - "source": "ext-glfw", - "lib-depends": [ - "glfw" - ] - }, "imap": { "type": "builtin", "arg-type": "with", @@ -196,6 +183,19 @@ "session" ] }, + "memcached": { + "type": "external", + "source": "memcached", + "arg-type": "custom", + "cpp-extension": true, + "lib-depends": [ + "libmemcached" + ], + "ext-depends": [ + "session", + "zlib" + ] + }, "mongodb": { "type": "external", "source": "mongodb", @@ -485,4 +485,4 @@ "zstd" ] } -} +} \ No newline at end of file diff --git a/config/lib.json b/config/lib.json index 03ff7bb3..d07a069a 100644 --- a/config/lib.json +++ b/config/lib.json @@ -15,18 +15,6 @@ "brotli" ] }, - "glfw": { - "source": "ext-glfw", - "static-libs-unix": [ - "libglfw3.a" - ], - "frameworks": [ - "CoreVideo", - "OpenGL", - "Cocoa", - "IOKit" - ] - }, "bzip2": { "source": "bzip2", "static-libs-unix": [ @@ -96,6 +84,18 @@ "brotli" ] }, + "glfw": { + "source": "ext-glfw", + "static-libs-unix": [ + "libglfw3.a" + ], + "frameworks": [ + "CoreVideo", + "OpenGL", + "Cocoa", + "IOKit" + ] + }, "gmp": { "source": "gmp", "static-libs-unix": [ @@ -200,6 +200,13 @@ "libmcrypt.a" ] }, + "libmemcached": { + "source": "libmemcached", + "static-libs-unix": [ + "libmemcached.a", + "libmemcachedutil.a" + ] + }, "libpng": { "source": "libpng", "static-libs-unix": [ @@ -474,13 +481,6 @@ "zconf.h" ] }, - "libmemcached": { - "source": "libmemcached", - "static-libs-unix": [ - "libmemcached.a", - "libmemcachedutil.a" - ] - }, "zstd": { "source": "zstd", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index b4ba3e74..e1fa90ad 100644 --- a/config/source.json +++ b/config/source.json @@ -6,15 +6,6 @@ "path": "LICENSE" } }, - "ext-glfw": { - "type": "git", - "url": "https://github.com/mario-deluna/php-glfw", - "rev": "master", - "license": { - "type": "file", - "path": "LICENSE" - } - }, "apcu": { "type": "url", "url": "https://pecl.php.net/get/APCu", @@ -25,25 +16,6 @@ "path": "LICENSE" } }, - "memcached": { - "type": "url", - "url": "https://pecl.php.net/get/memcached", - "path": "php-src/ext/memcached", - "filename": "memcached.tgz", - "license": { - "type": "file", - "path": "LICENSE" - } - }, - "libmemcached": { - "type": "git", - "url": "https://github.com/crazywhalecc/libmemcached-macos.git", - "rev": "master", - "license": { - "type": "file", - "path": "COPYING" - } - }, "brotli": { "type": "ghtar", "repo": "google/brotli", @@ -79,6 +51,15 @@ "path": "LICENSE" } }, + "ext-glfw": { + "type": "git", + "url": "https://github.com/mario-deluna/php-glfw", + "rev": "master", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-imagick": { "type": "url", "url": "https://pecl.php.net/get/imagick", @@ -213,6 +194,15 @@ "path": "COPYING" } }, + "libmemcached": { + "type": "git", + "url": "https://github.com/crazywhalecc/libmemcached-macos.git", + "rev": "master", + "license": { + "type": "file", + "path": "COPYING" + } + }, "libpng": { "type": "git", "url": "https://git.code.sf.net/p/libpng/code", @@ -290,6 +280,16 @@ "path": "COPYING" } }, + "memcached": { + "type": "url", + "url": "https://pecl.php.net/get/memcached", + "path": "php-src/ext/memcached", + "filename": "memcached.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "micro": { "type": "git", "path": "php-src/sapi/micro", @@ -476,4 +476,4 @@ "path": "LICENSE" } } -} +} \ No newline at end of file diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index c9f1814e..b687278e 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -10,11 +10,11 @@ use Symfony\Component\Console\Command\HelpCommand; use Symfony\Component\Console\Command\ListCommand; /** - * spc 应用究级入口 + * static-php-cli console app entry */ class ConsoleApplication extends Application { - public const VERSION = '2.0-rc5'; + public const VERSION = '2.0.0'; /** * @throws \ReflectionException @@ -26,10 +26,10 @@ class ConsoleApplication extends Application global $argv; - // 生产环境不显示详细的调试错误,只使用 symfony console 自带的错误显示 + // Detailed debugging errors are not displayed in the production environment. Only the error display provided by Symfony console is used. $this->setCatchExceptions(file_exists(ROOT_DIR . '/.prod') || !in_array('--debug', $argv)); - // 通过扫描目录 src/static-php-cli/command/ 添加子命令 + // Add subcommands by scanning the directory src/static-php-cli/command/ $commands = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/command', 'SPC\\command'); $phar = class_exists('\\Phar') && \Phar::running() || !class_exists('\\Phar'); $commands = array_filter($commands, function ($y) use ($phar) { @@ -46,9 +46,6 @@ class ConsoleApplication extends Application $this->addCommands(array_map(function ($x) { return new $x(); }, $commands)); } - /** - * 重载以去除一些不必要的默认命令 - */ protected function getDefaultCommands(): array { return [new HelpCommand(), new ListCommand()]; diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index e6763049..1c3c84fb 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -15,43 +15,32 @@ use SPC\util\DependencyUtil; abstract class BuilderBase { - /** @var bool 是否启用 ZTS 线程安全 */ - public bool $zts = false; - - /** @var string 编译目标架构 */ - public string $arch; - - /** @var string GNU 格式的编译目标架构 */ - public string $gnu_arch; - - /** @var int 编译进程数 */ + /** @var int Concurrency */ public int $concurrency = 1; - /** @var array 要编译的 libs 列表 */ + /** @var array libraries */ protected array $libs = []; - /** @var array 要编译的扩展列表 */ + /** @var array extensions */ protected array $exts = []; - /** @var array 要编译的扩展列表(仅名字列表,用于最后生成编译的扩展列表给 micro) */ - protected array $plain_extensions = []; - - /** @var bool 本次编译是否只编译 libs,不编译 PHP */ + /** @var bool compile libs only (just mark it) */ protected bool $libs_only = false; - /** @var bool 是否 strip 最终的二进制 */ - protected bool $strip = true; + /** @var array compile options */ + protected array $options = []; /** - * 构建指定列表的 libs + * Build libraries * + * @param array $libraries Libraries to build * @throws FileSystemException * @throws RuntimeException * @throws WrongUsageException */ public function buildLibs(array $libraries): void { - // 通过扫描目录查找 lib + // search all supported libs $support_lib_list = []; $classes = FileSystem::getClassesPsr4( ROOT_DIR . '/src/SPC/builder/' . osfamily2dir() . '/library', @@ -63,19 +52,22 @@ abstract class BuilderBase } } - // 如果传入了空,则默认检查和安置所有支持的lib,libraries为要build的,support_lib_list为支持的列表 + // if no libs specified, compile all supported libs if ($libraries === [] && $this->isLibsOnly()) { $libraries = array_keys($support_lib_list); } + + // pkg-config must be compiled first, whether it is specified or not if (!in_array('pkg-config', $libraries)) { array_unshift($libraries, 'pkg-config'); } - // 排序 libs,根据依赖计算一个新的列表出来 + // append dependencies $libraries = DependencyUtil::getLibsByDeps($libraries); - // 过滤不支持的库后添加 + // add lib object for builder foreach ($libraries as $library) { + // if some libs are not supported (but in config "lib.json", throw exception) if (!isset($support_lib_list[$library])) { throw new RuntimeException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!'); } @@ -83,14 +75,15 @@ abstract class BuilderBase $this->addLib($lib); } - // 计算依赖,经过这里的遍历,如果没有抛出异常,说明依赖符合要求,可以继续下面的 + // calculate and check dependencies foreach ($this->libs as $lib) { $lib->calcDependency(); } + // extract sources SourceExtractor::initSource(libs: $libraries); - // 构建库 + // build all libs foreach ($this->libs as $lib) { match ($lib->tryBuild()) { BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'), @@ -102,9 +95,9 @@ abstract class BuilderBase } /** - * 添加要编译的 Lib 库 + * Add library to build. * - * @param LibraryBase $library Lib 库对象 + * @param LibraryBase $library Library object */ public function addLib(LibraryBase $library): void { @@ -112,9 +105,7 @@ abstract class BuilderBase } /** - * 获取要编译的 Lib 库对象 - * - * @param string $name 库名称 + * Get library object by name. */ public function getLib(string $name): ?LibraryBase { @@ -122,9 +113,7 @@ abstract class BuilderBase } /** - * 添加要编译的扩展 - * - * @param Extension $extension 扩展对象 + * Add extension to build. */ public function addExt(Extension $extension): void { @@ -132,9 +121,7 @@ abstract class BuilderBase } /** - * 获取要编译的扩展对象 - * - * @param string $name 扩展名称 + * Get extension object by name. */ public function getExt(string $name): ?Extension { @@ -142,7 +129,7 @@ abstract class BuilderBase } /** - * 获取所有要编译的扩展对象 + * Get all extension objects. * * @return Extension[] */ @@ -152,10 +139,9 @@ abstract class BuilderBase } /** - * 检查 C++ 扩展是否存在 + * Check if there is a cpp extension. * * @throws FileSystemException - * @throws RuntimeException * @throws WrongUsageException */ public function hasCppExtension(): bool @@ -173,7 +159,7 @@ abstract class BuilderBase } /** - * 设置本次 Builder 是否为仅编译库的模式 + * Set libs only mode. */ public function setLibsOnly(bool $status = true): void { @@ -181,7 +167,7 @@ abstract class BuilderBase } /** - * 检验 ext 扩展列表是否合理,并声明 Extension 对象,检查扩展的依赖 + * Verify the list of "ext" extensions for validity and declare an Extension object to check the dependencies of the extensions. * * @throws FileSystemException * @throws RuntimeException @@ -203,26 +189,21 @@ abstract class BuilderBase } foreach ($this->exts as $ext) { - // 检查下依赖就行了,作用是导入依赖给 Extension 对象,今后可以对库依赖进行选择性处理 $ext->checkDependency(); } - - $this->plain_extensions = $extensions; } /** - * 开始构建 PHP + * Start to build PHP * - * @param int $build_target 规则 - * @param bool $bloat 保留 + * @param int $build_target Build target, see BUILD_TARGET_* */ - abstract public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $bloat = false); + abstract public function buildPHP(int $build_target = BUILD_TARGET_NONE); /** - * 生成依赖的扩展编译启用参数 - * 例如 --enable-mbstring 等 + * Generate extension enable arguments for configure. + * e.g. --enable-mbstring * - * @throws RuntimeException * @throws FileSystemException * @throws WrongUsageException */ @@ -237,7 +218,7 @@ abstract class BuilderBase } /** - * 返回是否只编译 libs 的模式 + * Get libs only mode. */ public function isLibsOnly(): bool { @@ -245,7 +226,7 @@ abstract class BuilderBase } /** - * 获取当前即将编译的 PHP 的版本 ID,五位数那个 + * Get PHP Version ID from php-src/main/php_version.h */ public function getPHPVersionID(): int { @@ -254,6 +235,11 @@ abstract class BuilderBase return intval($match[1]); } + /** + * Get build type name string to display. + * + * @param int $type Build target type + */ public function getBuildTypeName(int $type): string { $ls = []; @@ -269,13 +255,46 @@ abstract class BuilderBase return implode(', ', $ls); } - public function setStrip(bool $strip): void + /** + * Get builder options (maybe changed by user) + * + * @param string $key Option key + * @param mixed $default If not exists, return this value + */ + public function getOption(string $key, mixed $default = null): mixed { - $this->strip = $strip; + return $this->options[$key] ?? $default; } /** - * 检查是否存在 lib 库对应的源码,如果不存在,则抛出异常 + * Get all builder options + */ + public function getOptions(): array + { + return $this->options; + } + + /** + * Set builder options if not exists. + */ + public function setOptionIfNotExist(string $key, mixed $value): void + { + if (!isset($this->options[$key])) { + $this->options[$key] = $value; + } + } + + /** + * Set builder options. + */ + public function setOption(string $key, mixed $value): void + { + $this->options[$key] = $value; + } + + /** + * Check if all libs are downloaded. + * If not, throw exception. * * @throws RuntimeException */ diff --git a/src/SPC/builder/BuilderProvider.php b/src/SPC/builder/BuilderProvider.php index a4e54032..b0578ac5 100644 --- a/src/SPC/builder/BuilderProvider.php +++ b/src/SPC/builder/BuilderProvider.php @@ -6,7 +6,7 @@ namespace SPC\builder; use SPC\builder\linux\LinuxBuilder; use SPC\builder\macos\MacOSBuilder; -use SPC\builder\windows\WindowsBuilder; +use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use Symfony\Component\Console\Input\InputInterface; @@ -17,7 +17,9 @@ use Symfony\Component\Console\Input\InputInterface; class BuilderProvider { /** + * @throws FileSystemException * @throws RuntimeException + * @throws WrongUsageException */ public static function makeBuilderByInput(InputInterface $input): BuilderBase { @@ -27,18 +29,8 @@ class BuilderProvider // vs_ver: $input->getOption('vs-ver'), // arch: $input->getOption('arch'), // ), - 'Darwin' => new MacOSBuilder( - cc: $input->getOption('cc'), - cxx: $input->getOption('cxx'), - arch: $input->getOption('arch'), - zts: $input->hasOption('enable-zts') ? $input->getOption('enable-zts') : false, - ), - 'Linux' => new LinuxBuilder( - cc: $input->getOption('cc'), - cxx: $input->getOption('cxx'), - arch: $input->getOption('arch'), - zts: $input->hasOption('enable-zts') ? $input->getOption('enable-zts') : false, - ), + 'Darwin' => new MacOSBuilder($input->getOptions()), + 'Linux' => new LinuxBuilder($input->getOptions()), default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'), }; } diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 24118844..d9edc6b5 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -34,7 +34,7 @@ class Extension /** * 获取开启该扩展的 PHP 编译添加的参数 * - * @throws FileSystemException|RuntimeException + * @throws FileSystemException * @throws WrongUsageException */ public function getConfigureArg(): string @@ -56,7 +56,6 @@ class Extension * 根据 ext 的 arg-type 获取对应开启的参数,一般都是 --enable-xxx 和 --with-xxx * * @throws FileSystemException - * @throws RuntimeException * @throws WrongUsageException */ public function getEnableArg(): string diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index 5b0828dd..e9d7abd1 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -7,20 +7,16 @@ namespace SPC\builder; use SPC\builder\macos\library\MacOSLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\Config; -/** - * Lib 库的基类操作对象 - */ abstract class LibraryBase { - /** @var string lib 依赖名称,必须重写 */ + /** @var string */ public const NAME = 'unknown'; - /** @var string lib 依赖的根目录 */ protected string $source_dir; - /** @var array 依赖列表 */ protected array $dependencies = []; /** @@ -35,7 +31,7 @@ abstract class LibraryBase } /** - * 获取 lib 库的根目录 + * Get current lib source root dir. */ public function getSourceDir(): string { @@ -43,10 +39,9 @@ abstract class LibraryBase } /** - * 获取当前 lib 库的所有依赖列表 + * Get current lib dependencies. * - * @param bool $recursive 是否递归获取(默认为 False) - * @return array 依赖的 Map + * @return array */ public function getDependencies(bool $recursive = false): array { @@ -55,7 +50,6 @@ abstract class LibraryBase return $this->dependencies; } - // 下面为递归获取依赖列表,根据依赖顺序 $deps = []; $added = 1; @@ -78,20 +72,21 @@ abstract class LibraryBase } /** - * 计算依赖列表,不符合依赖将抛出异常 + * Calculate dependencies for current library. * * @throws RuntimeException * @throws FileSystemException + * @throws WrongUsageException */ public function calcDependency(): void { - // 先从配置文件添加依赖,这里根据不同的操作系统分别选择不同的元信息 + // Add dependencies from the configuration file. Here, choose different metadata based on the operating system. /* - 选择规则: - 如果是 Windows 系统,则依次尝试有无 lib-depends-windows、lib-depends-win、lib-depends。 - 如果是 macOS 系统,则依次尝试 lib-depends-darwin、lib-depends-unix、lib-depends。 - 如果是 Linux 系统,则依次尝试 lib-depends-linux、lib-depends-unix、lib-depends。 - */ + Rules: + If it is a Windows system, try the following dependencies in order: lib-depends-windows, lib-depends-win, lib-depends. + If it is a macOS system, try the following dependencies in order: lib-depends-darwin, lib-depends-unix, lib-depends. + If it is a Linux system, try the following dependencies in order: lib-depends-linux, lib-depends-unix, lib-depends. + */ foreach (Config::getLib(static::NAME, 'lib-depends', []) as $dep_name) { $this->addLibraryDependency($dep_name); } @@ -101,11 +96,10 @@ abstract class LibraryBase } /** - * 获取当前库编译出来获取到的静态库文件列表 + * Get config static libs. * - * @return string[] 获取编译出来后的需要的静态库文件列表 * @throws FileSystemException - * @throws RuntimeException + * @throws WrongUsageException */ public function getStaticLibs(): array { @@ -113,11 +107,10 @@ abstract class LibraryBase } /** - * 获取当前 lib 编译出来的 C Header 文件列表 + * Get config headers. * - * @return string[] 获取编译出来后需要的 C Header 文件列表 * @throws FileSystemException - * @throws RuntimeException + * @throws WrongUsageException */ public function getHeaders(): array { @@ -125,14 +118,19 @@ abstract class LibraryBase } /** - * 证明该库是否已编译好且就绪,如果没有就绪,内部会调用 build 来进行构建该库 + * Try to build this library, before build, we check first. + * + * BUILD_STATUS_OK if build success + * BUILD_STATUS_ALREADY if already built + * BUILD_STATUS_FAILED if build failed * * @throws RuntimeException * @throws FileSystemException + * @throws WrongUsageException */ public function tryBuild(bool $force_build = false): int { - // 传入 true,表明直接编译 + // force means just build if ($force_build) { logger()->info('Building required library [' . static::NAME . ']'); $this->patchBeforeBuild(); @@ -140,31 +138,31 @@ abstract class LibraryBase return BUILD_STATUS_OK; } - // 看看这些库是不是存在,如果不存在,则调用编译并返回结果状态 + // check if these libraries exist, if not, invoke compilation and return the result status foreach ($this->getStaticLibs() as $name) { if (!file_exists(BUILD_LIB_PATH . "/{$name}")) { $this->tryBuild(true); return BUILD_STATUS_OK; } } - // 头文件同理 + // header files the same foreach ($this->getHeaders() as $name) { if (!file_exists(BUILD_INCLUDE_PATH . "/{$name}")) { $this->tryBuild(true); return BUILD_STATUS_OK; } } - // pkg-config 做特殊处理,如果是 pkg-config 就检查有没有 pkg-config 二进制 + // pkg-config is treated specially. If it is pkg-config, check if the pkg-config binary exists if ($this instanceof MacOSLibraryBase && static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) { $this->tryBuild(true); return BUILD_STATUS_OK; } - // 到这里说明所有的文件都存在,就跳过编译 + // if all the files exist at this point, skip the compilation process return BUILD_STATUS_ALREADY; } /** - * Patch before build, overwrite this and return true to patch libs + * Patch before build, overwrite this and return true to patch libs. */ public function patchBeforeBuild(): bool { @@ -172,35 +170,32 @@ abstract class LibraryBase } /** - * 获取构建当前 lib 的 Builder 对象 + * Get current builder object. */ abstract public function getBuilder(): BuilderBase; /** - * 构建该库需要调用的命令和操作 + * Build this library. * * @throws RuntimeException */ abstract protected function build(); /** - * 添加 lib 库的依赖库 + * Add lib dependency * - * @param string $name 依赖名称 - * @param bool $optional 是否是可选依赖(默认为 False) * @throws RuntimeException */ protected function addLibraryDependency(string $name, bool $optional = false): void { - // Log::i("add $name as dep of {$this->name}"); $dep_lib = $this->getBuilder()->getLib($name); - if (!$dep_lib) { - if (!$optional) { - throw new RuntimeException(static::NAME . " requires library {$name}"); - } - logger()->debug('enabling ' . static::NAME . " without {$name}"); - } else { + if ($dep_lib) { $this->dependencies[$name] = $dep_lib; + return; } + if (!$optional) { + throw new RuntimeException(static::NAME . " requires library {$name}"); + } + logger()->debug('enabling ' . static::NAME . " without {$name}"); } } diff --git a/src/SPC/builder/extension/bz2.php b/src/SPC/builder/extension/bz2.php index c11060f1..88f22e56 100644 --- a/src/SPC/builder/extension/bz2.php +++ b/src/SPC/builder/extension/bz2.php @@ -7,6 +7,7 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\builder\macos\MacOSBuilder; use SPC\exception\FileSystemException; +use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\util\CustomExt; @@ -15,11 +16,12 @@ class bz2 extends Extension { /** * @throws FileSystemException + * @throws WrongUsageException */ public function patchBeforeConfigure(): bool { $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; - FileSystem::replaceFile(SOURCE_PATH . '/php-src/configure', REPLACE_FILE_PREG, '/-lbz2/', $this->getLibFilesString() . $frameworks); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lbz2/', $this->getLibFilesString() . $frameworks); return true; } } diff --git a/src/SPC/builder/extension/curl.php b/src/SPC/builder/extension/curl.php index c733efeb..d4f8b078 100644 --- a/src/SPC/builder/extension/curl.php +++ b/src/SPC/builder/extension/curl.php @@ -7,12 +7,16 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\builder\macos\MacOSBuilder; use SPC\exception\FileSystemException; +use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('curl')] class curl extends Extension { + /** + * @throws FileSystemException + */ public function patchBeforeBuildconf(): bool { logger()->info('patching before-configure for curl checks'); @@ -42,11 +46,12 @@ class curl extends Extension /** * @throws FileSystemException + * @throws WrongUsageException */ public function patchBeforeConfigure(): bool { $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; - FileSystem::replaceFile(SOURCE_PATH . '/php-src/configure', REPLACE_FILE_PREG, '/-lcurl/', $this->getLibFilesString() . $frameworks); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lcurl/', $this->getLibFilesString() . $frameworks); return true; } } diff --git a/src/SPC/builder/extension/event.php b/src/SPC/builder/extension/event.php index 5dd0bf75..7339ad17 100644 --- a/src/SPC/builder/extension/event.php +++ b/src/SPC/builder/extension/event.php @@ -31,12 +31,7 @@ class event extends Extension */ public function patchBeforeConfigure(): bool { - FileSystem::replaceFile( - SOURCE_PATH . '/php-src/configure', - REPLACE_FILE_PREG, - '/-levent_openssl/', - $this->getLibFilesString() - ); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString()); return true; } } diff --git a/src/SPC/builder/extension/glfw.php b/src/SPC/builder/extension/glfw.php index 7a52bb7c..2920dbf6 100644 --- a/src/SPC/builder/extension/glfw.php +++ b/src/SPC/builder/extension/glfw.php @@ -5,12 +5,16 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('glfw')] class glfw extends Extension { + /** + * @throws RuntimeException + */ public function patchBeforeBuildconf(): bool { FileSystem::copyDir(SOURCE_PATH . '/ext-glfw', SOURCE_PATH . '/php-src/ext/glfw'); diff --git a/src/SPC/builder/extension/iconv.php b/src/SPC/builder/extension/iconv.php new file mode 100644 index 00000000..6e2df2e5 --- /dev/null +++ b/src/SPC/builder/extension/iconv.php @@ -0,0 +1,23 @@ +builder->getOption('extra-libs', ''); + if (!str_contains($extra_libs, '-liconv')) { + $extra_libs .= ' -liconv'; + } + $this->builder->setOption('extra-libs', $extra_libs); + return true; + } +} diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index ed456e17..217b7aa9 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -10,6 +10,17 @@ use SPC\util\CustomExt; #[CustomExt('imagick')] class imagick extends Extension { + public function patchBeforeBuildconf(): bool + { + // linux need to link library manually, we add it to extra-libs + $extra_libs = $this->builder->getOption('extra-libs', ''); + if (!str_contains($extra_libs, 'libMagickCore')) { + $extra_libs .= ' /usr/lib/libMagick++-7.Q16HDRI.a /usr/lib/libMagickCore-7.Q16HDRI.a /usr/lib/libMagickWand-7.Q16HDRI.a'; + } + $this->builder->setOption('extra-libs', $extra_libs); + return true; + } + public function getUnixConfigureArg(): string { return '--with-imagick=' . BUILD_ROOT_PATH; diff --git a/src/SPC/builder/extension/memcache.php b/src/SPC/builder/extension/memcache.php index 38d00be0..eb3e2969 100644 --- a/src/SPC/builder/extension/memcache.php +++ b/src/SPC/builder/extension/memcache.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\CustomExt; @@ -16,17 +17,18 @@ class memcache extends Extension return '--enable-memcache --with-zlib-dir=' . BUILD_ROOT_PATH; } + /** + * @throws FileSystemException + */ public function patchBeforeBuildconf(): bool { - FileSystem::replaceFile( + FileSystem::replaceFileStr( SOURCE_PATH . '/php-src/ext/memcache/config9.m4', - REPLACE_FILE_STR, 'if test -d $abs_srcdir/src ; then', 'if test -d $abs_srcdir/main ; then' ); - FileSystem::replaceFile( + FileSystem::replaceFileStr( SOURCE_PATH . '/php-src/ext/memcache/config9.m4', - REPLACE_FILE_STR, 'export CPPFLAGS="$CPPFLAGS $INCLUDES"', 'export CPPFLAGS="$CPPFLAGS $INCLUDES -I$abs_srcdir/main"' ); diff --git a/src/SPC/builder/extension/pdo_sqlite.php b/src/SPC/builder/extension/pdo_sqlite.php index 5e9250d7..a33dbbba 100644 --- a/src/SPC/builder/extension/pdo_sqlite.php +++ b/src/SPC/builder/extension/pdo_sqlite.php @@ -17,9 +17,8 @@ class pdo_sqlite extends Extension */ public function patchBeforeConfigure(): bool { - FileSystem::replaceFile( + FileSystem::replaceFileRegex( SOURCE_PATH . '/php-src/configure', - REPLACE_FILE_PREG, '/sqlite3_column_table_name=yes/', 'sqlite3_column_table_name=no' ); diff --git a/src/SPC/builder/extension/pgsql.php b/src/SPC/builder/extension/pgsql.php index a5be7ea4..8b447a16 100644 --- a/src/SPC/builder/extension/pgsql.php +++ b/src/SPC/builder/extension/pgsql.php @@ -17,9 +17,8 @@ class pgsql extends Extension */ public function patchBeforeConfigure(): bool { - FileSystem::replaceFile( + FileSystem::replaceFileRegex( SOURCE_PATH . '/php-src/configure', - REPLACE_FILE_PREG, '/-lpq/', $this->getLibFilesString() ); diff --git a/src/SPC/builder/extension/readline.php b/src/SPC/builder/extension/readline.php index a5b09ea8..c66e7afa 100644 --- a/src/SPC/builder/extension/readline.php +++ b/src/SPC/builder/extension/readline.php @@ -17,9 +17,8 @@ class readline extends Extension */ public function patchBeforeConfigure(): bool { - FileSystem::replaceFile( + FileSystem::replaceFileRegex( SOURCE_PATH . '/php-src/configure', - REPLACE_FILE_PREG, '/-lncurses/', $this->getLibFilesString() ); diff --git a/src/SPC/builder/extension/ssh2.php b/src/SPC/builder/extension/ssh2.php index cf966ae6..eeabaa72 100644 --- a/src/SPC/builder/extension/ssh2.php +++ b/src/SPC/builder/extension/ssh2.php @@ -17,9 +17,8 @@ class ssh2 extends Extension */ public function patchBeforeConfigure(): bool { - FileSystem::replaceFile( + FileSystem::replaceFileRegex( SOURCE_PATH . '/php-src/configure', - REPLACE_FILE_PREG, '/-lssh2/', $this->getLibFilesString() ); diff --git a/src/SPC/builder/extension/swow.php b/src/SPC/builder/extension/swow.php index 515a81e1..fdea5a6e 100644 --- a/src/SPC/builder/extension/swow.php +++ b/src/SPC/builder/extension/swow.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\exception\RuntimeException; use SPC\util\CustomExt; use SPC\util\Util; @@ -19,6 +20,9 @@ class swow extends Extension return $arg; } + /** + * @throws RuntimeException + */ public function patchBeforeBuildconf(): bool { if (Util::getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) { diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index e088b0d6..e27c2f34 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -12,94 +12,90 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\SourcePatcher; -/** - * Linux 系统环境下的构建器 - */ class LinuxBuilder extends BuilderBase { - /** 编译的 Unix 工具集 */ + /** Unix compatible builder methods */ use UnixBuilderTrait; - /** @var string[] Linux 环境下编译依赖的命令 */ - public const REQUIRED_COMMANDS = ['make', 'bison', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', /* 'xz', 好像不需要 */ 'gzip', 'bzip2', 'cmake']; - - /** @var string 使用的 libc */ + /** @var string Using libc [musl,glibc] */ public string $libc; - /** @var array 特殊架构下的 cflags */ + /** @var array Tune cflags */ public array $tune_c_flags; - /** @var string pkg-config 环境变量 */ + /** @var string pkg-config env, including PKG_CONFIG_PATH, PKG_CONFIG */ public string $pkgconf_env; - /** @var string 交叉编译变量 */ - public string $cross_compile_prefix = ''; - - public string $note_section = "Je pense, donc je suis\0"; - + /** @var bool Micro patch phar flag */ private bool $phar_patched = false; /** + * @throws FileSystemException * @throws RuntimeException * @throws WrongUsageException */ - public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null, bool $zts = false) + public function __construct(array $options = []) { - // 初始化一些默认参数 - $this->cc = $cc ?? match (SystemUtil::getOSRelease()['dist']) { + $this->options = $options; + + // ---------- set necessary options ---------- + // set C Compiler (default: alpine: gcc, others: musl-gcc) + $this->setOptionIfNotExist('cc', match (SystemUtil::getOSRelease()['dist']) { 'alpine' => 'gcc', default => 'musl-gcc' - }; - $this->cxx = $cxx ?? 'g++'; - $this->arch = $arch ?? php_uname('m'); - $this->gnu_arch = arch2gnu($this->arch); - $this->zts = $zts; - $this->libc = 'musl'; // SystemUtil::selectLibc($this->cc); + }); + // set C++ Compiler (default: g++) + $this->setOptionIfNotExist('cxx', 'g++'); + // set arch (default: current) + $this->setOptionIfNotExist('arch', php_uname('m')); + $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); - // 根据 CPU 线程数设置编译进程数 + // ---------- set necessary compile environments ---------- + // set libc + $this->libc = 'musl'; // SystemUtil::selectLibc($this->cc); + // concurrency $this->concurrency = SystemUtil::getCpuCount(); - // 设置 cflags - $this->arch_c_flags = SystemUtil::getArchCFlags($this->cc, $this->arch); - $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->cxx, $this->arch); - $this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->arch), $this->cc); - // 设置 cmake + // cflags + $this->arch_c_flags = SystemUtil::getArchCFlags($this->getOption('cc'), $this->getOption('arch')); + $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('cxx'), $this->getOption('arch')); + $this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), $this->getOption('cc')); + // cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile( - os: 'Linux', - target_arch: $this->arch, - cflags: $this->arch_c_flags, - cc: $this->cc, - cxx: $this->cxx + 'Linux', + $this->getOption('arch'), + $this->arch_c_flags, + $this->getOption('cc'), + $this->getOption('cxx'), ); - // 设置 pkgconfig - $this->pkgconf_env = 'PKG_CONFIG="' . BUILD_ROOT_PATH . '/bin/pkg-config" PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig"'; - // 设置 configure 依赖的环境变量 - $this->configure_env = - $this->pkgconf_env . ' ' . - "CC='{$this->cc}' " . - "CXX='{$this->cxx}' " . - (php_uname('m') === $this->arch ? '' : "CFLAGS='{$this->arch_c_flags}'"); - // 交叉编译依赖的,TODO - if (php_uname('m') !== $this->arch) { + // pkg-config + $vars = [ + 'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config', + 'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig', + ]; + $this->pkgconf_env = SystemUtil::makeEnvVarString($vars); + // configure environment + $this->configure_env = SystemUtil::makeEnvVarString([ + ...$vars, + 'CC' => $this->getOption('cc'), + 'CXX' => $this->getOption('cxx'), + ]); + // cross-compile does not support yet + /*if (php_uname('m') !== $this->arch) { $this->cross_compile_prefix = SystemUtil::getCrossCompilePrefix($this->cc, $this->arch); logger()->info('using cross compile prefix: ' . $this->cross_compile_prefix); $this->configure_env .= " CROSS_COMPILE='{$this->cross_compile_prefix}'"; - } + }*/ - $missing = []; - foreach (self::REQUIRED_COMMANDS as $cmd) { - if (SystemUtil::findCommand($cmd) === null) { - $missing[] = $cmd; - } - } - if (!empty($missing)) { - throw new WrongUsageException('missing system commands: ' . implode(', ', $missing)); - } - - // 创立 pkg-config 和放头文件的目录 + // create pkgconfig and include dir (some libs cannot create them automatically) f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true); f_mkdir(BUILD_INCLUDE_PATH, recursive: true); } + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ public function makeAutoconfArgs(string $name, array $libSpecs): string { $ret = ''; @@ -124,32 +120,22 @@ class LinuxBuilder extends BuilderBase /** * @throws RuntimeException * @throws FileSystemException + * @throws WrongUsageException */ - public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $with_clean = false, bool $bloat = false) + public function buildPHP(int $build_target = BUILD_TARGET_NONE): void { - if (!$bloat) { - $extra_libs = implode(' ', $this->getAllStaticLibFiles()); + // ---------- Update extra-libs ---------- + $extra_libs = $this->getOption('extra-libs', ''); + // non-bloat linking + if (!$this->getOption('bloat', false)) { + $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); } else { - logger()->info('bloat linking'); - $extra_libs = implode( - ' ', - array_map( - fn ($x) => "-Xcompiler {$x}", - array_filter($this->getAllStaticLibFiles()) - ) - ); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles()))); } + // add libstdc++, some extensions or libraries need it (C++ cannot be linked statically) + $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lc++ ' : ''); + $this->setOption('extra-libs', $extra_libs); - if ($this->hasCppExtension()) { - $extra_libs .= ' -lstdc++'; - } - if ($this->getExt('imagick')) { - $extra_libs .= ' /usr/lib/libMagick++-7.Q16HDRI.a /usr/lib/libMagickCore-7.Q16HDRI.a /usr/lib/libMagickWand-7.Q16HDRI.a'; - } - - $envs = $this->pkgconf_env . ' ' . - "CC='{$this->cc}' " . - "CXX='{$this->cxx}' "; $cflags = $this->arch_c_flags; $use_lld = ''; @@ -159,7 +145,7 @@ class LinuxBuilder extends BuilderBase $cflags .= ' -static-libgcc -I"' . BUILD_INCLUDE_PATH . '"'; break; case 'musl': - if (str_ends_with($this->cc, 'clang') && SystemUtil::findCommand('lld')) { + if (str_ends_with($this->getOption('cc'), 'clang') && SystemUtil::findCommand('lld')) { $use_lld = '-Xcompiler -fuse-ld=lld'; } break; @@ -167,7 +153,12 @@ class LinuxBuilder extends BuilderBase throw new WrongUsageException('libc ' . $this->libc . ' is not implemented yet'); } - $envs = "{$envs} CFLAGS='{$cflags}' LIBS='-ldl -lpthread'"; + $envs = $this->pkgconf_env . ' ' . SystemUtil::makeEnvVarString([ + 'CC' => $this->getOption('cc'), + 'CXX' => $this->getOption('cxx'), + 'CFLAGS' => $cflags, + 'LIBS' => '-ldl -lpthread', + ]); SourcePatcher::patchBeforeBuildconf($this); @@ -175,11 +166,8 @@ class LinuxBuilder extends BuilderBase SourcePatcher::patchBeforeConfigure($this); - if ($this->getPHPVersionID() < 80000) { - $json_74 = '--enable-json '; - } else { - $json_74 = ''; - } + $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; + $zts = $this->getOption('enable-zts', false) ? '--enable-zts ' : ''; shell()->cd(SOURCE_PATH . '/php-src') ->exec( @@ -194,24 +182,16 @@ class LinuxBuilder extends BuilderBase '--enable-cli ' . '--enable-fpm ' . $json_74 . + $zts . '--enable-micro=all-static ' . - ($this->zts ? '--enable-zts' : '') . ' ' . $this->makeExtensionArgs() . ' ' . $envs ); SourcePatcher::patchBeforeMake($this); - file_put_contents('/tmp/comment', $this->note_section); - - // 清理 $this->cleanMake(); - if ($bloat) { - logger()->info('bloat linking'); - $extra_libs = "-Wl,--whole-archive {$extra_libs} -Wl,--no-whole-archive"; - } - if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { logger()->info('building cli'); $this->buildCli($extra_libs, $use_lld); @@ -225,7 +205,7 @@ class LinuxBuilder extends BuilderBase $this->buildMicro($extra_libs, $use_lld, $cflags); } - if (php_uname('m') === $this->arch) { + if (php_uname('m') === $this->getOption('arch')) { $this->sanityCheck($build_target); } @@ -235,30 +215,34 @@ class LinuxBuilder extends BuilderBase } /** + * Build cli sapi + * * @throws RuntimeException + * @throws FileSystemException */ public function buildCli(string $extra_libs, string $use_lld): void { + $vars = SystemUtil::makeEnvVarString([ + 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), + 'EXTRA_LIBS' => $extra_libs, + 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", + ]); shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec( - 'make -j' . $this->concurrency . - ' EXTRA_CFLAGS="-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . '" ' . - "EXTRA_LIBS=\"{$extra_libs}\" " . - "EXTRA_LDFLAGS_PROGRAM='{$use_lld} -all-static' " . - 'cli' - ); + ->exec("make -j{$this->concurrency} {$vars} cli"); + + if (!$this->getOption('no-strip', false)) { + shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php'); + } - shell()->cd(SOURCE_PATH . '/php-src/sapi/cli') - ->exec("{$this->cross_compile_prefix}objcopy --only-keep-debug php php.debug") - ->exec('elfedit --output-osabi linux php') - ->exec("{$this->cross_compile_prefix}strip --strip-all php") - ->exec("{$this->cross_compile_prefix}objcopy --update-section .comment=/tmp/comment --add-gnu-debuglink=php.debug --remove-section=.note php"); $this->deployBinary(BUILD_TARGET_CLI); } /** + * Build phpmicro sapi + * * @throws RuntimeException + * @throws FileSystemException */ public function buildMicro(string $extra_libs, string $use_lld, string $cflags): void { @@ -270,43 +254,45 @@ class LinuxBuilder extends BuilderBase SourcePatcher::patchMicro(['phar']); } + $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; + $vars = SystemUtil::makeEnvVarString([ + 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $enable_fake_cli, + 'EXTRA_LIBS' => $extra_libs, + 'EXTRA_LDFLAGS_PROGRAM' => "{$cflags} {$use_lld} -all-static", + ]); shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec( - "make -j{$this->concurrency} " . - 'EXTRA_CFLAGS=' . quote('-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags))) . ' ' . - 'EXTRA_LIBS=' . quote($extra_libs) . ' ' . - 'EXTRA_LDFLAGS_PROGRAM=' . quote("{$cflags} {$use_lld}" . ' -all-static', "'") . ' ' . - 'micro' - ); + ->exec("make -j{$this->concurrency} {$vars} micro"); - shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec("{$this->cross_compile_prefix}strip --strip-all micro.sfx"); + if (!$this->getOption('no-strip', false)) { + shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-all micro.sfx'); + } $this->deployBinary(BUILD_TARGET_MICRO); } /** - * 构建 fpm + * Build fpm sapi * - * @throws FileSystemException|RuntimeException + * @throws FileSystemException + * @throws RuntimeException */ public function buildFpm(string $extra_libs, string $use_lld): void { + $vars = SystemUtil::makeEnvVarString([ + 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), + 'EXTRA_LIBS' => $extra_libs, + 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", + ]); + shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec( - 'make -j' . $this->concurrency . - ' EXTRA_CFLAGS="-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . '" ' . - "EXTRA_LIBS=\"{$extra_libs}\" " . - "EXTRA_LDFLAGS_PROGRAM='{$use_lld} -all-static' " . - 'fpm' - ); + ->exec("make -j{$this->concurrency} {$vars} fpm"); + + if (!$this->getOption('no-strip', false)) { + shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm'); + } - shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm') - ->exec("{$this->cross_compile_prefix}objcopy --only-keep-debug php-fpm php-fpm.debug") - ->exec('elfedit --output-osabi linux php-fpm') - ->exec("{$this->cross_compile_prefix}strip --strip-all php-fpm") - ->exec("{$this->cross_compile_prefix}objcopy --update-section .comment=/tmp/comment --add-gnu-debuglink=php-fpm.debug --remove-section=.note php-fpm"); $this->deployBinary(BUILD_TARGET_FPM); } } diff --git a/src/SPC/builder/linux/SystemUtil.php b/src/SPC/builder/linux/SystemUtil.php index 5f2df6a3..13bc44b8 100644 --- a/src/SPC/builder/linux/SystemUtil.php +++ b/src/SPC/builder/linux/SystemUtil.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\builder\linux; -use JetBrains\PhpStorm\ArrayShape; use SPC\builder\traits\UnixSystemUtilTrait; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; @@ -13,7 +12,7 @@ class SystemUtil { use UnixSystemUtilTrait; - #[ArrayShape(['dist' => 'mixed|string', 'ver' => 'mixed|string'])] + /** @noinspection PhpMissingBreakStatementInspection */ public static function getOSRelease(): array { $ret = [ @@ -81,6 +80,8 @@ class SystemUtil /** * @throws RuntimeException + * @throws WrongUsageException + * @throws WrongUsageException */ public static function getArchCFlags(string $cc, string $arch): string { @@ -129,6 +130,7 @@ class SystemUtil /** * @throws RuntimeException + * @noinspection PhpUnused */ public static function getCrossCompilePrefix(string $cc, string $arch): string { @@ -159,6 +161,7 @@ class SystemUtil return null; } + /** @noinspection PhpUnused */ public static function findStaticLibs(array $names): ?array { $ret = []; @@ -187,6 +190,7 @@ class SystemUtil return null; } + /** @noinspection PhpUnused */ public static function findHeaders(array $names): ?array { $ret = []; diff --git a/src/SPC/builder/linux/library/LinuxLibraryBase.php b/src/SPC/builder/linux/library/LinuxLibraryBase.php index e3d9878e..5ec8c7c2 100644 --- a/src/SPC/builder/linux/library/LinuxLibraryBase.php +++ b/src/SPC/builder/linux/library/LinuxLibraryBase.php @@ -8,7 +8,9 @@ use SPC\builder\BuilderBase; use SPC\builder\LibraryBase; use SPC\builder\linux\LinuxBuilder; use SPC\builder\traits\UnixLibraryTrait; +use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; abstract class LinuxLibraryBase extends LibraryBase { @@ -37,6 +39,8 @@ abstract class LinuxLibraryBase extends LibraryBase /** * @throws RuntimeException + * @throws FileSystemException + * @throws WrongUsageException */ public function tryBuild(bool $force_build = false): int { @@ -71,7 +75,7 @@ abstract class LinuxLibraryBase extends LibraryBase return BUILD_STATUS_ALREADY; } - protected function makeFakePkgconfs() + protected function makeFakePkgconfs(): void { $workspace = BUILD_ROOT_PATH; if ($workspace === '/') { diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php index c6ef6c37..39125675 100644 --- a/src/SPC/builder/linux/library/icu.php +++ b/src/SPC/builder/linux/library/icu.php @@ -8,7 +8,7 @@ class icu extends LinuxLibraryBase { public const NAME = 'icu'; - protected function build() + protected function build(): void { $root = BUILD_ROOT_PATH; $cppflag = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"'; diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index 54f3357c..81456389 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -23,24 +23,26 @@ namespace SPC\builder\linux\library; use SPC\builder\linux\SystemUtil; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\FileSystem; class libpng extends LinuxLibraryBase { public const NAME = 'libpng'; + /** + * @throws FileSystemException + */ public function patchBeforeBuild(): bool { - FileSystem::replaceFile( + FileSystem::replaceFileStr( SOURCE_PATH . '/libpng/configure', - REPLACE_FILE_STR, '-lz', BUILD_LIB_PATH . '/libz.a' ); if (SystemUtil::getOSRelease()['dist'] === 'alpine') { - FileSystem::replaceFile( + FileSystem::replaceFileStr( SOURCE_PATH . '/libpng/configure', - REPLACE_FILE_STR, '-lm', '/usr/lib/libm.a' ); @@ -49,12 +51,13 @@ class libpng extends LinuxLibraryBase } /** - * @throws RuntimeException * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ - public function build() + public function build(): void { - $optimizations = match ($this->builder->arch) { + $optimizations = match ($this->builder->getOption('arch')) { 'x86_64' => '--enable-intel-sse ', 'arm64' => '--enable-arm-neon ', default => '', @@ -64,7 +67,7 @@ class libpng extends LinuxLibraryBase ->exec('chmod +x ./install-sh') ->exec( "{$this->builder->configure_env} ./configure " . - "--host={$this->builder->gnu_arch}-unknown-linux " . + "--host={$this->builder->getOption('gnu-arch')}-unknown-linux " . '--disable-shared ' . '--enable-static ' . '--enable-hardware-optimizations ' . diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php index 0389b3ea..7a26578b 100644 --- a/src/SPC/builder/linux/library/libxml2.php +++ b/src/SPC/builder/linux/library/libxml2.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\builder\linux\library; +use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; @@ -13,14 +14,15 @@ class libxml2 extends LinuxLibraryBase /** * @throws RuntimeException + * @throws FileSystemException */ - public function build() + public function build(): void { $enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF'; $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF'; $enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF'; - [$lib, $include, $destdir] = SEPARATED_PATH; + [, , $destdir] = SEPARATED_PATH; FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') diff --git a/src/SPC/builder/linux/library/nghttp2.php b/src/SPC/builder/linux/library/nghttp2.php index 733b562d..8246a2eb 100644 --- a/src/SPC/builder/linux/library/nghttp2.php +++ b/src/SPC/builder/linux/library/nghttp2.php @@ -20,11 +20,20 @@ declare(strict_types=1); namespace SPC\builder\linux\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; + class nghttp2 extends LinuxLibraryBase { public const NAME = 'nghttp2'; - public function build() + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + public function build(): void { $args = $this->builder->makeAutoconfArgs(static::NAME, [ 'zlib' => null, @@ -49,7 +58,7 @@ class nghttp2 extends LinuxLibraryBase "{$this->builder->configure_env} ./configure " . '--enable-static ' . '--disable-shared ' . - "--host={$this->builder->gnu_arch}-unknown-linux " . + "--host={$this->builder->getOption('gnu-arch')}-unknown-linux " . '--enable-lib-only ' . '--with-boost=no ' . $args . ' ' . diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index d5cfa7cb..af3400b6 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -23,26 +23,28 @@ namespace SPC\builder\linux\library; use SPC\builder\linux\SystemUtil; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; class openssl extends LinuxLibraryBase { public const NAME = 'openssl'; /** - * @throws RuntimeException * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ - public function build() + public function build(): void { - [$lib,$include,$destdir] = SEPARATED_PATH; + [,,$destdir] = SEPARATED_PATH; $extra = ''; $ex_lib = '-ldl -pthread'; $env = $this->builder->pkgconf_env . " CFLAGS='{$this->builder->arch_c_flags}'"; - $env .= " CC='{$this->builder->cc} -static -idirafter " . BUILD_INCLUDE_PATH . + $env .= " CC='{$this->builder->getOption('cc')} -static -idirafter " . BUILD_INCLUDE_PATH . ' -idirafter /usr/include/ ' . - ' -idirafter /usr/include/' . $this->builder->arch . '-linux-gnu/ ' . + ' -idirafter /usr/include/' . $this->builder->getOption('arch') . '-linux-gnu/ ' . "' "; // lib:zlib $zlib = $this->builder->getLib('zlib'); @@ -58,7 +60,7 @@ class openssl extends LinuxLibraryBase $ex_lib = trim($ex_lib); - $clang_postfix = SystemUtil::getCCType($this->builder->cc) === 'clang' ? '-clang' : ''; + $clang_postfix = SystemUtil::getCCType($this->builder->getOption('cc')) === 'clang' ? '-clang' : ''; shell()->cd($this->source_dir) ->exec( @@ -68,7 +70,7 @@ class openssl extends LinuxLibraryBase '-static ' . "{$zlib_extra}" . 'no-legacy ' . - "linux-{$this->builder->arch}{$clang_postfix}" + "linux-{$this->builder->getOption('arch')}{$clang_postfix}" ) ->exec('make clean') ->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"") diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 5e48629e..eb92a279 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -12,57 +12,56 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\SourcePatcher; -/** - * macOS 系统环境下的构建器 - * 源于 Config,但因为感觉叫 Config 不太合适,就换成了 Builder - */ class MacOSBuilder extends BuilderBase { - /** 编译的 Unix 工具集 */ + /** Unix compatible builder methods */ use UnixBuilderTrait; - /** @var bool 标记是否 patch 了 phar */ + /** @var bool Micro patch phar flag */ private bool $phar_patched = false; /** - * @param null|string $cc C编译器名称,如果不传入则默认使用clang - * @param null|string $cxx C++编译器名称,如果不传入则默认使用clang++ - * @param null|string $arch 当前架构,如果不传入则默认使用当前系统架构 * @throws RuntimeException * @throws WrongUsageException + * @throws FileSystemException */ - public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null, bool $zts = false) + public function __construct(array $options = []) { - // 如果是 Debug 模式,才使用 set -x 显示每条执行的命令 - $this->set_x = defined('DEBUG_MODE') ? 'set -x' : 'true'; - // 初始化一些默认参数 - $this->cc = $cc ?? 'clang'; - $this->cxx = $cxx ?? 'clang++'; - $this->arch = $arch ?? php_uname('m'); - $this->gnu_arch = arch2gnu($this->arch); - $this->zts = $zts; - // 根据 CPU 线程数设置编译进程数 - $this->concurrency = SystemUtil::getCpuCount(); - // 设置 cflags - $this->arch_c_flags = SystemUtil::getArchCFlags($this->arch); - $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->arch); - // 设置 cmake - $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('Darwin', $this->arch, $this->arch_c_flags); - // 设置 configure 依赖的环境变量 - $this->configure_env = - 'PKG_CONFIG="' . BUILD_ROOT_PATH . '/bin/pkg-config" ' . - 'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig/" ' . - "CC='{$this->cc}' " . - "CXX='{$this->cxx}' " . - "CFLAGS='{$this->arch_c_flags} -Wimplicit-function-declaration -Os'"; + $this->options = $options; - // 创立 pkg-config 和放头文件的目录 + // ---------- set necessary options ---------- + // set C Compiler (default: clang) + $this->setOptionIfNotExist('cc', 'clang'); + // set C++ Composer (default: clang++) + $this->setOptionIfNotExist('cxx', 'clang++'); + // set arch (default: current) + $this->setOptionIfNotExist('arch', php_uname('m')); + $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); + + // ---------- set necessary compile environments ---------- + // concurrency + $this->concurrency = SystemUtil::getCpuCount(); + // cflags + $this->arch_c_flags = SystemUtil::getArchCFlags($this->getOption('arch')); + $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('arch')); + // cmake toolchain + $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('Darwin', $this->getOption('arch'), $this->arch_c_flags); + // configure environment + $this->configure_env = SystemUtil::makeEnvVarString([ + 'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config', + 'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig/', + 'CC' => $this->getOption('cc'), + 'CXX' => $this->getOption('cxx'), + 'CFLAGS' => "{$this->arch_c_flags} -Wimplicit-function-declaration -Os", + ]); + + // create pkgconfig and include dir (some libs cannot create them automatically) f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true); f_mkdir(BUILD_INCLUDE_PATH, recursive: true); } /** - * 生成库构建采用的 autoconf 参数列表 + * [deprecated] 生成库构建采用的 autoconf 参数列表 * * @param string $name 要构建的 lib 库名,传入仅供输出日志 * @param array $lib_specs 依赖的 lib 库的 autoconf 文件 @@ -76,7 +75,6 @@ class MacOSBuilder extends BuilderBase $arr = $arr ?? []; $disableArgs = $arr[0] ?? null; - $prefix = $arr[1] ?? null; if ($lib instanceof MacOSLibraryBase) { logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support"); $ret .= '--with-' . $libName . '=yes '; @@ -89,9 +87,11 @@ class MacOSBuilder extends BuilderBase } /** - * 返回 macOS 系统依赖的框架列表 + * Get dynamically linked macOS frameworks * - * @param bool $asString 是否以字符串形式返回(默认为 False) + * @param bool $asString If true, return as string + * @throws FileSystemException + * @throws WrongUsageException */ public function getFrameworks(bool $asString = false): array|string { @@ -118,50 +118,43 @@ class MacOSBuilder extends BuilderBase } /** + * Just start to build statically linked php binary + * * @param int $build_target build target - * @param bool $bloat just raw add all lib files * @throws FileSystemException * @throws RuntimeException * @throws WrongUsageException */ - public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $bloat = false): void + public function buildPHP(int $build_target = BUILD_TARGET_NONE): void { - $extra_libs = $this->getFrameworks(true) . ' ' . ($this->hasCppExtension() ? '-lc++ ' : ''); - if (!$bloat) { - $extra_libs .= implode(' ', $this->getAllStaticLibFiles()); + // ---------- Update extra-libs ---------- + $extra_libs = $this->getOption('extra-libs', ''); + // add macOS frameworks + $extra_libs .= (empty($extra_libs) ? '' : ' ') . $this->getFrameworks(true); + // add libc++, some extensions or libraries need it (C++ cannot be linked statically) + $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lc++ ' : ''); + if (!$this->getOption('bloat', false)) { + $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); } else { logger()->info('bloat linking'); - $extra_libs .= implode( - ' ', - array_map( - fn ($x) => "-Wl,-force_load,{$x}", - array_filter($this->getAllStaticLibFiles()) - ) - ); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Wl,-force_load,{$x}", array_filter($this->getAllStaticLibFiles()))); } + $this->setOption('extra-libs', $extra_libs); - // patch before buildconf SourcePatcher::patchBeforeBuildconf($this); shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force'); SourcePatcher::patchBeforeConfigure($this); - if ($this->getLib('libxml2') || $this->getExt('iconv')) { - $extra_libs .= ' -liconv'; - } - - if ($this->getPHPVersionID() < 80000) { - $json_74 = '--enable-json '; - } else { - $json_74 = ''; - } + $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; + $zts = $this->getOption('enable-zts', false) ? '--enable-zts ' : ''; shell()->cd(SOURCE_PATH . '/php-src') ->exec( './configure ' . '--prefix= ' . - '--with-valgrind=no ' . // 不检测内存泄漏 + '--with-valgrind=no ' . // Not detect memory leak '--enable-shared=no ' . '--enable-static=yes ' . "CFLAGS='{$this->arch_c_flags} -Werror=unknown-warning-option' " . @@ -170,9 +163,9 @@ class MacOSBuilder extends BuilderBase '--disable-phpdbg ' . '--enable-cli ' . '--enable-fpm ' . - $json_74 . '--enable-micro ' . - ($this->zts ? '--enable-zts' : '') . ' ' . + $json_74 . + $zts . $this->makeExtensionArgs() . ' ' . $this->configure_env ); @@ -183,18 +176,18 @@ class MacOSBuilder extends BuilderBase if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { logger()->info('building cli'); - $this->buildCli($extra_libs); + $this->buildCli(); } if (($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) { logger()->info('building fpm'); - $this->buildFpm($extra_libs); + $this->buildFpm(); } if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) { logger()->info('building micro'); - $this->buildMicro($extra_libs); + $this->buildMicro(); } - if (php_uname('m') === $this->arch) { + if (php_uname('m') === $this->getOption('arch')) { $this->sanityCheck($build_target); } @@ -204,27 +197,32 @@ class MacOSBuilder extends BuilderBase } /** - * 构建 cli + * Build cli sapi * * @throws RuntimeException * @throws FileSystemException */ - public function buildCli(string $extra_libs): void + public function buildCli(): void { + $vars = SystemUtil::makeEnvVarString([ + 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size + 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS need it) + ]); + $shell = shell()->cd(SOURCE_PATH . '/php-src'); - $shell->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" cli"); - if ($this->strip) { + $shell->exec("make -j{$this->concurrency} {$vars} cli"); + if (!$this->getOption('no-strip', false)) { $shell->exec('dsymutil -f sapi/cli/php')->exec('strip sapi/cli/php'); } $this->deployBinary(BUILD_TARGET_CLI); } /** - * 构建 phpmicro + * Build phpmicro sapi * * @throws FileSystemException|RuntimeException */ - public function buildMicro(string $extra_libs): void + public function buildMicro(): void { if ($this->getPHPVersionID() < 80000) { throw new RuntimeException('phpmicro only support PHP >= 8.0!'); @@ -234,22 +232,39 @@ class MacOSBuilder extends BuilderBase SourcePatcher::patchMicro(['phar']); } + $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; + $vars = [ + // with debug information, optimize for size, remove identifiers, patch fake cli for micro + 'EXTRA_CFLAGS' => '-g -Os -fno-ident' . $enable_fake_cli, + // link resolv library (macOS need it) + 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", + ]; + if (!$this->getOption('no-strip', false)) { + $vars['STRIP'] = 'dsymutil -f '; + } + $vars = SystemUtil::makeEnvVarString($vars); + shell()->cd(SOURCE_PATH . '/php-src') - ->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os -fno-ident\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" " . ($this->strip ? 'STRIP="dsymutil -f " ' : '') . 'micro'); + ->exec("make -j{$this->concurrency} {$vars} micro"); $this->deployBinary(BUILD_TARGET_MICRO); } /** - * 构建 fpm + * Build fpm sapi * * @throws RuntimeException * @throws FileSystemException */ - public function buildFpm(string $extra_libs): void + public function buildFpm(): void { + $vars = SystemUtil::makeEnvVarString([ + 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size + 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS need it) + ]); + $shell = shell()->cd(SOURCE_PATH . '/php-src'); - $shell->exec("make -j{$this->concurrency} EXTRA_CFLAGS=\"-g -Os -fno-ident\" EXTRA_LIBS=\"{$extra_libs} -lresolv\" fpm"); - if ($this->strip) { + $shell->exec("make -j{$this->concurrency} {$vars} fpm"); + if (!$this->getOption('no-strip', false)) { $shell->exec('dsymutil -f sapi/fpm/php-fpm')->exec('strip sapi/fpm/php-fpm'); } $this->deployBinary(BUILD_TARGET_FPM); diff --git a/src/SPC/builder/macos/SystemUtil.php b/src/SPC/builder/macos/SystemUtil.php index e810ae22..22d7847e 100644 --- a/src/SPC/builder/macos/SystemUtil.php +++ b/src/SPC/builder/macos/SystemUtil.php @@ -10,11 +10,11 @@ use SPC\exception\WrongUsageException; class SystemUtil { - /** macOS 兼容 unix 的系统工具 */ + /** Unix System Util Compatible */ use UnixSystemUtilTrait; /** - * 获取系统 CPU 逻辑内核数 + * Get Logic CPU Count for macOS * * @throws RuntimeException */ @@ -29,9 +29,10 @@ class SystemUtil } /** - * 获取不同架构对应的 cflags 参数 + * Get Target Arch CFlags * - * @param string $arch 架构名称 + * @param string $arch Arch Name + * @return string return Arch CFlags string * @throws WrongUsageException */ public static function getArchCFlags(string $arch): string diff --git a/src/SPC/builder/macos/library/MacOSLibraryBase.php b/src/SPC/builder/macos/library/MacOSLibraryBase.php index 3401e168..336a21b0 100644 --- a/src/SPC/builder/macos/library/MacOSLibraryBase.php +++ b/src/SPC/builder/macos/library/MacOSLibraryBase.php @@ -8,6 +8,8 @@ use SPC\builder\BuilderBase; use SPC\builder\LibraryBase; use SPC\builder\macos\MacOSBuilder; use SPC\builder\traits\UnixLibraryTrait; +use SPC\exception\FileSystemException; +use SPC\exception\WrongUsageException; use SPC\store\Config; abstract class MacOSLibraryBase extends LibraryBase @@ -27,7 +29,8 @@ abstract class MacOSLibraryBase extends LibraryBase } /** - * 获取当前 lib 库依赖的 macOS framework + * @throws WrongUsageException + * @throws FileSystemException */ public function getFrameworks(): array { diff --git a/src/SPC/builder/macos/library/curl.php b/src/SPC/builder/macos/library/curl.php index fa031de5..c590c003 100644 --- a/src/SPC/builder/macos/library/curl.php +++ b/src/SPC/builder/macos/library/curl.php @@ -34,15 +34,13 @@ class curl extends MacOSLibraryBase */ public function patchBeforeBuild(): bool { - FileSystem::replaceFile( + FileSystem::replaceFileRegex( SOURCE_PATH . '/curl/CMakeLists.txt', - REPLACE_FILE_PREG, '/NOT COREFOUNDATION_FRAMEWORK/m', 'FALSE' ); - FileSystem::replaceFile( + FileSystem::replaceFileRegex( SOURCE_PATH . '/curl/CMakeLists.txt', - REPLACE_FILE_PREG, '/NOT SYSTEMCONFIGURATION_FRAMEWORK/m', 'FALSE' ); diff --git a/src/SPC/builder/macos/library/glfw.php b/src/SPC/builder/macos/library/glfw.php index 113bede1..c2ca2e74 100644 --- a/src/SPC/builder/macos/library/glfw.php +++ b/src/SPC/builder/macos/library/glfw.php @@ -4,11 +4,18 @@ declare(strict_types=1); namespace SPC\builder\macos\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; + class glfw extends MacOSLibraryBase { public const NAME = 'glfw'; - protected function build() + /** + * @throws FileSystemException + * @throws RuntimeException + */ + protected function build(): void { // compile! shell()->cd(SOURCE_PATH . '/ext-glfw/vendor/glfw') diff --git a/src/SPC/builder/macos/library/icu.php b/src/SPC/builder/macos/library/icu.php index dd7967a1..11a5663e 100644 --- a/src/SPC/builder/macos/library/icu.php +++ b/src/SPC/builder/macos/library/icu.php @@ -8,7 +8,7 @@ class icu extends MacOSLibraryBase { public const NAME = 'icu'; - protected function build() + protected function build(): void { $root = BUILD_ROOT_PATH; shell()->cd($this->source_dir . '/source') diff --git a/src/SPC/builder/macos/library/libffi.php b/src/SPC/builder/macos/library/libffi.php index 2c67cb46..74bc9ce6 100644 --- a/src/SPC/builder/macos/library/libffi.php +++ b/src/SPC/builder/macos/library/libffi.php @@ -1,39 +1,30 @@ - * - * lwmbs is licensed under Mulan PSL v2. You can use this - * software according to the terms and conditions of the - * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, - * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * - * See the Mulan PSL v2 for more details. - */ declare(strict_types=1); namespace SPC\builder\macos\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; + class libffi extends MacOSLibraryBase { public const NAME = 'libffi'; - protected function build() + /** + * @throws RuntimeException + * @throws FileSystemException + */ + protected function build(): void { - [$lib, , $destdir] = SEPARATED_PATH; + [, , $destdir] = SEPARATED_PATH; shell()->cd($this->source_dir) ->exec( "{$this->builder->configure_env} ./configure " . '--enable-static ' . '--disable-shared ' . - "--host={$this->builder->arch}-apple-darwin " . - "--target={$this->builder->arch}-apple-darwin " . + "--host={$this->builder->getOption('arch')}-apple-darwin " . + "--target={$this->builder->getOption('arch')}-apple-darwin " . '--prefix= ' // use prefix=/ ) ->exec('make clean') diff --git a/src/SPC/builder/macos/library/libmemcached.php b/src/SPC/builder/macos/library/libmemcached.php index c6b74bb4..6eb906f9 100644 --- a/src/SPC/builder/macos/library/libmemcached.php +++ b/src/SPC/builder/macos/library/libmemcached.php @@ -11,7 +11,7 @@ class libmemcached extends MacOSLibraryBase { public const NAME = 'libmemcached'; - public function build() + public function build(): void { $rootdir = BUILD_ROOT_PATH; diff --git a/src/SPC/builder/macos/library/libpng.php b/src/SPC/builder/macos/library/libpng.php index 7b05dcd9..868270d3 100644 --- a/src/SPC/builder/macos/library/libpng.php +++ b/src/SPC/builder/macos/library/libpng.php @@ -22,6 +22,7 @@ namespace SPC\builder\macos\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; class libpng extends MacOSLibraryBase { @@ -30,10 +31,11 @@ class libpng extends MacOSLibraryBase /** * @throws FileSystemException * @throws RuntimeException + * @throws WrongUsageException */ - protected function build() + protected function build(): void { - $optimizations = match ($this->builder->arch) { + $optimizations = match ($this->builder->getOption('arch')) { 'x86_64' => '--enable-intel-sse ', 'arm64' => '--enable-arm-neon ', default => '', @@ -43,7 +45,7 @@ class libpng extends MacOSLibraryBase ->exec('chmod +x ./install-sh') ->exec( "{$this->builder->configure_env} ./configure " . - "--host={$this->builder->gnu_arch}-apple-darwin " . + "--host={$this->builder->getOption('gnu-arch')}-apple-darwin " . '--disable-shared ' . '--enable-static ' . '--enable-hardware-optimizations ' . diff --git a/src/SPC/builder/macos/library/libxml2.php b/src/SPC/builder/macos/library/libxml2.php index 53fa1e52..1ebf0aa9 100644 --- a/src/SPC/builder/macos/library/libxml2.php +++ b/src/SPC/builder/macos/library/libxml2.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\builder\macos\library; +use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; @@ -13,14 +14,22 @@ class libxml2 extends MacOSLibraryBase /** * @throws RuntimeException + * @throws FileSystemException */ - protected function build() + protected function build(): void { + // macOS need to link iconv dynamically, we add it to extra-libs + $extra_libs = $this->builder->getOption('extra-libs', ''); + if (!str_contains($extra_libs, '-liconv')) { + $extra_libs .= ' -liconv'; + } + $this->builder->setOption('extra-libs', $extra_libs); + $enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF'; - $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF'; + // $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF'; $enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF'; - [$lib, $include, $destdir] = SEPARATED_PATH; + [, , $destdir] = SEPARATED_PATH; FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') diff --git a/src/SPC/builder/macos/library/nghttp2.php b/src/SPC/builder/macos/library/nghttp2.php index 62518c24..c1943840 100644 --- a/src/SPC/builder/macos/library/nghttp2.php +++ b/src/SPC/builder/macos/library/nghttp2.php @@ -20,11 +20,18 @@ declare(strict_types=1); namespace SPC\builder\macos\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; + class nghttp2 extends MacOSLibraryBase { public const NAME = 'nghttp2'; - protected function build() + /** + * @throws FileSystemException + * @throws RuntimeException + */ + protected function build(): void { $args = $this->builder->makeAutoconfArgs(static::NAME, [ 'zlib' => null, @@ -49,7 +56,7 @@ class nghttp2 extends MacOSLibraryBase "{$this->builder->configure_env} " . ' ./configure ' . '--enable-static ' . '--disable-shared ' . - "--host={$this->builder->gnu_arch}-apple-darwin " . + "--host={$this->builder->getOption('gnu-arch')}-apple-darwin " . '--enable-lib-only ' . '--with-boost=no ' . $args . ' ' . diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index 89c778a0..8ac99b7f 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -20,11 +20,20 @@ declare(strict_types=1); namespace SPC\builder\macos\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; + class openssl extends MacOSLibraryBase { public const NAME = 'openssl'; - protected function build() + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + protected function build(): void { [$lib,,$destdir] = SEPARATED_PATH; @@ -43,7 +52,7 @@ class openssl extends MacOSLibraryBase '--prefix=/ ' . // use prefix=/ "--libdir={$lib} " . '--openssldir=/System/Library/OpenSSL ' . - "darwin64-{$this->builder->arch}-cc" + "darwin64-{$this->builder->getOption('arch')}-cc" ) ->exec('make clean') ->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"") diff --git a/src/SPC/builder/traits/UnixBuilderTrait.php b/src/SPC/builder/traits/UnixBuilderTrait.php index 49b952d0..8dafe20a 100644 --- a/src/SPC/builder/traits/UnixBuilderTrait.php +++ b/src/SPC/builder/traits/UnixBuilderTrait.php @@ -7,31 +7,27 @@ namespace SPC\builder\traits; use SPC\builder\linux\LinuxBuilder; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\FileSystem; trait UnixBuilderTrait { - /** @var string 设置的命令前缀,设置为 set -x 可以在终端打印命令 */ - public string $set_x = 'set -x'; - - /** @var string C 编译器命令 */ - public string $cc; - - /** @var string C++ 编译器命令 */ - public string $cxx; - - /** @var string cflags 参数 */ + /** @var string cflags */ public string $arch_c_flags; - /** @var string C++ flags 参数 */ + /** @var string C++ flags */ public string $arch_cxx_flags; /** @var string cmake toolchain file */ public string $cmake_toolchain_file; - /** @var string configure 环境依赖的变量 */ + /** @var string configure environments */ public string $configure_env; + /** + * @throws WrongUsageException + * @throws FileSystemException + */ public function getAllStaticLibFiles(): array { $libs = []; @@ -125,7 +121,7 @@ trait UnixBuilderTrait } /** - * 清理编译好的文件 + * Run php clean * * @throws RuntimeException */ @@ -141,7 +137,7 @@ trait UnixBuilderTrait public function makeCmakeArgs(): string { [$lib, $include] = SEPARATED_PATH; - $extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . $this->cc . ' ' : ''; + $extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . $this->getOption('cc') . ' ' : ''; return $extra . '-DCMAKE_BUILD_TYPE=Release ' . '-DCMAKE_INSTALL_PREFIX=/ ' . "-DCMAKE_INSTALL_LIBDIR={$lib} " . diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index 4bc210fa..2f988945 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -7,6 +7,7 @@ namespace SPC\builder\traits; use SPC\builder\LibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\FileSystem; trait UnixLibraryTrait @@ -16,6 +17,7 @@ trait UnixLibraryTrait /** * @throws RuntimeException * @throws FileSystemException + * @throws WrongUsageException */ public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string { @@ -43,6 +45,11 @@ trait UnixLibraryTrait return implode($sep, $ret); } + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ public function makeAutoconfEnv(string $prefix = null): string { if ($prefix === null) { @@ -82,7 +89,7 @@ trait UnixLibraryTrait * remove libtool archive files * * @throws FileSystemException - * @throws RuntimeException + * @throws WrongUsageException */ public function cleanLaFiles(): void { diff --git a/src/SPC/builder/traits/UnixSystemUtilTrait.php b/src/SPC/builder/traits/UnixSystemUtilTrait.php index 6e25ab7a..5aa325ab 100644 --- a/src/SPC/builder/traits/UnixSystemUtilTrait.php +++ b/src/SPC/builder/traits/UnixSystemUtilTrait.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\builder\traits; +use SPC\exception\FileSystemException; use SPC\store\FileSystem; /** @@ -14,11 +15,12 @@ trait UnixSystemUtilTrait /** * 生成 toolchain.cmake,用于 cmake 构建 * - * @param string $os 操作系统代号 - * @param string $target_arch 目标架构 - * @param string $cflags CFLAGS 参数 - * @param null|string $cc CC 参数(默认空) - * @param null|string $cxx CXX 参数(默认空) + * @param string $os 操作系统代号 + * @param string $target_arch 目标架构 + * @param string $cflags CFLAGS 参数 + * @param null|string $cc CC 参数(默认空) + * @param null|string $cxx CXX 参数(默认空) + * @throws FileSystemException */ public static function makeCmakeToolchainFile( string $os, @@ -76,4 +78,20 @@ CMAKE; } return null; } + + /** + * @param array $vars Variables, like: ["CFLAGS" => "-Ixxx"] + * @return string like: CFLAGS="-Ixxx" + */ + public static function makeEnvVarString(array $vars): string + { + $str = ''; + foreach ($vars as $key => $value) { + if ($str !== '') { + $str .= ' '; + } + $str .= $key . '=' . escapeshellarg($value); + } + return $str; + } } diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index 21869601..3dae0814 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -4,10 +4,16 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; use SPC\store\FileSystem; trait brotli { + /** + * @throws FileSystemException + * @throws RuntimeException + */ protected function build(): void { FileSystem::resetDir($this->source_dir . '/build-dir'); diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index fe03acf6..aa5ef28a 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -4,11 +4,17 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; use SPC\store\FileSystem; trait curl { - protected function build() + /** + * @throws RuntimeException + * @throws FileSystemException + */ + protected function build(): void { $extra = ''; // lib:openssl diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index 18b77997..ee7bc9aa 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -4,11 +4,19 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\FileSystem; trait freetype { - protected function build() + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + protected function build(): void { $suggested = $this->builder->getLib('libpng') ? '--with-png' : '--without-png'; $suggested .= ' '; @@ -27,9 +35,8 @@ trait freetype ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['freetype2.pc']); - FileSystem::replaceFile( + FileSystem::replaceFileStr( BUILD_ROOT_PATH . '/lib/pkgconfig/freetype2.pc', - REPLACE_FILE_STR, ' -L/lib ', ' -L' . BUILD_ROOT_PATH . '/lib ' ); diff --git a/src/SPC/builder/unix/library/gmp.php b/src/SPC/builder/unix/library/gmp.php index 934e9b02..bc95a3eb 100644 --- a/src/SPC/builder/unix/library/gmp.php +++ b/src/SPC/builder/unix/library/gmp.php @@ -4,9 +4,16 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; + trait gmp { - protected function build() + /** + * @throws FileSystemException + * @throws RuntimeException + */ + protected function build(): void { shell()->cd($this->source_dir) ->exec( diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index 6f1fd461..f1530b76 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -4,10 +4,16 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; use SPC\store\FileSystem; trait imagemagick { + /** + * @throws RuntimeException + * @throws FileSystemException + */ protected function build(): void { $extra = '--without-jxl --without-xml --without-zstd --without-x --disable-openmp '; @@ -46,9 +52,8 @@ trait imagemagick ]; $this->patchPkgconfPrefix($filelist); foreach ($filelist as $file) { - FileSystem::replaceFile( + FileSystem::replaceFileRegex( BUILD_LIB_PATH . '/pkgconfig/' . $file, - REPLACE_FILE_PREG, '#includearchdir=/include/ImageMagick-7#m', 'includearchdir=${prefix}/include/ImageMagick-7' ); diff --git a/src/SPC/builder/unix/library/libavif.php b/src/SPC/builder/unix/library/libavif.php index ac27a5d9..56b17bdb 100644 --- a/src/SPC/builder/unix/library/libavif.php +++ b/src/SPC/builder/unix/library/libavif.php @@ -4,11 +4,19 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\FileSystem; trait libavif { - protected function build() + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + protected function build(): void { // CMake needs a clean build directory FileSystem::resetDir($this->source_dir . '/build'); diff --git a/src/SPC/builder/unix/library/libevent.php b/src/SPC/builder/unix/library/libevent.php index 66de81b7..59e59f53 100644 --- a/src/SPC/builder/unix/library/libevent.php +++ b/src/SPC/builder/unix/library/libevent.php @@ -4,11 +4,17 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; use SPC\store\FileSystem; trait libevent { - protected function build() + /** + * @throws RuntimeException + * @throws FileSystemException + */ + protected function build(): void { // CMake needs a clean build directory FileSystem::resetDir($this->source_dir . '/build'); @@ -29,6 +35,5 @@ trait libevent ) ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install'); - // patch pkgconfig } } diff --git a/src/SPC/builder/unix/library/libiconv.php b/src/SPC/builder/unix/library/libiconv.php index 12ca1ada..dacfab1e 100644 --- a/src/SPC/builder/unix/library/libiconv.php +++ b/src/SPC/builder/unix/library/libiconv.php @@ -6,7 +6,7 @@ namespace SPC\builder\unix\library; trait libiconv { - protected function build() + protected function build(): void { [,,$destdir] = SEPARATED_PATH; diff --git a/src/SPC/builder/unix/library/libjpeg.php b/src/SPC/builder/unix/library/libjpeg.php index 65da0c08..88845c49 100644 --- a/src/SPC/builder/unix/library/libjpeg.php +++ b/src/SPC/builder/unix/library/libjpeg.php @@ -4,11 +4,19 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\FileSystem; trait libjpeg { - protected function build() + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + protected function build(): void { // CMake needs a clean build directory FileSystem::resetDir($this->source_dir . '/build'); diff --git a/src/SPC/builder/unix/library/libsodium.php b/src/SPC/builder/unix/library/libsodium.php index 2f093d03..f12727d7 100644 --- a/src/SPC/builder/unix/library/libsodium.php +++ b/src/SPC/builder/unix/library/libsodium.php @@ -6,7 +6,7 @@ namespace SPC\builder\unix\library; trait libsodium { - protected function build() + protected function build(): void { $root = BUILD_ROOT_PATH; shell()->cd($this->source_dir) diff --git a/src/SPC/builder/unix/library/libssh2.php b/src/SPC/builder/unix/library/libssh2.php index c0dccdf2..04aa5882 100644 --- a/src/SPC/builder/unix/library/libssh2.php +++ b/src/SPC/builder/unix/library/libssh2.php @@ -4,11 +4,17 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; use SPC\store\FileSystem; trait libssh2 { - protected function build() + /** + * @throws RuntimeException + * @throws FileSystemException + */ + protected function build(): void { $enable_zlib = $this->builder->getLib('zlib') !== null ? 'ON' : 'OFF'; diff --git a/src/SPC/builder/unix/library/libwebp.php b/src/SPC/builder/unix/library/libwebp.php index f6e7a596..ce7bd58e 100644 --- a/src/SPC/builder/unix/library/libwebp.php +++ b/src/SPC/builder/unix/library/libwebp.php @@ -4,9 +4,18 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; + trait libwebp { - protected function build() + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + protected function build(): void { [,,$destdir] = SEPARATED_PATH; diff --git a/src/SPC/builder/unix/library/libyaml.php b/src/SPC/builder/unix/library/libyaml.php index 58ea9fe3..b35cd25f 100644 --- a/src/SPC/builder/unix/library/libyaml.php +++ b/src/SPC/builder/unix/library/libyaml.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; @@ -11,8 +12,9 @@ trait libyaml { /** * @throws RuntimeException + * @throws FileSystemException */ - protected function build() + protected function build(): void { // prepare cmake/config.h.in if (!is_file(SOURCE_PATH . '/libyaml/cmake/config.h.in')) { diff --git a/src/SPC/builder/unix/library/libzip.php b/src/SPC/builder/unix/library/libzip.php index b4b8f99f..f21678ae 100644 --- a/src/SPC/builder/unix/library/libzip.php +++ b/src/SPC/builder/unix/library/libzip.php @@ -4,11 +4,17 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; use SPC\store\FileSystem; trait libzip { - protected function build() + /** + * @throws RuntimeException + * @throws FileSystemException + */ + protected function build(): void { $extra = ''; // lib:bzip2 diff --git a/src/SPC/builder/unix/library/ncurses.php b/src/SPC/builder/unix/library/ncurses.php index f09246eb..f3ec2636 100644 --- a/src/SPC/builder/unix/library/ncurses.php +++ b/src/SPC/builder/unix/library/ncurses.php @@ -6,7 +6,7 @@ namespace SPC\builder\unix\library; trait ncurses { - protected function build() + protected function build(): void { shell()->cd($this->source_dir) ->exec( diff --git a/src/SPC/builder/unix/library/onig.php b/src/SPC/builder/unix/library/onig.php index 72969d79..e9414ab2 100644 --- a/src/SPC/builder/unix/library/onig.php +++ b/src/SPC/builder/unix/library/onig.php @@ -4,9 +4,16 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; + trait onig { - protected function build() + /** + * @throws FileSystemException + * @throws RuntimeException + */ + protected function build(): void { [,,$destdir] = SEPARATED_PATH; diff --git a/src/SPC/builder/unix/library/pkgconfig.php b/src/SPC/builder/unix/library/pkgconfig.php index 6cc475d9..822371a8 100644 --- a/src/SPC/builder/unix/library/pkgconfig.php +++ b/src/SPC/builder/unix/library/pkgconfig.php @@ -6,20 +6,16 @@ namespace SPC\builder\unix\library; trait pkgconfig { - protected function build() + protected function build(): void { $macos_env = 'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig/" ' . - "CC='{$this->builder->cc}' " . - "CXX='{$this->builder->cxx}' " . + "CC='{$this->builder->getOption('cc')}' " . + "CXX='{$this->builder->getOption('cxx')}' " . "CFLAGS='{$this->builder->arch_c_flags} -Wimplicit-function-declaration' "; $linux_env = 'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig" ' . - "CC='{$this->builder->cc}' " . - "CXX='{$this->builder->cxx}' "; + "CC='{$this->builder->getOption('cc')}' " . + "CXX='{$this->builder->getOption('cxx')}' "; - $extra = match (PHP_OS_FAMILY) { - 'Darwin' => '', - default => '--with-internal-glib ', - }; shell()->cd($this->source_dir) ->exec( match (PHP_OS_FAMILY) { @@ -29,7 +25,7 @@ trait pkgconfig './configure ' . '--disable-shared ' . '--enable-static ' . - $extra . + '--with-internal-glib ' . '--prefix=' . BUILD_ROOT_PATH . ' ' . '--without-sysroot ' . '--without-system-include-path ' . diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 40b39c41..b2fa4b27 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -15,7 +15,7 @@ trait postgresql * @throws RuntimeException * @throws FileSystemException */ - protected function build() + protected function build(): void { $builddir = BUILD_ROOT_PATH; $env = $this->builder->configure_env; diff --git a/src/SPC/builder/unix/library/readline.php b/src/SPC/builder/unix/library/readline.php index 31ea26aa..fc865238 100644 --- a/src/SPC/builder/unix/library/readline.php +++ b/src/SPC/builder/unix/library/readline.php @@ -4,9 +4,16 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; + trait readline { - protected function build() + /** + * @throws RuntimeException + * @throws FileSystemException + */ + protected function build(): void { shell()->cd($this->source_dir) ->exec( diff --git a/src/SPC/builder/unix/library/sqlite.php b/src/SPC/builder/unix/library/sqlite.php index add31e53..f9947df7 100644 --- a/src/SPC/builder/unix/library/sqlite.php +++ b/src/SPC/builder/unix/library/sqlite.php @@ -6,7 +6,7 @@ namespace SPC\builder\unix\library; trait sqlite { - protected function build() + protected function build(): void { shell()->cd($this->source_dir) ->exec("{$this->builder->configure_env} ./configure --enable-static --disable-shared --prefix=") diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index 006ed6c2..1f214b3a 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -4,16 +4,23 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; + trait xz { - public function build() + /** + * @throws RuntimeException + * @throws FileSystemException + */ + public function build(): void { shell()->cd($this->source_dir) ->exec( "{$this->builder->configure_env} ./configure " . '--enable-static ' . '--disable-shared ' . - "--host={$this->builder->gnu_arch}-unknown-linux " . + "--host={$this->builder->getOption('gnu-arch')}-unknown-linux " . '--disable-scripts ' . '--disable-doc ' . '--with-libiconv ' . diff --git a/src/SPC/builder/unix/library/zlib.php b/src/SPC/builder/unix/library/zlib.php index 542d918d..5dd0ee10 100644 --- a/src/SPC/builder/unix/library/zlib.php +++ b/src/SPC/builder/unix/library/zlib.php @@ -4,9 +4,16 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; + trait zlib { - protected function build() + /** + * @throws RuntimeException + * @throws FileSystemException + */ + protected function build(): void { [,,$destdir] = SEPARATED_PATH; diff --git a/src/SPC/builder/unix/library/zstd.php b/src/SPC/builder/unix/library/zstd.php index f6b4ea32..de375b25 100644 --- a/src/SPC/builder/unix/library/zstd.php +++ b/src/SPC/builder/unix/library/zstd.php @@ -4,11 +4,17 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; use SPC\store\FileSystem; trait zstd { - protected function build() + /** + * @throws RuntimeException + * @throws FileSystemException + */ + protected function build(): void { FileSystem::resetDir($this->source_dir . '/build/cmake/build'); shell()->cd($this->source_dir . '/build/cmake/build') diff --git a/src/SPC/command/BaseCommand.php b/src/SPC/command/BaseCommand.php index fe3775e1..998336e9 100644 --- a/src/SPC/command/BaseCommand.php +++ b/src/SPC/command/BaseCommand.php @@ -17,16 +17,8 @@ abstract class BaseCommand extends Command { protected bool $no_motd = false; - /** - * 输入 - */ protected InputInterface $input; - /** - * 输出 - * - * 一般来说同样会是 ConsoleOutputInterface - */ protected OutputInterface $output; public function __construct(string $name = null) @@ -36,12 +28,12 @@ abstract class BaseCommand extends Command $this->addOption('no-motd', null, null, 'Disable motd'); } - public function initialize(InputInterface $input, OutputInterface $output) + public function initialize(InputInterface $input, OutputInterface $output): void { if ($input->getOption('no-motd')) { $this->no_motd = true; } - // 注册全局错误处理器 + set_error_handler(static function ($error_no, $error_msg, $error_file, $error_line) { $tips = [ E_WARNING => ['PHP Warning: ', 'warning'], @@ -77,6 +69,9 @@ abstract class BaseCommand extends Command } } + /** + * @throws WrongUsageException + */ abstract public function handle(): int; protected function execute(InputInterface $input, OutputInterface $output): int @@ -93,7 +88,6 @@ abstract class BaseCommand extends Command } return static::FAILURE; } catch (\Throwable $e) { - // 不开 debug 模式就不要再显示复杂的调试栈信息了 if ($this->getOption('debug')) { ExceptionHandler::getInstance()->handle($e); } else { @@ -118,11 +112,6 @@ abstract class BaseCommand extends Command return $this->input->getArgument($name); } - /** - * 是否应该执行 - * - * @return bool 返回 true 以继续执行,返回 false 以中断执行 - */ protected function shouldExecute(): bool { return true; diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index f1427ed6..517f30d7 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -18,7 +18,7 @@ use ZM\Logger\ConsoleColor; #[AsCommand('build', 'build CLI binary')] class BuildCliCommand extends BuildCommand { - public function configure() + public function configure(): void { $this->addArgument('extensions', InputArgument::REQUIRED, 'The extensions will be compiled, comma separated'); $this->addOption('with-libs', null, InputOption::VALUE_REQUIRED, 'add additional libraries, comma separated', ''); @@ -29,17 +29,16 @@ class BuildCliCommand extends BuildCommand $this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions'); $this->addOption('enable-zts', null, null, 'enable ZTS support'); $this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI'); + $this->addOption('with-micro-fake-cli', null, null, 'Enable phpmicro fake cli'); } public function handle(): int { - // 从参数中获取要编译的 libraries,并转换为数组 + // transform string to array $libraries = array_map('trim', array_filter(explode(',', $this->getOption('with-libs')))); - // 从参数中获取要编译的 extensions,并转换为数组 + // transform string to array $extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions')))); - define('BUILD_ALL_STATIC', true); - $rule = BUILD_TARGET_NONE; $rule = $rule | ($this->getOption('build-cli') ? BUILD_TARGET_CLI : BUILD_TARGET_NONE); $rule = $rule | ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE); @@ -54,9 +53,9 @@ class BuildCliCommand extends BuildCommand return static::FAILURE; } try { - // 构建对象 + // create builder $builder = BuilderProvider::makeBuilderByInput($this->input); - // 根据提供的扩展列表获取依赖库列表并编译 + // calculate dependencies [$extensions, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps($extensions, $libraries); /* @phpstan-ignore-next-line */ logger()->info('Build target: ' . ConsoleColor::yellow($builder->getBuildTypeName($rule))); @@ -68,12 +67,11 @@ class BuildCliCommand extends BuildCommand logger()->warning('some extensions will be enabled due to dependencies: ' . implode(',', $not_included)); } sleep(2); - // 编译和检查库是否完整 + // compile libraries $builder->buildLibs($libraries); - // 执行扩展检测 + // check extensions $builder->proveExts($extensions); - // strip - $builder->setStrip(!$this->getOption('no-strip')); + // Process -I option $custom_ini = []; foreach ($this->input->getOption('with-hardcoded-ini') as $value) { @@ -84,11 +82,15 @@ class BuildCliCommand extends BuildCommand if (!empty($custom_ini)) { SourcePatcher::patchHardcodedINI($custom_ini); } - // 构建 - $builder->buildPHP($rule, $this->getOption('bloat')); - // 统计时间 + + // start to build + $builder->buildPHP($rule); + + // compile stopwatch :P $time = round(microtime(true) - START_TIME, 3); logger()->info('Build complete, used ' . $time . ' s !'); + + // ---------- When using bin/spc-alpine-docker, the build root path is different from the host system ---------- $build_root_path = BUILD_ROOT_PATH; $cwd = getcwd(); $fixed = ''; @@ -106,15 +108,17 @@ class BuildCliCommand extends BuildCommand if (($rule & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) { logger()->info('Static php-fpm binary path' . $fixed . ': ' . $build_root_path . '/bin/php-fpm'); } - // 导出相关元数据 + + // export metadata file_put_contents(BUILD_ROOT_PATH . '/build-extensions.json', json_encode($extensions, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); file_put_contents(BUILD_ROOT_PATH . '/build-libraries.json', json_encode($libraries, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); - // 导出 LICENSE + // export licenses $dumper = new LicenseDumper(); $dumper->addExts($extensions)->addLibs($libraries)->addSources(['php-src'])->dump(BUILD_ROOT_PATH . '/license'); logger()->info('License path' . $fixed . ': ' . $build_root_path . '/license/'); return static::SUCCESS; } catch (WrongUsageException $e) { + // WrongUsageException is not an exception, it's a user error, so we just print the error message logger()->critical($e->getMessage()); return static::FAILURE; } catch (\Throwable $e) { diff --git a/src/SPC/command/BuildCommand.php b/src/SPC/command/BuildCommand.php index 11507546..8a721189 100644 --- a/src/SPC/command/BuildCommand.php +++ b/src/SPC/command/BuildCommand.php @@ -12,7 +12,6 @@ abstract class BuildCommand extends BaseCommand { parent::__construct($name); - // 根据运行的操作系统分配允许不同的命令行参数,Windows 需要额外的 VS 和 SDK等,*nix 需要提供架构 switch (PHP_OS_FAMILY) { case 'Windows': $this->addOption('with-sdk-binary-dir', null, InputOption::VALUE_REQUIRED, 'path to binary sdk'); @@ -29,9 +28,7 @@ abstract class BuildCommand extends BaseCommand break; } - // 是否在编译 make 前清除旧的文件 $this->addOption('with-clean', null, null, 'fresh build, `make clean` before `make`'); - // 是否采用强制链接,让链接器强制加载静态库文件 $this->addOption('bloat', null, null, 'add all libraries into binary'); } } diff --git a/src/SPC/command/BuildLibsCommand.php b/src/SPC/command/BuildLibsCommand.php index cc1471eb..be49f86a 100644 --- a/src/SPC/command/BuildLibsCommand.php +++ b/src/SPC/command/BuildLibsCommand.php @@ -15,14 +15,14 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand('build:libs', 'Build dependencies')] class BuildLibsCommand extends BuildCommand { - public function configure() + public function configure(): void { $this->addArgument('libraries', InputArgument::REQUIRED, 'The libraries will be compiled, comma separated'); $this->addOption('clean', null, null, 'Clean old download cache and source before fetch'); $this->addOption('all', 'A', null, 'Build all libs that static-php-cli needed'); } - public function initialize(InputInterface $input, OutputInterface $output) + public function initialize(InputInterface $input, OutputInterface $output): void { // --all 等于 "" if ($input->getOption('all')) { diff --git a/src/SPC/command/DeployCommand.php b/src/SPC/command/DeployCommand.php index 5dd5ddee..b5353619 100644 --- a/src/SPC/command/DeployCommand.php +++ b/src/SPC/command/DeployCommand.php @@ -16,7 +16,7 @@ use function Laravel\Prompts\text; #[AsCommand('deploy', 'Deploy static-php-cli self to an .phar application')] class DeployCommand extends BaseCommand { - public function configure() + public function configure(): void { $this->addArgument('target', InputArgument::OPTIONAL, 'The file or directory to pack.'); $this->addOption('auto-phar-fix', null, InputOption::VALUE_NONE, 'Automatically fix ini option.'); @@ -25,6 +25,9 @@ class DeployCommand extends BaseCommand $this->addOption('with-dev', 'd', InputOption::VALUE_NONE, 'Automatically use dev composer dependencies'); } + /** + * @throws \PharException + */ public function handle(): int { $composer = require ROOT_DIR . '/vendor/composer/installed.php'; @@ -149,9 +152,9 @@ class DeployCommand extends BaseCommand return static::SUCCESS; } - private function progress(int $max = 0): ProgressBar + private function progress(): ProgressBar { - $progress = new ProgressBar($this->output, $max); + $progress = new ProgressBar($this->output, 0); $progress->setBarCharacter('⚬'); $progress->setEmptyBarCharacter('⚬'); $progress->setProgressCharacter('➤'); diff --git a/src/SPC/command/DoctorCommand.php b/src/SPC/command/DoctorCommand.php index eacaf26b..74fc48b8 100644 --- a/src/SPC/command/DoctorCommand.php +++ b/src/SPC/command/DoctorCommand.php @@ -10,7 +10,7 @@ use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand('doctor', 'Diagnose whether the current environment can compile normally')] class DoctorCommand extends BaseCommand { - public function configure() + public function configure(): void { $this->addOption('auto-fix', null, null, 'Automatically fix failed items (if possible)'); } diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 9d2e05a8..b1977459 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -23,7 +23,7 @@ class DownloadCommand extends BaseCommand protected string $php_major_ver; - public function configure() + public function configure(): void { $this->addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated'); $this->addOption('shallow-clone', null, null, 'Clone shallow'); @@ -35,7 +35,7 @@ class DownloadCommand extends BaseCommand $this->addOption('from-zip', 'Z', InputOption::VALUE_REQUIRED, 'Fetch from zip archive'); } - public function initialize(InputInterface $input, OutputInterface $output) + public function initialize(InputInterface $input, OutputInterface $output): void { // --all 等于 "" "",也就是所有东西都要下载 if ($input->getOption('all') || $input->getOption('clean') || $input->getOption('from-zip')) { diff --git a/src/SPC/command/DumpLicenseCommand.php b/src/SPC/command/DumpLicenseCommand.php index ea4d377a..98b5a4fe 100644 --- a/src/SPC/command/DumpLicenseCommand.php +++ b/src/SPC/command/DumpLicenseCommand.php @@ -18,7 +18,7 @@ use Symfony\Component\Console\Input\InputOption; #[AsCommand('dump-license', 'Dump licenses for required libraries')] class DumpLicenseCommand extends BaseCommand { - public function configure() + public function configure(): void { $this->addOption('by-extensions', null, InputOption::VALUE_REQUIRED, 'Dump by extensions and related libraries', null); $this->addOption('without-php', null, InputOption::VALUE_NONE, 'Dump without php-src'); @@ -39,7 +39,7 @@ class DumpLicenseCommand extends BaseCommand // 从参数中获取要编译的 extensions,并转换为数组 $extensions = array_map('trim', array_filter(explode(',', $this->getOption('by-extensions')))); // 根据提供的扩展列表获取依赖库列表并编译 - [$extensions, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps($extensions); + [$extensions, $libraries] = DependencyUtil::getExtLibsByDeps($extensions); $dumper->addExts($extensions); $dumper->addLibs($libraries); if (!$this->getOption('without-php')) { diff --git a/src/SPC/command/ExtractCommand.php b/src/SPC/command/ExtractCommand.php index e9c69fdd..84768866 100644 --- a/src/SPC/command/ExtractCommand.php +++ b/src/SPC/command/ExtractCommand.php @@ -5,6 +5,9 @@ declare(strict_types=1); namespace SPC\command; use SPC\builder\traits\UnixSystemUtilTrait; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\SourceExtractor; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; @@ -14,13 +17,16 @@ class ExtractCommand extends BaseCommand { use UnixSystemUtilTrait; - protected string $php_major_ver; - - public function configure() + public function configure(): void { $this->addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated'); } + /** + * @throws WrongUsageException + * @throws FileSystemException + * @throws RuntimeException + */ public function handle(): int { $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); diff --git a/src/SPC/command/MicroCombineCommand.php b/src/SPC/command/MicroCombineCommand.php index 2c209033..1b14979a 100644 --- a/src/SPC/command/MicroCombineCommand.php +++ b/src/SPC/command/MicroCombineCommand.php @@ -12,7 +12,7 @@ use Symfony\Component\Console\Input\InputOption; #[AsCommand('micro:combine', 'Combine micro.sfx and php code together')] class MicroCombineCommand extends BaseCommand { - public function configure() + public function configure(): void { $this->addArgument('file', InputArgument::REQUIRED, 'The php or phar file to be combined'); $this->addOption('with-micro', 'M', InputOption::VALUE_REQUIRED, 'Customize your micro.sfx file'); diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index c8a18495..7c77b5c5 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -5,17 +5,21 @@ declare(strict_types=1); namespace SPC\command\dev; use SPC\command\BaseCommand; +use SPC\exception\FileSystemException; use SPC\store\Config; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand('dev:ext-all', 'Dev command', ['list-ext'])] class AllExtCommand extends BaseCommand { - public function configure() + public function configure(): void { $this->addOption('line', 'l', null, 'Show with separate lines'); } + /** + * @throws FileSystemException + */ public function handle(): int { $this->output->writeln(implode($this->input->getOption('line') ? PHP_EOL : ',', array_keys(Config::getExts()))); diff --git a/src/SPC/command/dev/ExtInfoCommand.php b/src/SPC/command/dev/ExtInfoCommand.php index 1175b2af..fbab7db6 100644 --- a/src/SPC/command/dev/ExtInfoCommand.php +++ b/src/SPC/command/dev/ExtInfoCommand.php @@ -5,6 +5,9 @@ declare(strict_types=1); namespace SPC\command\dev; use SPC\command\BaseCommand; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\util\DependencyUtil; use Symfony\Component\Console\Attribute\AsCommand; @@ -13,11 +16,16 @@ use Symfony\Component\Console\Input\InputArgument; #[AsCommand('dev:ext-info', 'Dev command')] class ExtInfoCommand extends BaseCommand { - public function configure() + public function configure(): void { $this->addArgument('extensions', InputArgument::REQUIRED, 'The extension name you need to get info'); } + /** + * @throws WrongUsageException + * @throws FileSystemException + * @throws RuntimeException + */ public function handle(): int { $extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions')))); diff --git a/src/SPC/command/dev/PhpVerCommand.php b/src/SPC/command/dev/PhpVerCommand.php index b307f1c5..57374753 100644 --- a/src/SPC/command/dev/PhpVerCommand.php +++ b/src/SPC/command/dev/PhpVerCommand.php @@ -12,7 +12,7 @@ use Symfony\Component\Console\Output\OutputInterface; #[AsCommand('dev:php-ver', 'Dev command')] class PhpVerCommand extends BaseCommand { - public function initialize(InputInterface $input, OutputInterface $output) + public function initialize(InputInterface $input, OutputInterface $output): void { $this->no_motd = true; parent::initialize($input, $output); diff --git a/src/SPC/command/dev/SortConfigCommand.php b/src/SPC/command/dev/SortConfigCommand.php index 39e32f31..11360fd0 100644 --- a/src/SPC/command/dev/SortConfigCommand.php +++ b/src/SPC/command/dev/SortConfigCommand.php @@ -18,7 +18,7 @@ use Symfony\Component\Console\Input\InputArgument; #[AsCommand('dev:sort-config', 'After config edited, sort it by alphabet', ['sort-config'])] class SortConfigCommand extends BaseCommand { - public function configure() + public function configure(): void { $this->addArgument('config-name', InputArgument::REQUIRED, 'Your config to be sorted, you can sort "lib", "source" and "ext".'); } diff --git a/src/SPC/doctor/CheckListHandler.php b/src/SPC/doctor/CheckListHandler.php index f627e632..414c89f9 100644 --- a/src/SPC/doctor/CheckListHandler.php +++ b/src/SPC/doctor/CheckListHandler.php @@ -24,11 +24,14 @@ class CheckListHandler * @throws FileSystemException * @throws RuntimeException */ - public function __construct(private InputInterface $input, private OutputInterface $output, bool $include_manual = false) + public function __construct(private readonly InputInterface $input, private readonly OutputInterface $output, bool $include_manual = false) { $this->loadCheckList($include_manual); } + /** + * @throws RuntimeException + */ public function runSingleCheck(string $item_name, int $fix_policy = FIX_POLICY_DIE): void { foreach ($this->check_list as $item) { @@ -127,7 +130,10 @@ class CheckListHandler usort($this->check_list, fn ($a, $b) => $a->level > $b->level ? -1 : ($a->level == $b->level ? 0 : 1)); } - private function emitFix(CheckResult $result) + /** + * @throws RuntimeException + */ + private function emitFix(CheckResult $result): void { pcntl_signal(SIGINT, function () { $this->output->writeln('You cancelled fix'); diff --git a/src/SPC/doctor/CheckResult.php b/src/SPC/doctor/CheckResult.php index 4a1394d4..112c14ae 100644 --- a/src/SPC/doctor/CheckResult.php +++ b/src/SPC/doctor/CheckResult.php @@ -6,7 +6,7 @@ namespace SPC\doctor; class CheckResult { - public function __construct(private bool $ok, private ?string $message = null, private string $fix_item = '', private array $fix_params = []) + public function __construct(private readonly bool $ok, private readonly ?string $message = null, private string $fix_item = '', private array $fix_params = []) { } @@ -40,7 +40,7 @@ class CheckResult return $this->ok; } - public function setFixItem(string $fix_item = '', array $fix_params = []) + public function setFixItem(string $fix_item = '', array $fix_params = []): void { $this->fix_item = $fix_item; $this->fix_params = $fix_params; diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index c9cb956b..05fa2bd2 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -12,11 +12,11 @@ use SPC\exception\RuntimeException; class LinuxMuslCheck { + /** @noinspection PhpUnused */ #[AsCheckItem('if musl-libc is installed', limit_os: 'Linux')] public function checkMusl(): ?CheckResult { $file = '/lib/ld-musl-x86_64.so.1'; - $result = null; if (file_exists($file)) { return CheckResult::ok(); } @@ -29,6 +29,10 @@ class LinuxMuslCheck }; } + /** + * @throws RuntimeException + * @noinspection PhpUnused + */ #[AsFixItem('fix-musl')] public function fixMusl(array $distro): bool { diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index f563e79f..68ab6f79 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -30,6 +30,7 @@ class LinuxToolCheckList 'bzip2', 'cmake', 'patch', ]; + /** @noinspection PhpUnused */ #[AsCheckItem('if necessary tools are installed', limit_os: 'Linux')] public function checkCliTools(): ?CheckResult { @@ -54,6 +55,7 @@ class LinuxToolCheckList return CheckResult::ok(); } + /** @noinspection PhpUnused */ #[AsCheckItem('if necessary packages are installed', limit_os: 'Linux')] public function checkSystemOSPackages(): ?CheckResult { @@ -67,6 +69,10 @@ class LinuxToolCheckList return CheckResult::ok(); } + /** + * @throws RuntimeException + * @noinspection PhpUnused + */ #[AsFixItem('install-linux-tools')] public function fixBuildTools(array $distro, array $missing): bool { diff --git a/src/SPC/exception/ExceptionHandler.php b/src/SPC/exception/ExceptionHandler.php index 0f03efba..f4bebbf1 100644 --- a/src/SPC/exception/ExceptionHandler.php +++ b/src/SPC/exception/ExceptionHandler.php @@ -6,9 +6,9 @@ namespace SPC\exception; class ExceptionHandler { - protected $whoops; + protected mixed $whoops; - private static $obj; + private static ?ExceptionHandler $obj = null; private function __construct() { @@ -32,14 +32,6 @@ class ExceptionHandler return self::$obj; } - public function getWhoops() - { - return $this->whoops; - } - - /** - * 处理异常 - */ public function handle(\Throwable $e): void { if (is_null($this->whoops)) { diff --git a/src/SPC/store/Config.php b/src/SPC/store/Config.php index 2f6e992b..3a449dfd 100644 --- a/src/SPC/store/Config.php +++ b/src/SPC/store/Config.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace SPC\store; use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; /** @@ -83,7 +82,6 @@ class Config /** * @throws FileSystemException - * @throws RuntimeException * @throws WrongUsageException */ public static function getExt(string $name, ?string $key = null, mixed $default = null) @@ -126,6 +124,9 @@ class Config return self::$ext; } + /** + * @throws FileSystemException + */ public static function getSources(): array { if (self::$source === null) { diff --git a/src/SPC/store/CurlHook.php b/src/SPC/store/CurlHook.php index 2cf7b15b..ce27cf3d 100644 --- a/src/SPC/store/CurlHook.php +++ b/src/SPC/store/CurlHook.php @@ -13,7 +13,7 @@ class CurlHook * @param string $url 修改的链接 * @param array $headers 修改的 headers */ - public static function setupGithubToken(string &$method, string &$url, array &$headers): void + public static function setupGithubToken(string $method, string $url, array &$headers): void { if (!getenv('GITHUB_TOKEN')) { return; diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index d8aada0f..997545f7 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -4,23 +4,22 @@ declare(strict_types=1); namespace SPC\store; -use JetBrains\PhpStorm\ArrayShape; use SPC\exception\DownloaderException; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\source\CustomSourceBase; /** - * 资源下载器 + * Source Downloader. */ class Downloader { /** - * 获取 BitBucket 仓库的最新 Tag + * Get latest version from BitBucket tag * - * @param string $name 资源名称 - * @param array $source 资源的元信息,包含字段 repo - * @return array 返回下载 url 链接和文件名 + * @param string $name source name + * @param array $source source meta info: [repo] + * @return array [url, filename] * @throws DownloaderException */ public static function getLatestBitbucketTag(string $name, array $source): array @@ -49,10 +48,13 @@ class Downloader } /** - * 获取 GitHub 最新的打包地址和文件名 + * Get latest version from GitHub tarball + * + * @param string $name source name + * @param array $source source meta info: [repo] + * @param string $type type of tarball, default is 'releases' + * @return array [url, filename] * - * @param string $name 包名称 - * @param array $source 源信息 * @throws DownloaderException */ public static function getLatestGithubTarball(string $name, array $source, string $type = 'releases'): array @@ -82,10 +84,11 @@ class Downloader } /** - * 获取 GitHub 最新的 Release 下载信息 + * Get latest version from GitHub release (uploaded archive) * - * @param string $name 资源名 - * @param array $source 资源的元信息,包含字段 repo、match + * @param string $name source name + * @param array $source source meta info: [repo, match] + * @return array [url, filename] * @throws DownloaderException */ public static function getLatestGithubRelease(string $name, array $source): array @@ -111,10 +114,11 @@ class Downloader } /** - * 获取文件列表的资源链接和名称 + * Get latest version from file list (regex based crawler) * - * @param string $name 资源名称 - * @param array $source 资源元信息,包含 url、regex + * @param string $name source name + * @param array $source source meta info: [url, regex] + * @return array [url, filename] * @throws DownloaderException */ public static function getFromFileList(string $name, array $source): array @@ -149,6 +153,8 @@ class Downloader } /** + * Just download file using system curl command, and lock it + * * @throws DownloaderException * @throws RuntimeException * @throws FileSystemException @@ -168,6 +174,11 @@ class Downloader self::lockSource($name, ['source_type' => 'archive', 'filename' => $filename, 'move_path' => $move_path]); } + /** + * Try to lock source. + * + * @throws FileSystemException + */ public static function lockSource(string $name, array $data): void { if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { @@ -180,40 +191,11 @@ class Downloader } /** - * 通过链接下载资源到本地并解压 + * Download git source, and lock it. * - * @param string $name 资源名称 - * @param string $url 下载链接 - * @param string $filename 下载到下载目录的目标文件名称,例如 xz.tar.gz - * @param null|string $path 如果指定了此参数,则会移动该资源目录到目标目录 * @throws FileSystemException * @throws RuntimeException - * @throws DownloaderException */ - public static function downloadUrl(string $name, string $url, string $filename, ?string $path = null): void - { - if (!file_exists(DOWNLOAD_PATH . "/{$filename}")) { - logger()->debug("downloading {$url}"); - self::curlDown(url: $url, path: DOWNLOAD_PATH . "/{$filename}"); - } else { - logger()->notice("{$filename} already exists"); - } - FileSystem::extractSource($name, DOWNLOAD_PATH . "/{$filename}"); - if ($path) { - $path = FileSystem::convertPath(SOURCE_PATH . "/{$path}"); - $src_path = FileSystem::convertPath(SOURCE_PATH . "/{$name}"); - switch (PHP_OS_FAMILY) { - case 'Windows': - f_passthru('move "' . $src_path . '" "' . $path . '"'); - break; - case 'Linux': - case 'Darwin': - f_passthru('mv "' . $src_path . '" "' . $path . '"'); - break; - } - } - } - public static function downloadGit(string $name, string $url, string $branch, ?string $move_path = null): void { $download_path = DOWNLOAD_PATH . "/{$name}"; @@ -257,10 +239,10 @@ class Downloader } /** - * 拉取资源 + * Download source by name and meta. * - * @param string $name 资源名称 - * @param null|array $source 资源参数,包含 type、path、rev、url、filename、regex、license + * @param string $name source name + * @param null|array $source source meta info: [type, path, rev, url, filename, regex, license] * @throws DownloaderException * @throws FileSystemException * @throws RuntimeException @@ -291,35 +273,35 @@ class Downloader try { switch ($source['type']) { - case 'bitbuckettag': // 从 BitBucket 的 Tag 拉取 + case 'bitbuckettag': // BitBucket Tag [$url, $filename] = self::getLatestBitbucketTag($name, $source); self::downloadFile($name, $url, $filename, $source['path'] ?? null); break; - case 'ghtar': // 从 GitHub 的 TarBall 拉取 + case 'ghtar': // GitHub Release (tar) [$url, $filename] = self::getLatestGithubTarball($name, $source); self::downloadFile($name, $url, $filename, $source['path'] ?? null); break; - case 'ghtagtar': // 根据 GitHub 的 Tag 拉取相应版本的 Tar + case 'ghtagtar': // GitHub Tag (tar) [$url, $filename] = self::getLatestGithubTarball($name, $source, 'tags'); self::downloadFile($name, $url, $filename, $source['path'] ?? null); break; - case 'ghrel': // 通过 GitHub Release 来拉取 + case 'ghrel': // GitHub Release (uploaded) [$url, $filename] = self::getLatestGithubRelease($name, $source); self::downloadFile($name, $url, $filename, $source['path'] ?? null); break; - case 'filelist': // 通过网站提供的 filelist 使用正则提取后拉取 + case 'filelist': // Basic File List (regex based crawler) [$url, $filename] = self::getFromFileList($name, $source); self::downloadFile($name, $url, $filename, $source['path'] ?? null); break; - case 'url': // 通过直链拉取 + case 'url': // Direct download URL $url = $source['url']; $filename = $source['filename'] ?? basename($source['url']); self::downloadFile($name, $url, $filename, $source['path'] ?? null); break; - case 'git': // 通过拉回 Git 仓库的形式拉取 + case 'git': // Git repo self::downloadGit($name, $source['url'], $source['rev'], $source['path'] ?? null); break; - case 'custom': // 自定义,可能是通过复杂 API 形式获取的文件,需要手写 crawler + case 'custom': // Custom download method, like API-based download or other $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/store/source', 'SPC\\store\\source'); foreach ($classes as $class) { if (is_a($class, CustomSourceBase::class, true) && $class::NAME === $name) { @@ -332,7 +314,8 @@ class Downloader throw new DownloaderException('unknown source type: ' . $source['type']); } } catch (RuntimeException $e) { - // 因为某些时候通过命令行下载的文件在失败后不会删除,这里检测到文件存在需要手动删一下 + // Because sometimes files downloaded through the command line are not automatically deleted after a failure. + // Here we need to manually delete the file if it is detected to exist. if (isset($filename) && file_exists(DOWNLOAD_PATH . '/' . $filename)) { logger()->warning('Deleting download file: ' . $filename); unlink(DOWNLOAD_PATH . '/' . $filename); @@ -342,27 +325,7 @@ class Downloader } /** - * 获取 PHP x.y 的具体版本号,例如通过 8.1 来获取 8.1.10 - * - * @throws DownloaderException - */ - #[ArrayShape(['type' => 'string', 'path' => 'string', 'rev' => 'string', 'url' => 'string'])] - public static function getLatestPHPInfo(string $major_version): array - { - // 查找最新的小版本号 - $info = json_decode(self::curlExec(url: "https://www.php.net/releases/index.php?json&version={$major_version}"), true); - $version = $info['version']; - - // 从官网直接下载 - return [ - 'type' => 'url', - 'url' => "https://www.php.net/distributions/php-{$version}.tar.gz", - // 'url' => "https://mirrors.zhamao.xin/php/php-{$version}.tar.gz", - ]; - } - - /** - * 使用 curl 命令拉取元信息 + * Use curl command to get http response * * @throws DownloaderException */ @@ -408,7 +371,7 @@ class Downloader } /** - * 使用 curl 命令下载文件 + * Use curl to download sources from url * * @throws DownloaderException * @throws RuntimeException diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index ab0028ef..f4bf8664 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -55,23 +55,25 @@ class FileSystem /** * @throws FileSystemException */ - public static function replaceFile(string $filename, int $replace_type = REPLACE_FILE_STR, mixed $callback_or_search = null, mixed $to_replace = null): bool|int + public static function replaceFileStr(string $filename, mixed $search = null, mixed $replace = null): bool|int { - logger()->debug('Replacing file with type[' . $replace_type . ']: ' . $filename); - $file = self::readFile($filename); - switch ($replace_type) { - case REPLACE_FILE_STR: - default: - $file = str_replace($callback_or_search, $to_replace, $file); - break; - case REPLACE_FILE_PREG: - $file = preg_replace($callback_or_search, $to_replace, $file); - break; - case REPLACE_FILE_USER: - $file = $callback_or_search($file); - break; - } - return file_put_contents($filename, $file); + return self::replaceFile($filename, REPLACE_FILE_STR, $search, $replace); + } + + /** + * @throws FileSystemException + */ + public static function replaceFileRegex(string $filename, mixed $search = null, mixed $replace = null): bool|int + { + return self::replaceFile($filename, REPLACE_FILE_PREG, $search, $replace); + } + + /** + * @throws FileSystemException + */ + public static function replaceFileUser(string $filename, mixed $callback = null): bool|int + { + return self::replaceFile($filename, REPLACE_FILE_USER, $callback); } /** @@ -117,6 +119,9 @@ class FileSystem return null; } + /** + * @throws RuntimeException + */ public static function copyDir(string $from, string $to): void { $dst_path = FileSystem::convertPath($to); @@ -384,6 +389,9 @@ class FileSystem return rmdir($dir); } + /** + * @throws FileSystemException + */ public static function createDir(string $path): void { if (!is_dir($path) && !f_mkdir($path, 0755, true) && !is_dir($path)) { @@ -391,7 +399,11 @@ class FileSystem } } - public static function writeFile(string $path, $content, ...$args): bool|string|int + /** + * @param mixed ...$args Arguments passed to file_put_contents + * @throws FileSystemException + */ + public static function writeFile(string $path, mixed $content, ...$args): bool|string|int { $dir = pathinfo($path, PATHINFO_DIRNAME); if (!is_dir($dir) && !mkdir($dir, 0755, true)) { @@ -413,7 +425,7 @@ class FileSystem self::createDir($dir_name); } - public static function addSourceExtractHook(string $name, callable $callback) + public static function addSourceExtractHook(string $name, callable $callback): void { self::$_extract_hook[$name][] = $callback; } @@ -425,14 +437,35 @@ class FileSystem */ public static function isRelativePath(string $path): bool { - // 适配 Windows 的多盘符目录形式 if (DIRECTORY_SEPARATOR === '\\') { return !(strlen($path) > 2 && ctype_alpha($path[0]) && $path[1] === ':'); } return strlen($path) > 0 && $path[0] !== '/'; } - private static function emitSourceExtractHook(string $name) + /** + * @throws FileSystemException + */ + private static function replaceFile(string $filename, int $replace_type = REPLACE_FILE_STR, mixed $callback_or_search = null, mixed $to_replace = null): bool|int + { + logger()->debug('Replacing file with type[' . $replace_type . ']: ' . $filename); + $file = self::readFile($filename); + switch ($replace_type) { + case REPLACE_FILE_STR: + default: + $file = str_replace($callback_or_search, $to_replace, $file); + break; + case REPLACE_FILE_PREG: + $file = preg_replace($callback_or_search, $to_replace, $file); + break; + case REPLACE_FILE_USER: + $file = $callback_or_search($file); + break; + } + return file_put_contents($filename, $file); + } + + private static function emitSourceExtractHook(string $name): void { foreach ((self::$_extract_hook[$name] ?? []) as $hook) { if ($hook() === true) { diff --git a/src/SPC/store/SourceExtractor.php b/src/SPC/store/SourceExtractor.php index 8842b890..4a68bef8 100644 --- a/src/SPC/store/SourceExtractor.php +++ b/src/SPC/store/SourceExtractor.php @@ -4,10 +4,17 @@ declare(strict_types=1); namespace SPC\store; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; class SourceExtractor { + /** + * @throws WrongUsageException + * @throws FileSystemException + * @throws RuntimeException + */ public static function initSource(?array $sources = null, ?array $libs = null, ?array $exts = null): void { if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 4bcc8d31..970f22c0 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -11,7 +11,7 @@ use SPC\exception\RuntimeException; class SourcePatcher { - public static function init() + public static function init(): void { // FileSystem::addSourceExtractHook('swow', [SourcePatcher::class, 'patchSwow']); FileSystem::addSourceExtractHook('micro', [SourcePatcher::class, 'patchMicro']); @@ -46,9 +46,13 @@ class SourcePatcher } } // patch capstone - FileSystem::replaceFile(SOURCE_PATH . '/php-src/configure', REPLACE_FILE_PREG, '/have_capstone="yes"/', 'have_capstone="no"'); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"'); } + /** + * @throws RuntimeException + * @throws FileSystemException + */ public static function patchMicro(?array $list = null, bool $reverse = false): bool { if (!file_exists(SOURCE_PATH . '/php-src/sapi/micro/php_micro.c')) { @@ -66,7 +70,7 @@ class SourcePatcher if ($major_ver === '74') { return false; } - $check = !defined('DEBUG_MODE') ? ' -q' : ''; + // $check = !defined('DEBUG_MODE') ? ' -q' : ''; // f_passthru('cd ' . SOURCE_PATH . '/php-src && git checkout' . $check . ' HEAD'); $default = [ @@ -113,15 +117,13 @@ class SourcePatcher return true; } + /** + * @throws FileSystemException + */ public static function patchOpenssl11Darwin(): bool { if (PHP_OS_FAMILY === 'Darwin' && !file_exists(SOURCE_PATH . '/openssl/VERSION.dat') && file_exists(SOURCE_PATH . '/openssl/test/v3ext.c')) { - FileSystem::replaceFile( - SOURCE_PATH . '/openssl/test/v3ext.c', - REPLACE_FILE_STR, - '#include ', - '#include ' . PHP_EOL . '#include ' - ); + FileSystem::replaceFileStr(SOURCE_PATH . '/openssl/test/v3ext.c', '#include ', '#include ' . PHP_EOL . '#include '); return true; } return false; @@ -134,10 +136,10 @@ class SourcePatcher { // Try to fix debian environment build lack HAVE_STRLCAT problem if ($builder instanceof LinuxBuilder) { - FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_STRLCPY 1$/m', ''); - FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_STRLCAT 1$/m', ''); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_STRLCPY 1$/m', ''); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_STRLCAT 1$/m', ''); } - FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_OPENPTY 1$/m', ''); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', ''); // call extension patch before make foreach ($builder->getExts() as $ext) { @@ -158,7 +160,7 @@ class SourcePatcher $micro_c_bak = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c.bak'; // Try to reverse backup file - $find_pattern = 'const char HARDCODED_INI[] ='; + $find_str = 'const char HARDCODED_INI[] ='; $patch_str = ''; foreach ($ini as $key => $value) { $patch_str .= "\"{$key}={$value}\\n\"\n"; @@ -178,8 +180,8 @@ class SourcePatcher } // Patch it - FileSystem::replaceFile($cli_c, REPLACE_FILE_STR, $find_pattern, $patch_str); - FileSystem::replaceFile($micro_c, REPLACE_FILE_STR, $find_pattern, $patch_str); + FileSystem::replaceFileStr($cli_c, $find_str, $patch_str); + FileSystem::replaceFileStr($micro_c, $find_str, $patch_str); return true; } diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index 44998e4e..f23f63ea 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -6,6 +6,7 @@ namespace SPC\store\source; use JetBrains\PhpStorm\ArrayShape; use SPC\exception\DownloaderException; +use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\Downloader; @@ -16,8 +17,9 @@ class PhpSource extends CustomSourceBase /** * @throws DownloaderException * @throws RuntimeException + * @throws FileSystemException */ - public function fetch() + public function fetch(): void { $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.1'; Downloader::downloadSource('php-src', self::getLatestPHPInfo($major)); diff --git a/src/SPC/store/source/PostgreSQLSource.php b/src/SPC/store/source/PostgreSQLSource.php index cd8a095d..66276db0 100644 --- a/src/SPC/store/source/PostgreSQLSource.php +++ b/src/SPC/store/source/PostgreSQLSource.php @@ -4,20 +4,31 @@ declare(strict_types=1); namespace SPC\store\source; +use SPC\exception\DownloaderException; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; use SPC\store\Downloader; class PostgreSQLSource extends CustomSourceBase { public const NAME = 'postgresql'; - public function fetch() + /** + * @throws DownloaderException + * @throws RuntimeException + * @throws FileSystemException + */ + public function fetch(): void { Downloader::downloadSource('postgresql', self::getLatestInfo()); } + /** + * @throws DownloaderException + */ public function getLatestInfo(): array { - [$url, $filename, $version] = Downloader::getFromFileList('postgresql', [ + [, $filename, $version] = Downloader::getFromFileList('postgresql', [ 'url' => 'https://www.postgresql.org/ftp/source/', 'regex' => '/href="(?v(?[^"]+)\/)"/', ]); diff --git a/src/SPC/util/ConfigValidator.php b/src/SPC/util/ConfigValidator.php index 9b818fb7..0126ddf9 100644 --- a/src/SPC/util/ConfigValidator.php +++ b/src/SPC/util/ConfigValidator.php @@ -49,10 +49,9 @@ class ConfigValidator } /** - * @param mixed $data * @throws ValidationException */ - public static function validateLibs($data, array $source_data = []): void + public static function validateLibs(mixed $data, array $source_data = []): void { is_array($data) || throw new ValidationException('lib.json is broken'); foreach ($data as $name => $lib) { @@ -64,7 +63,10 @@ class ConfigValidator } } - public static function validateExts($data, array $source_data = []): void + /** + * @throws ValidationException + */ + public static function validateExts(mixed $data): void { is_array($data) || throw new ValidationException('ext.json is broken'); } diff --git a/src/SPC/util/DependencyUtil.php b/src/SPC/util/DependencyUtil.php index d030966d..ba0d839c 100644 --- a/src/SPC/util/DependencyUtil.php +++ b/src/SPC/util/DependencyUtil.php @@ -15,18 +15,17 @@ use SPC\store\Config; class DependencyUtil { /** - * 根据需要的 ext 列表获取依赖的 lib 列表,同时根据依赖关系排序 + * Obtain the dependent lib list according to the required ext list, and sort according to the dependency * - * @param array $exts 要获取 libs 依赖的列表 - * @param array $additional_libs 额外要添加的库列表,用于激活 lib-suggests 触发的额外库特性 - * @return array 返回一个包含三个数组的数组,第一个是排序后的 ext 列表,第二个是排序后的 lib 列表,第三个是没有传入但是依赖了的 ext 列表 + * @param array $exts extensions list + * @param array $additional_libs List of additional libraries to add to activate the extra library features triggered by lib-suggests + * @return array Returns an array containing three arrays, [extensions, libraries, not included extensions] * @throws WrongUsageException * @throws RuntimeException * @throws FileSystemException */ public static function getExtLibsByDeps(array $exts, array $additional_libs = []): array { - // 先对扩展列表进行一个依赖筛选 $sorted = []; $visited = []; $not_included_exts = []; @@ -49,7 +48,7 @@ class DependencyUtil } } $libs = $additional_libs; - // 遍历每一个 ext 的 libs + foreach ($final as $ext) { if (!in_array($ext, $exts)) { $not_included_exts[] = $ext; diff --git a/src/SPC/util/Patcher.php b/src/SPC/util/Patcher.php index 3f7f7660..1419606e 100644 --- a/src/SPC/util/Patcher.php +++ b/src/SPC/util/Patcher.php @@ -19,17 +19,17 @@ class Patcher switch ($libc) { case 'musl_wrapper': // bad checks - FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_STRLCPY 1$/m', ''); - FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_STRLCAT 1$/m', ''); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_STRLCPY 1$/m', ''); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_STRLCAT 1$/m', ''); // no break case 'musl': - FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_FUNC_ATTRIBUTE_IFUNC 1$/m', ''); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_FUNC_ATTRIBUTE_IFUNC 1$/m', ''); break; case 'glibc': // avoid lcrypt dependency - FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_CRYPT 1$/m', ''); - FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_CRYPT_R 1$/m', ''); - FileSystem::replaceFile(SOURCE_PATH . '/php-src/main/php_config.h', REPLACE_FILE_PREG, '/^#define HAVE_CRYPT_H 1$/m', ''); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_CRYPT 1$/m', ''); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_CRYPT_R 1$/m', ''); + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_CRYPT_H 1$/m', ''); break; default: throw new RuntimeException('not implemented'); diff --git a/src/SPC/util/UnixShell.php b/src/SPC/util/UnixShell.php index 565182ea..5fd730f9 100644 --- a/src/SPC/util/UnixShell.php +++ b/src/SPC/util/UnixShell.php @@ -63,6 +63,9 @@ class UnixShell return $this; } + /** + * @throws RuntimeException + */ public function execWithEnv(string $cmd): UnixShell { return $this->exec($this->getEnvString() . ' ' . $cmd); diff --git a/src/globals/defines.php b/src/globals/defines.php index fb66869e..28473296 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -39,11 +39,11 @@ const BUILD_STATUS_ALREADY = 1; const BUILD_STATUS_FAILED = 2; // build target type -const BUILD_TARGET_NONE = 0; -const BUILD_TARGET_CLI = 1; -const BUILD_TARGET_MICRO = 2; -const BUILD_TARGET_FPM = 4; -const BUILD_TARGET_ALL = 7; +const BUILD_TARGET_NONE = 0; // no target +const BUILD_TARGET_CLI = 1; // build cli +const BUILD_TARGET_MICRO = 2; // build micro +const BUILD_TARGET_FPM = 4; // build fpm +const BUILD_TARGET_ALL = 7; // build all // doctor error fix policy const FIX_POLICY_DIE = 1; // die directly @@ -57,9 +57,4 @@ const PKGCONF_PATCH_LIBDIR = 4; const PKGCONF_PATCH_INCLUDEDIR = 8; const PKGCONF_PATCH_ALL = 15; -// Custom download type -const DOWNLOAD_TYPE_NONE = 0; -const DOWNLOAD_TYPE_ARCHIVE = 1; -const DOWNLOAD_TYPE_DIR = 2; - ConsoleLogger::$date_format = 'H:i:s'; diff --git a/src/globals/functions.php b/src/globals/functions.php index 5f6cc29f..7f411624 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -8,17 +8,15 @@ use SPC\util\UnixShell; use ZM\Logger\ConsoleLogger; /** - * 判断传入的数组是否为关联数组 - * - * @param mixed $array + * Judge if an array is an associative array */ -function is_assoc_array($array): bool +function is_assoc_array(mixed $array): bool { return is_array($array) && (!empty($array) && array_keys($array) !== range(0, count($array) - 1)); } /** - * 助手方法,返回一个 Logger 实例 + * Return a logger instance */ function logger(): LoggerInterface { @@ -30,7 +28,8 @@ function logger(): LoggerInterface } /** - * @param string $arch 架构名称转换为 GNU 标准形式 + * Transfer architecture name to gnu triplet + * * @throws WrongUsageException */ function arch2gnu(string $arch): string @@ -50,7 +49,7 @@ function quote(string $str, string $quote = '"'): string } /** - * 将不同系统环境的编译使用工具集的文件夹名称进行一个返回 + * Get Family name of current OS * * @throws WrongUsageException */ @@ -66,7 +65,7 @@ function osfamily2dir(): string } /** - * 执行shell,直接输出在终端,出现错误抛出异常 + * Execute the shell command, and the output will be directly printed in the terminal. If there is an error, an exception will be thrown * * @throws \SPC\exception\RuntimeException */ @@ -92,12 +91,9 @@ function f_passthru(string $cmd): ?bool } /** - * 执行命令,不输出内容,返回执行结果和内容 - * - * @param mixed $output - * @param mixed $result_code + * Execute a command, return the output and result code */ -function f_exec(string $command, &$output, &$result_code): bool|string +function f_exec(string $command, mixed &$output, mixed &$result_code): bool|string { logger()->debug('Running command (no output) : ' . $command); return exec($command, $output, $result_code); diff --git a/src/globals/tests/bcmath.php b/src/globals/tests/bcmath.php index bad5f8f6..0190aa78 100644 --- a/src/globals/tests/bcmath.php +++ b/src/globals/tests/bcmath.php @@ -1,7 +1,5 @@ Date: Mon, 21 Aug 2023 18:07:52 +0800 Subject: [PATCH 094/296] add buildroot bin PATH --- src/SPC/builder/linux/LinuxBuilder.php | 2 ++ src/SPC/builder/macos/MacOSBuilder.php | 1 + 2 files changed, 3 insertions(+) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index e27c2f34..ff33af3a 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -78,6 +78,7 @@ class LinuxBuilder extends BuilderBase ...$vars, 'CC' => $this->getOption('cc'), 'CXX' => $this->getOption('cxx'), + 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), ]); // cross-compile does not support yet /*if (php_uname('m') !== $this->arch) { @@ -158,6 +159,7 @@ class LinuxBuilder extends BuilderBase 'CXX' => $this->getOption('cxx'), 'CFLAGS' => $cflags, 'LIBS' => '-ldl -lpthread', + 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), ]); SourcePatcher::patchBeforeBuildconf($this); diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index eb92a279..8378f080 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -53,6 +53,7 @@ class MacOSBuilder extends BuilderBase 'CC' => $this->getOption('cc'), 'CXX' => $this->getOption('cxx'), 'CFLAGS' => "{$this->arch_c_flags} -Wimplicit-function-declaration -Os", + 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), ]); // create pkgconfig and include dir (some libs cannot create them automatically) From 21a4ba7478bc9b12b177124d3655b249c4079349 Mon Sep 17 00:00:00 2001 From: kocoten1992 Date: Mon, 21 Aug 2023 11:15:09 +0700 Subject: [PATCH 095/296] add swoole pgsql (--enable-swoole-pgsql) --- config/ext.json | 3 ++- src/SPC/builder/extension/swoole.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/ext.json b/config/ext.json index 3bac3fa0..cd081e36 100644 --- a/config/ext.json +++ b/config/ext.json @@ -370,7 +370,8 @@ "arg-type": "custom", "cpp-extension": true, "lib-depends": [ - "openssl" + "openssl", + "pqsql" ], "ext-depends": [ "openssl" diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 492ff12c..0d0e2c7e 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -12,7 +12,7 @@ class swoole extends Extension { public function getUnixConfigureArg(): string { - $arg = '--enable-swoole'; + $arg = '--enable-swoole --enable-swoole-pgsql'; $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl'; $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; // curl hook is buggy for static php From 4766ae146fbb16b11a5ce3fa72effc989c005369 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 21 Aug 2023 18:30:26 +0800 Subject: [PATCH 096/296] change swoole-pgsql as alternative --- config/ext.json | 6 +++--- src/SPC/builder/extension/swoole.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config/ext.json b/config/ext.json index cd081e36..67b96622 100644 --- a/config/ext.json +++ b/config/ext.json @@ -370,14 +370,14 @@ "arg-type": "custom", "cpp-extension": true, "lib-depends": [ - "openssl", - "pqsql" + "openssl" ], "ext-depends": [ "openssl" ], "ext-suggests": [ - "curl" + "curl", + "pgsql" ], "unix-only": true }, diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 0d0e2c7e..ab8b9848 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -12,7 +12,8 @@ class swoole extends Extension { public function getUnixConfigureArg(): string { - $arg = '--enable-swoole --enable-swoole-pgsql'; + $arg = '--enable-swoole'; + $arg .= $this->builder->getExt('pgsql') ? ' --enable-swoole-pgsql' : ' --disable-swoole-pgsql'; $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl'; $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; // curl hook is buggy for static php From d326154241502a6c08a1c7927e3e654421ec1d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 21 Aug 2023 12:13:25 +0200 Subject: [PATCH 097/296] fix: musl detection on non-x86_64 --- src/SPC/doctor/item/LinuxMuslCheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index 05fa2bd2..9eeb6f53 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -16,7 +16,7 @@ class LinuxMuslCheck #[AsCheckItem('if musl-libc is installed', limit_os: 'Linux')] public function checkMusl(): ?CheckResult { - $file = '/lib/ld-musl-x86_64.so.1'; + $file = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); if (file_exists($file)) { return CheckResult::ok(); } From 60e06737d7e07a68136769b7afc08c6eb910ab50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 21 Aug 2023 12:47:06 +0200 Subject: [PATCH 098/296] fix: disable Zend Signals and enable Zend Max Execution Timers for ZTS builds --- src/SPC/builder/linux/LinuxBuilder.php | 2 +- src/SPC/builder/macos/MacOSBuilder.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index ff33af3a..6ed41c1b 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -169,7 +169,7 @@ class LinuxBuilder extends BuilderBase SourcePatcher::patchBeforeConfigure($this); $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; - $zts = $this->getOption('enable-zts', false) ? '--enable-zts ' : ''; + $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals --enable-zend-max-execution-timers ' : ''; shell()->cd(SOURCE_PATH . '/php-src') ->exec( diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 8378f080..0e8c98f0 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -149,7 +149,7 @@ class MacOSBuilder extends BuilderBase SourcePatcher::patchBeforeConfigure($this); $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; - $zts = $this->getOption('enable-zts', false) ? '--enable-zts ' : ''; + $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : ''; shell()->cd(SOURCE_PATH . '/php-src') ->exec( From 4a4b0e209c34f76a64b401e73ec4816a1f70fd39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 21 Aug 2023 12:54:36 +0200 Subject: [PATCH 099/296] detect PHP 8.1+ --- src/SPC/builder/linux/LinuxBuilder.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 6ed41c1b..04a7ad86 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -168,8 +168,11 @@ class LinuxBuilder extends BuilderBase SourcePatcher::patchBeforeConfigure($this); - $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; - $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals --enable-zend-max-execution-timers ' : ''; + $phpVersionID = $this->getPHPVersionID(); + + $json_74 = $phpVersionID < 80000 ? '--enable-json ' : ''; + $maxExecutionTimers = $this->getOption('enable-zts', false) && $this->getPHPVersionID() > 81000 ? '--enable-zend-max-execution-timers ' : ''; + $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : ''; shell()->cd(SOURCE_PATH . '/php-src') ->exec( @@ -185,6 +188,7 @@ class LinuxBuilder extends BuilderBase '--enable-fpm ' . $json_74 . $zts . + $maxExecutionTimers . '--enable-micro=all-static ' . $this->makeExtensionArgs() . ' ' . $envs From f4327c8c812a86744872b8231ac8003718bfb8a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 21 Aug 2023 18:37:00 +0200 Subject: [PATCH 100/296] fix --- src/SPC/builder/linux/LinuxBuilder.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 04a7ad86..09d6fbdf 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -169,10 +169,15 @@ class LinuxBuilder extends BuilderBase SourcePatcher::patchBeforeConfigure($this); $phpVersionID = $this->getPHPVersionID(); - $json_74 = $phpVersionID < 80000 ? '--enable-json ' : ''; - $maxExecutionTimers = $this->getOption('enable-zts', false) && $this->getPHPVersionID() > 81000 ? '--enable-zend-max-execution-timers ' : ''; - $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : ''; + + if ($this->getOption('enable-zts', false)) { + $maxExecutionTimers = $phpVersionID >= 80100 ? '--enable-zend-max-execution-timers ' : ''; + $zts = '--enable-zts --disable-zend-signals '; + } else { + $maxExecutionTimers = ''; + $zts = ''; + } shell()->cd(SOURCE_PATH . '/php-src') ->exec( From 4c46f6a7628b1950d2d9d6077c01d66b8957c6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 21 Aug 2023 22:16:42 +0200 Subject: [PATCH 101/296] fix: error when source doesn't exist --- src/SPC/store/Downloader.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 997545f7..c8bdf179 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -253,6 +253,12 @@ class Downloader $source = Config::getSource($name); } + if ($source === null) { + logger()->warning('Source {name} unknown. Skipping.', ['name' => $name]); + + return; + } + // load lock file if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { $lock = []; From 15905c063a3c6c790ef09a8ec883b0e528a91186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 21 Aug 2023 21:47:35 +0200 Subject: [PATCH 102/296] fix: use apt-get instead of apt --- src/SPC/doctor/item/LinuxMuslCheck.php | 2 +- src/SPC/doctor/item/LinuxToolCheckList.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index 9eeb6f53..28232a9e 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -37,7 +37,7 @@ class LinuxMuslCheck public function fixMusl(array $distro): bool { $install_cmd = match ($distro['dist']) { - 'ubuntu', 'debian' => 'apt install musl musl-tools -y', + 'ubuntu', 'debian' => 'apt-get install musl musl-tools -y', 'alpine' => 'apk add musl musl-utils musl-dev', default => throw new RuntimeException('Current linux distro is not supported for auto-install musl packages'), }; diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 68ab6f79..491e988e 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -77,7 +77,7 @@ class LinuxToolCheckList public function fixBuildTools(array $distro, array $missing): bool { $install_cmd = match ($distro['dist']) { - 'ubuntu', 'debian' => 'apt install -y', + 'ubuntu', 'debian' => 'apt-get install -y', 'alpine' => 'apk add', default => throw new RuntimeException('Current linux distro is not supported for auto-install musl packages'), }; From 100d31791a3e77162cb6e6c8e5d6f8354baaa410 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 22 Aug 2023 18:16:23 +0800 Subject: [PATCH 103/296] fix linux builder cpp link option --- src/SPC/builder/linux/LinuxBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 09d6fbdf..431fe490 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -134,7 +134,7 @@ class LinuxBuilder extends BuilderBase $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles()))); } // add libstdc++, some extensions or libraries need it (C++ cannot be linked statically) - $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lc++ ' : ''); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lstdc++ ' : ''); $this->setOption('extra-libs', $extra_libs); $cflags = $this->arch_c_flags; From 3e7ef49bde7d53aa19a51a244d5cd7cd70101dc8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 22 Aug 2023 18:33:34 +0800 Subject: [PATCH 104/296] update README --- README-en.md | 4 ++-- README.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README-en.md b/README-en.md index c5108c21..cd30bb4c 100755 --- a/README-en.md +++ b/README-en.md @@ -37,7 +37,7 @@ Here is the architecture support status, where `CI` represents support for GitHu > macOS-arm64 is not supported for GitHub Actions, if you are going to build on arm, you can build it manually on your own machine. -Currently supported PHP versions for compilation are: `7.4`, `8.0`, `8.1`, `8.2`. +Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`. ## Docs @@ -117,7 +117,7 @@ chmod +x bin/spc You can also use the parameter `--with-php=x.y` to specify the downloaded PHP version, currently supports 7.4 ~ 8.2: ```bash -# Using PHP >= 8.0 is recommended, because 7.4 cannot use phpmicro +# Using PHP >= 8.0 is recommended, because PHP7 cannot use phpmicro ./bin/spc fetch --with-php=8.2 --all ``` diff --git a/README.md b/README.md index 503498e0..57c79e08 100755 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Compile A Statically Linked PHP With Swoole and other Extensions. > macOS-arm64 因 GitHub 暂未提供 arm runner,如果要构建 arm 二进制,可以使用手动构建。 -目前支持编译的 PHP 版本为:`7.4`,`8.0`,`8.1`,`8.2`。 +目前支持编译的 PHP 版本为:`7.3`,`7.4`,`8.0`,`8.1`,`8.2`,`8.3`。 ## 文档 @@ -108,10 +108,10 @@ chmod +x bin/spc ./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro ``` -你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.4 ~ 8.2: +你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.3 ~ 8.3: ```bash -# 优先考虑使用 >= 8.0 的 PHP 版本 +# 优先考虑使用 >= 8.0 的 PHP 版本,因为 phpmicro 不支持在 PHP7 中构建 ./bin/spc fetch --with-php=8.2 --all ``` From cf35a270bb7b06f6de9170895a1e7df34d1ec2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Tue, 22 Aug 2023 10:39:25 +0200 Subject: [PATCH 105/296] minor: read Dockerfile from stdin --- bin/spc-alpine-docker | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index 3d135791..c4ff7d9c 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -52,7 +52,7 @@ fi # Detect docker env is setup if ! $DOCKER_EXECUTABLE images | grep -q cwcc-spc-$SPC_USE_ARCH; then echo "Docker container does not exist. Building docker image ..." - ALPINE_DOCKERFILE=$(cat << EOF + $DOCKER_EXECUTABLE build -t cwcc-spc-$SPC_USE_ARCH -f- . < "$(pwd)"/Dockerfile - - $DOCKER_EXECUTABLE build -t cwcc-spc-$SPC_USE_ARCH . - rm "$(pwd)"/Dockerfile fi # Check if in ci (local terminal can execute with -it) From e7e0ac006f8e9dd9bd053893c917b212facf46bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Tue, 22 Aug 2023 11:13:51 +0200 Subject: [PATCH 106/296] more optims --- bin/setup-runtime | 4 +++- bin/spc-alpine-docker | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/bin/setup-runtime b/bin/setup-runtime index 06ebd749..84061a19 100755 --- a/bin/setup-runtime +++ b/bin/setup-runtime @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # set error-quit, verbose, non-variable-quit set -eu @@ -52,6 +52,8 @@ china) esac +apk add --no-cache curl || true + test -d "${__PROJECT__}"/downloads || mkdir "${__PROJECT__}"/downloads # download static php binary test -f "${__PROJECT__}"/downloads/runtime.tar.gz || { echo "Downloading $__PHP_RUNTIME_URL__ ..." && curl -#fSL -o "${__PROJECT__}"/downloads/runtime.tar.gz "$__PHP_RUNTIME_URL__" ; } diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index c4ff7d9c..b7ca9278 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -55,10 +55,38 @@ if ! $DOCKER_EXECUTABLE images | grep -q cwcc-spc-$SPC_USE_ARCH; then $DOCKER_EXECUTABLE build -t cwcc-spc-$SPC_USE_ARCH -f- . < Date: Tue, 22 Aug 2023 14:26:53 +0200 Subject: [PATCH 107/296] hide warning --- bin/setup-runtime | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/setup-runtime b/bin/setup-runtime index 84061a19..4ae41b7c 100755 --- a/bin/setup-runtime +++ b/bin/setup-runtime @@ -52,7 +52,9 @@ china) esac -apk add --no-cache curl || true +if ! command -v curl &> /dev/null && command -v apk &> /dev/null; then + apk add --no-cache curl +fi test -d "${__PROJECT__}"/downloads || mkdir "${__PROJECT__}"/downloads # download static php binary From 7fb27c0c296ceb06903307ccdcb1af0eaac3a19d Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 23 Aug 2023 10:42:53 +0800 Subject: [PATCH 108/296] fix reference error --- bin/spc-alpine-docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index b7ca9278..39c4729b 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -104,4 +104,4 @@ fi # Run docker # shellcheck disable=SC2068 -$DOCKER_EXECUTABLE run --rm "$INTERACT" -e SPC_FIX_DEPLOY_ROOT="$(pwd)" -v "$(pwd)"/config:/app/config -v "$(pwd)"/src:/app/src -v "$(pwd)"/buildroot:/app/buildroot -v "$(pwd)"/source:/app/source -v "$(pwd)"/downloads:/app/downloads cwcc-spc-$SPC_USE_ARCH bin/spc $@ +$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" -v "$(pwd)"/config:/app/config -v "$(pwd)"/src:/app/src -v "$(pwd)"/buildroot:/app/buildroot -v "$(pwd)"/source:/app/source -v "$(pwd)"/downloads:/app/downloads cwcc-spc-$SPC_USE_ARCH bin/spc $@ From a8924ac4fee2aeae741fe7765b10fd988ecab30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 25 Aug 2023 16:11:28 +0200 Subject: [PATCH 109/296] fix: setup-runtime portability --- bin/setup-runtime | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/setup-runtime b/bin/setup-runtime index 4ae41b7c..b02e3177 100755 --- a/bin/setup-runtime +++ b/bin/setup-runtime @@ -52,7 +52,7 @@ china) esac -if ! command -v curl &> /dev/null && command -v apk &> /dev/null; then +if ! command -v curl > /dev/null && command -v apk > /dev/null; then apk add --no-cache curl fi From 42e5877a7f6f3643cff493c31abf0575c99dd22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 25 Aug 2023 16:31:16 +0200 Subject: [PATCH 110/296] fix: check of xz --- src/SPC/doctor/item/LinuxToolCheckList.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 491e988e..557ba3df 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -28,6 +28,7 @@ class LinuxToolCheckList 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'patch', + 'xz', ]; /** @noinspection PhpUnused */ @@ -87,7 +88,7 @@ class LinuxToolCheckList logger()->warning('Current user is not root, using sudo for running command'); } try { - shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', $missing)); + shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', str_replace('xz', 'xz-utils', $missing))); } catch (RuntimeException) { return false; } From dc12d4d982fb125ded3eed2bb7a159b78753648a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 25 Aug 2023 16:32:56 +0200 Subject: [PATCH 111/296] fix: ExceptionHandler:: must not be accessed before initialization --- src/SPC/exception/ExceptionHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/exception/ExceptionHandler.php b/src/SPC/exception/ExceptionHandler.php index f4bebbf1..544575dc 100644 --- a/src/SPC/exception/ExceptionHandler.php +++ b/src/SPC/exception/ExceptionHandler.php @@ -6,7 +6,7 @@ namespace SPC\exception; class ExceptionHandler { - protected mixed $whoops; + protected mixed $whoops = null; private static ?ExceptionHandler $obj = null; From bcf64cbeefb3701151f33e4bf579592627f61d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 25 Aug 2023 17:35:14 +0200 Subject: [PATCH 112/296] fix: throw if the PHP version doesn't exist --- src/SPC/store/source/PhpSource.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index f23f63ea..ce7483f6 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -35,6 +35,10 @@ class PhpSource extends CustomSourceBase { // 查找最新的小版本号 $info = json_decode(Downloader::curlExec(url: "https://www.php.net/releases/index.php?json&version={$major_version}"), true); + if (!isset($info['version'])) { + throw new DownloaderException("Version {$major_version} not found."); + } + $version = $info['version']; // 从官网直接下载 From 1ebc58664ecfa8785bb845f9076f1082012a249d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sat, 26 Aug 2023 10:51:39 +0200 Subject: [PATCH 113/296] ci: remove useless step and dump Compose autoloader --- .github/workflows/build-linux-x86_64.yml | 7 +------ .github/workflows/build-macos-x86_64.yml | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-linux-x86_64.yml b/.github/workflows/build-linux-x86_64.yml index 446f8f09..90705f33 100644 --- a/.github/workflows/build-linux-x86_64.yml +++ b/.github/workflows/build-linux-x86_64.yml @@ -40,11 +40,6 @@ jobs: steps: - uses: actions/checkout@v3 - # Install Ubuntu missing packages and mark os suffix - - run: | - sudo apt install musl-tools -y - echo "SPC_BUILD_OS=linux" >> $GITHUB_ENV - # Cache composer dependencies - id: cache-composer-deps uses: actions/cache@v3 @@ -54,7 +49,7 @@ jobs: # If there's no Composer cache, install dependencies - if: steps.cache-composer-deps.outputs.cache-hit != 'true' - run: composer update --no-dev + run: composer update --no-dev --classmap-authoritative # Cache downloaded source - id: cache-download diff --git a/.github/workflows/build-macos-x86_64.yml b/.github/workflows/build-macos-x86_64.yml index 3aa44541..6727fcbd 100644 --- a/.github/workflows/build-macos-x86_64.yml +++ b/.github/workflows/build-macos-x86_64.yml @@ -54,7 +54,7 @@ jobs: # If there's no Composer cache, install dependencies - if: steps.cache-composer-deps.outputs.cache-hit != 'true' - run: composer update --no-dev + run: composer update --no-dev --classmap-authoritative # Cache downloaded source - id: cache-download From 238fd7fc743e2fc61f783a32b6e7521b22ecc350 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 26 Aug 2023 23:31:56 +0800 Subject: [PATCH 114/296] add libxslt source --- config/source.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/source.json b/config/source.json index e1fa90ad..b1627f82 100644 --- a/config/source.json +++ b/config/source.json @@ -16,6 +16,15 @@ "path": "LICENSE" } }, + "libxslt": { + "type": "filelist", + "url": "https://download.gnome.org/sources/libxslt/1.1/", + "regex": "/href=\"(?libxslt-(?[^\"]+)\\.tar\\.xz)\"/", + "license": { + "type": "text", + "text": "TODO" + } + }, "brotli": { "type": "ghtar", "repo": "google/brotli", From 6c49d35aec7bc53aee7c52041345b2f3b8d1f821 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 26 Aug 2023 23:50:24 +0800 Subject: [PATCH 115/296] add libxslt compile command --- config/ext.json | 6 +++- config/lib.json | 10 +++++++ config/source.json | 18 ++++++------ src/SPC/builder/linux/library/libxslt.php | 15 ++++++++++ src/SPC/builder/macos/library/libxslt.php | 15 ++++++++++ src/SPC/builder/unix/library/libxslt.php | 35 +++++++++++++++++++++++ 6 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 src/SPC/builder/linux/library/libxslt.php create mode 100644 src/SPC/builder/macos/library/libxslt.php create mode 100644 src/SPC/builder/unix/library/libxslt.php diff --git a/config/ext.json b/config/ext.json index 67b96622..4cd15da2 100644 --- a/config/ext.json +++ b/config/ext.json @@ -449,9 +449,13 @@ }, "xsl": { "type": "builtin", - "arg-type": "with", + "arg-type": "with-prefix", "lib-depends": [ "libxslt" + ], + "ext-depends": [ + "xml", + "dom" ] }, "yaml": { diff --git a/config/lib.json b/config/lib.json index d07a069a..668e97d9 100644 --- a/config/lib.json +++ b/config/lib.json @@ -293,6 +293,16 @@ "pthreads4w" ] }, + "libxslt": { + "source": "libxslt", + "static-libs-unix": [ + "libxslt.a", + "libexslt.a" + ], + "lib-depends": [ + "libxml2" + ] + }, "libyaml": { "source": "libyaml", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index b1627f82..8f7eeebe 100644 --- a/config/source.json +++ b/config/source.json @@ -16,15 +16,6 @@ "path": "LICENSE" } }, - "libxslt": { - "type": "filelist", - "url": "https://download.gnome.org/sources/libxslt/1.1/", - "regex": "/href=\"(?libxslt-(?[^\"]+)\\.tar\\.xz)\"/", - "license": { - "type": "text", - "text": "TODO" - } - }, "brotli": { "type": "ghtar", "repo": "google/brotli", @@ -263,6 +254,15 @@ "path": "Copyright" } }, + "libxslt": { + "type": "filelist", + "url": "https://download.gnome.org/sources/libxslt/1.1/", + "regex": "/href=\"(?libxslt-(?[^\"]+)\\.tar\\.xz)\"/", + "license": { + "type": "text", + "text": "TODO" + } + }, "libyaml": { "type": "ghrel", "repo": "yaml/libyaml", diff --git a/src/SPC/builder/linux/library/libxslt.php b/src/SPC/builder/linux/library/libxslt.php new file mode 100644 index 00000000..4bc4a27e --- /dev/null +++ b/src/SPC/builder/linux/library/libxslt.php @@ -0,0 +1,15 @@ +cd($this->source_dir) + ->exec( + "{$this->builder->configure_env} ./configure " . + '--enable-static --disable-shared ' . + '--without-python ' . + '--without-mem-debug ' . + '--without-crypto ' . + '--without-debug ' . + '--without-debugger ' . + '--with-libxml-prefix=' . escapeshellarg(BUILD_ROOT_PATH) . ' ' . + '--prefix=' + ) + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . escapeshellarg(BUILD_ROOT_PATH)); + $this->patchPkgconfPrefix(['libexslt.pc']); + } +} From ed227ce00ee255c8c7353d2a666b39166e829280 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 26 Aug 2023 23:51:24 +0800 Subject: [PATCH 116/296] fix linux libxml2 #75 issue --- src/SPC/builder/linux/library/libxml2.php | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php index 7a26578b..9856f527 100644 --- a/src/SPC/builder/linux/library/libxml2.php +++ b/src/SPC/builder/linux/library/libxml2.php @@ -19,21 +19,22 @@ class libxml2 extends LinuxLibraryBase public function build(): void { $enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF'; - $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF'; + // $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF'; $enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF'; - [, , $destdir] = SEPARATED_PATH; - FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( "{$this->builder->configure_env} " . ' cmake ' . - "{$this->builder->makeCmakeArgs()} " . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DCMAKE_INSTALL_PREFIX=' . escapeshellarg(BUILD_ROOT_PATH) . ' ' . '-DBUILD_SHARED_LIBS=OFF ' . + '-DCMAKE_INSTALL_BINDIR=' . escapeshellarg(BUILD_ROOT_PATH . '/bin') . ' ' . '-DLIBXML2_WITH_ICONV=ON ' . '-DIconv_IS_BUILT_IN=OFF ' . "-DLIBXML2_WITH_ZLIB={$enable_zlib} " . - "-DLIBXML2_WITH_ICU={$enable_icu} " . + '-DLIBXML2_WITH_ICU=OFF ' . "-DLIBXML2_WITH_LZMA={$enable_xz} " . '-DLIBXML2_WITH_PYTHON=OFF ' . '-DLIBXML2_WITH_PROGRAMS=OFF ' . @@ -41,15 +42,6 @@ class libxml2 extends LinuxLibraryBase '..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec("make install DESTDIR={$destdir}"); - - if (is_dir(BUILD_INCLUDE_PATH . '/libxml2/libxml')) { - if (is_dir(BUILD_INCLUDE_PATH . '/libxml')) { - shell()->exec('rm -rf "' . BUILD_INCLUDE_PATH . '/libxml"'); - } - $path = FileSystem::convertPath(BUILD_INCLUDE_PATH . '/libxml2/libxml'); - $dst_path = FileSystem::convertPath(BUILD_INCLUDE_PATH . '/'); - shell()->exec('mv "' . $path . '" "' . $dst_path . '"'); - } + ->exec('make install'); } } From 42fbf18bba8eb35da4b04e9f25c40bd0a461806c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 27 Aug 2023 00:14:39 +0800 Subject: [PATCH 117/296] update license --- config/source.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/source.json b/config/source.json index 8f7eeebe..9d98174c 100644 --- a/config/source.json +++ b/config/source.json @@ -259,8 +259,8 @@ "url": "https://download.gnome.org/sources/libxslt/1.1/", "regex": "/href=\"(?libxslt-(?[^\"]+)\\.tar\\.xz)\"/", "license": { - "type": "text", - "text": "TODO" + "type": "file", + "text": "COPYING" } }, "libyaml": { From 5359f3a79a63d50dcc23451c04241c55c388bb8b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 27 Aug 2023 03:05:53 +0800 Subject: [PATCH 118/296] fix webp compile to cmake, fix #95 --- src/SPC/builder/unix/library/libwebp.php | 30 ++++++++++-------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/SPC/builder/unix/library/libwebp.php b/src/SPC/builder/unix/library/libwebp.php index ce7bd58e..3cdeb3ff 100644 --- a/src/SPC/builder/unix/library/libwebp.php +++ b/src/SPC/builder/unix/library/libwebp.php @@ -7,6 +7,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; +use SPC\store\FileSystem; trait libwebp { @@ -17,25 +18,20 @@ trait libwebp */ protected function build(): void { - [,,$destdir] = SEPARATED_PATH; - - shell()->cd($this->source_dir) - ->exec('./autogen.sh') + // CMake needs a clean build directory + FileSystem::resetDir($this->source_dir . '/build'); + // Start build + shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} ./configure " . - '--enable-static ' . - '--disable-shared ' . - '--prefix= ' . - '--enable-libwebpdecoder ' . - '--enable-libwebpextras ' . - '--disable-tiff ' . - '--disable-gl ' . - '--disable-sdl ' . - '--disable-wic' + "{$this->builder->configure_env} cmake " . + $this->builder->makeCmakeArgs() . ' ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DWEBP_BUILD_EXTRAS=ON ' . + '..' ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . $destdir); + ->exec("cmake --build . -j {$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + // patch pkgconfig $this->patchPkgconfPrefix(['libsharpyuv.pc', 'libwebp.pc', 'libwebpdecoder.pc', 'libwebpdemux.pc', 'libwebpmux.pc'], PKGCONF_PATCH_PREFIX); $this->cleanLaFiles(); } From f90892c92f53da7bdab9032a5f21286c7f9f8afa Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 27 Aug 2023 03:23:11 +0800 Subject: [PATCH 119/296] fix curl in musl-gcc bug, fix #88 --- src/SPC/builder/unix/library/curl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index aa5ef28a..94b7fb61 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -51,6 +51,7 @@ trait curl FileSystem::resetDir($this->source_dir . '/build'); // compile! shell()->cd($this->source_dir . '/build') + ->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt') ->exec("{$this->builder->configure_env} cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF {$extra} ..") ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); From 92861537428ec6de093acffd8b139f0a625a0362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 28 Aug 2023 16:57:00 +0200 Subject: [PATCH 120/296] fix: linxml build on macOS --- config/lib.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/lib.json b/config/lib.json index 668e97d9..700066b2 100644 --- a/config/lib.json +++ b/config/lib.json @@ -279,17 +279,16 @@ "libxml2" ], "lib-depends": [ - "libiconv" + "libiconv", + "zlib" ], "lib-suggests": [ "xz", - "zlib", "icu" ], "lib-suggests-windows": [ "icu", "xz", - "zlib", "pthreads4w" ] }, From dc28ce0899ce35c59fd16358ba2a55046b39538e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 30 Aug 2023 16:56:11 +0200 Subject: [PATCH 121/296] fix: curl dependency on openssl --- config/lib.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/lib.json b/config/lib.json index 700066b2..490450d5 100644 --- a/config/lib.json +++ b/config/lib.json @@ -42,14 +42,14 @@ "curl" ], "lib-depends-unix": [ + "openssl", "zlib" ], "lib-suggests": [ "libssh2", "brotli", "nghttp2", - "zstd", - "openssl" + "zstd" ], "lib-suggests-windows": [ "zlib", From 6de5c1dab04f468d205634ff845c463f6cf0280b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 31 Aug 2023 20:26:52 +0800 Subject: [PATCH 122/296] Remove unused source libressl --- config/source.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/config/source.json b/config/source.json index 9d98174c..324292a1 100644 --- a/config/source.json +++ b/config/source.json @@ -212,15 +212,6 @@ "text": "COPYRIGHT NOTICE, DISCLAIMER, and LICENSE\n=========================================\n\nPNG Reference Library License version 2\n---------------------------------------\n\n * Copyright (c) 1995-2019 The PNG Reference Library Authors.\n * Copyright (c) 2018-2019 Cosmin Truta.\n * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.\n * Copyright (c) 1996-1997 Andreas Dilger.\n * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n\nThe software is supplied \"as is\", without warranty of any kind,\nexpress or implied, including, without limitation, the warranties\nof merchantability, fitness for a particular purpose, title, and\nnon-infringement. In no event shall the Copyright owners, or\nanyone distributing the software, be liable for any damages or\nother liability, whether in contract, tort or otherwise, arising\nfrom, out of, or in connection with the software, or the use or\nother dealings in the software, even if advised of the possibility\nof such damage.\n\nPermission is hereby granted to use, copy, modify, and distribute\nthis software, or portions hereof, for any purpose, without fee,\nsubject to the following restrictions:\n\n 1. The origin of this software must not be misrepresented; you\n must not claim that you wrote the original software. If you\n use this software in a product, an acknowledgment in the product\n documentation would be appreciated, but is not required.\n\n 2. Altered source versions must be plainly marked as such, and must\n not be misrepresented as being the original software.\n\n 3. This Copyright notice may not be removed or altered from any\n source or altered source distribution.\n\n\nPNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)\n-----------------------------------------------------------------------\n\nlibpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are\nCopyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are\nderived from libpng-1.0.6, and are distributed according to the same\ndisclaimer and license as libpng-1.0.6 with the following individuals\nadded to the list of Contributing Authors:\n\n Simon-Pierre Cadieux\n Eric S. Raymond\n Mans Rullgard\n Cosmin Truta\n Gilles Vollant\n James Yu\n Mandar Sahastrabuddhe\n Google Inc.\n Vadim Barkov\n\nand with the following additions to the disclaimer:\n\n There is no warranty against interference with your enjoyment of\n the library or against infringement. There is no warranty that our\n efforts or the library will fulfill any of your particular purposes\n or needs. This library is provided with all faults, and the entire\n risk of satisfactory quality, performance, accuracy, and effort is\n with the user.\n\nSome files in the \"contrib\" directory and some configure-generated\nfiles that are distributed with libpng have other copyright owners, and\nare released under other open source licenses.\n\nlibpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are\nCopyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from\nlibpng-0.96, and are distributed according to the same disclaimer and\nlicense as libpng-0.96, with the following individuals added to the\nlist of Contributing Authors:\n\n Tom Lane\n Glenn Randers-Pehrson\n Willem van Schaik\n\nlibpng versions 0.89, June 1996, through 0.96, May 1997, are\nCopyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,\nand are distributed according to the same disclaimer and license as\nlibpng-0.88, with the following individuals added to the list of\nContributing Authors:\n\n John Bowler\n Kevin Bracey\n Sam Bushell\n Magnus Holmgren\n Greg Roelofs\n Tom Tanner\n\nSome files in the \"scripts\" directory have other copyright owners,\nbut are released under this license.\n\nlibpng versions 0.5, May 1995, through 0.88, January 1996, are\nCopyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n\nFor the purposes of this copyright and license, \"Contributing Authors\"\nis defined as the following set of individuals:\n\n Andreas Dilger\n Dave Martindale\n Guy Eric Schalnat\n Paul Schmidt\n Tim Wegner\n\nThe PNG Reference Library is supplied \"AS IS\". The Contributing\nAuthors and Group 42, Inc. disclaim all warranties, expressed or\nimplied, including, without limitation, the warranties of\nmerchantability and of fitness for any purpose. The Contributing\nAuthors and Group 42, Inc. assume no liability for direct, indirect,\nincidental, special, exemplary, or consequential damages, which may\nresult from the use of the PNG Reference Library, even if advised of\nthe possibility of such damage.\n\nPermission is hereby granted to use, copy, modify, and distribute this\nsource code, or portions hereof, for any purpose, without fee, subject\nto the following restrictions:\n\n 1. The origin of this source code must not be misrepresented.\n\n 2. Altered versions must be plainly marked as such and must not\n be misrepresented as being the original source.\n\n 3. This Copyright notice may not be removed or altered from any\n source or altered source distribution.\n\nThe Contributing Authors and Group 42, Inc. specifically permit,\nwithout fee, and encourage the use of this source code as a component\nto supporting the PNG file format in commercial products. If you use\nthis source code in a product, acknowledgment is not required but would\nbe appreciated.\n" } }, - "libressl": { - "type": "filelist", - "url": "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/", - "regex": "/href=\"(?libressl-(?[^\"]+)\\.tar\\.gz)\"/", - "license": { - "type": "file", - "path": "COPYING" - } - }, "libsodium": { "type": "url", "url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz", From fdc3a7a04b6f567391950f95411b9d8e4aea1153 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Sun, 3 Sep 2023 15:49:15 +0200 Subject: [PATCH 123/296] Add snappy extension --- config/ext.json | 13 +++++++++- config/lib.json | 15 ++++++++++- config/source.json | 22 +++++++++++++++- src/SPC/builder/extension/snappy.php | 17 +++++++++++++ src/SPC/builder/linux/library/snappy.php | 12 +++++++++ src/SPC/builder/macos/library/snappy.php | 12 +++++++++ src/SPC/builder/unix/library/snappy.php | 32 ++++++++++++++++++++++++ 7 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 src/SPC/builder/extension/snappy.php create mode 100644 src/SPC/builder/linux/library/snappy.php create mode 100644 src/SPC/builder/macos/library/snappy.php create mode 100644 src/SPC/builder/unix/library/snappy.php diff --git a/config/ext.json b/config/ext.json index 4cd15da2..00f60518 100644 --- a/config/ext.json +++ b/config/ext.json @@ -325,6 +325,17 @@ "libxml2" ] }, + "snappy": { + "type": "external", + "source": "ext-snappy", + "arg-type": "custom", + "lib-depends": [ + "snappy" + ], + "ext-suggest": [ + "apcu" + ] + }, "snmp": { "type": "builtin", "arg-type": "with", @@ -490,4 +501,4 @@ "zstd" ] } -} \ No newline at end of file +} diff --git a/config/lib.json b/config/lib.json index 490450d5..ebcbe668 100644 --- a/config/lib.json +++ b/config/lib.json @@ -510,5 +510,18 @@ "zstd.h", "zstd_errors.h" ] + }, + "snappy": { + "source": "snappy", + "static-libs-unix": [ + "libsnappy.a" + ], + "headers-unix": [ + "snappy-c.h", + "snappy-sinksource.h", + "snappy.h", + "snappy-stubs-internal.h", + "snappy-stubs-public.h" + ] } -} \ No newline at end of file +} diff --git a/config/source.json b/config/source.json index 324292a1..2f1e2e41 100644 --- a/config/source.json +++ b/config/source.json @@ -80,6 +80,16 @@ "path": "LICENSE" } }, + "ext-snappy": { + "type": "git", + "path": "php-src/ext/snappy", + "rev": "master", + "url": "https://github.com/kjdev/php-ext-snappy", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-ssh2": { "type": "url", "url": "https://pecl.php.net/get/ssh2", @@ -401,6 +411,16 @@ "path": "COPYING" } }, + "snappy": { + "type": "git", + "repo": "google/snappy", + "rev": "main", + "url": "https://github.com/google/snappy", + "license": { + "type": "file", + "path": "COPYING" + } + }, "sqlite": { "type": "url", "url": "https://www.sqlite.org/2023/sqlite-autoconf-3410100.tar.gz", @@ -476,4 +496,4 @@ "path": "LICENSE" } } -} \ No newline at end of file +} diff --git a/src/SPC/builder/extension/snappy.php b/src/SPC/builder/extension/snappy.php new file mode 100644 index 00000000..065b33a7 --- /dev/null +++ b/src/SPC/builder/extension/snappy.php @@ -0,0 +1,17 @@ +source_dir . '/cmake/build'); + + shell()->cd($this->source_dir . '/cmake/build') + ->exec( + "{$this->builder->configure_env} cmake " . + "{$this->builder->makeCmakeArgs()} " . + '-DSNAPPY_BUILD_TESTS=OFF ' . + '-DSNAPPY_BUILD_BENCHMARKS=OFF ' . + '../..' + ) + ->exec("cmake --build . -j {$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + } +} From 0381a1c412d97b6ac447c73dc99e9c4e549e9c45 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Sun, 3 Sep 2023 18:59:00 +0200 Subject: [PATCH 124/296] Adjust extension definition after review --- config/ext.json | 1 + config/lib.json | 3 +++ src/SPC/builder/extension/snappy.php | 16 ++++++++++++++++ src/SPC/builder/unix/library/snappy.php | 6 ++++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/config/ext.json b/config/ext.json index 00f60518..d5234e4e 100644 --- a/config/ext.json +++ b/config/ext.json @@ -328,6 +328,7 @@ "snappy": { "type": "external", "source": "ext-snappy", + "cpp-extension": true, "arg-type": "custom", "lib-depends": [ "snappy" diff --git a/config/lib.json b/config/lib.json index ebcbe668..f4558f83 100644 --- a/config/lib.json +++ b/config/lib.json @@ -522,6 +522,9 @@ "snappy.h", "snappy-stubs-internal.h", "snappy-stubs-public.h" + ], + "lib-depends": [ + "zlib" ] } } diff --git a/src/SPC/builder/extension/snappy.php b/src/SPC/builder/extension/snappy.php index 065b33a7..ad80518f 100644 --- a/src/SPC/builder/extension/snappy.php +++ b/src/SPC/builder/extension/snappy.php @@ -5,11 +5,27 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\builder\macos\MacOSBuilder; +use SPC\exception\FileSystemException; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('snappy')] class snappy extends Extension { + /** + * @throws FileSystemException + */ + public function patchBeforeConfigure(): bool + { + FileSystem::replaceFileRegex( + SOURCE_PATH . '/php-src/configure', + '/-lsnappy/', + $this->getLibFilesString() . $this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++' + ); + return true; + } + public function getUnixConfigureArg(): string { return '--enable-snappy --with-snappy-includedir="' . BUILD_ROOT_PATH . '"'; diff --git a/src/SPC/builder/unix/library/snappy.php b/src/SPC/builder/unix/library/snappy.php index b7924de2..112cf5ed 100644 --- a/src/SPC/builder/unix/library/snappy.php +++ b/src/SPC/builder/unix/library/snappy.php @@ -21,12 +21,14 @@ trait snappy shell()->cd($this->source_dir . '/cmake/build') ->exec( "{$this->builder->configure_env} cmake " . - "{$this->builder->makeCmakeArgs()} " . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DCMAKE_INSTALL_PREFIX=' . escapeshellarg(BUILD_ROOT_PATH) . ' ' . '-DSNAPPY_BUILD_TESTS=OFF ' . '-DSNAPPY_BUILD_BENCHMARKS=OFF ' . '../..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->exec('make install'); } } From 88e96394827dc3527ddb14708525b216df4bcd08 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Sun, 3 Sep 2023 19:22:10 +0200 Subject: [PATCH 125/296] Fix operator precedence --- src/SPC/builder/extension/snappy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/snappy.php b/src/SPC/builder/extension/snappy.php index ad80518f..2dc2a33a 100644 --- a/src/SPC/builder/extension/snappy.php +++ b/src/SPC/builder/extension/snappy.php @@ -21,7 +21,7 @@ class snappy extends Extension FileSystem::replaceFileRegex( SOURCE_PATH . '/php-src/configure', '/-lsnappy/', - $this->getLibFilesString() . $this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++' + $this->getLibFilesString() . ($this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++') ); return true; } From 3d2f6e4c3ad504c6043cdcb3072d4f63cc3f12f2 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Mon, 4 Sep 2023 10:41:38 +0200 Subject: [PATCH 126/296] Sort lib definition --- config/lib.json | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/config/lib.json b/config/lib.json index f4558f83..606a1be4 100644 --- a/config/lib.json +++ b/config/lib.json @@ -445,6 +445,22 @@ "ncurses" ] }, + "snappy": { + "source": "snappy", + "static-libs-unix": [ + "libsnappy.a" + ], + "headers-unix": [ + "snappy-c.h", + "snappy-sinksource.h", + "snappy.h", + "snappy-stubs-internal.h", + "snappy-stubs-public.h" + ], + "lib-depends": [ + "zlib" + ] + }, "sqlite": { "source": "sqlite", "static-libs-unix": [ @@ -510,21 +526,5 @@ "zstd.h", "zstd_errors.h" ] - }, - "snappy": { - "source": "snappy", - "static-libs-unix": [ - "libsnappy.a" - ], - "headers-unix": [ - "snappy-c.h", - "snappy-sinksource.h", - "snappy.h", - "snappy-stubs-internal.h", - "snappy-stubs-public.h" - ], - "lib-depends": [ - "zlib" - ] } } From 8d348b9e14f6ea5d576c869fc2c438b2533dbc1f Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Mon, 4 Sep 2023 14:13:15 +0200 Subject: [PATCH 127/296] Allow setting multiple license in extensions, libraries & sources --- src/SPC/util/LicenseDumper.php | 45 ++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/SPC/util/LicenseDumper.php b/src/SPC/util/LicenseDumper.php index 32bbdc93..4ebff36b 100644 --- a/src/SPC/util/LicenseDumper.php +++ b/src/SPC/util/LicenseDumper.php @@ -45,46 +45,58 @@ class LicenseDumper { // mkdir first if (is_dir($target_dir) && !FileSystem::removeDir($target_dir)) { - logger()->warning('Target dump directory is noe empty, be aware!'); + logger()->warning('Target dump directory is not empty, be aware!'); } FileSystem::createDir($target_dir); foreach ($this->exts as $ext) { if (Config::getExt($ext, 'type') !== 'external') { continue; } + $source_name = Config::getExt($ext, 'source'); - $content = $this->getSourceLicense($source_name); - file_put_contents($target_dir . '/ext_' . $ext . '.txt', $content); + foreach ($this->getSourceLicenses($source_name) as $index => $license) { + file_put_contents("{$target_dir}/ext_{$ext}_{$index}.txt", $license); + } } foreach ($this->libs as $lib) { $source_name = Config::getLib($lib, 'source'); - $content = $this->getSourceLicense($source_name); - file_put_contents($target_dir . '/lib_' . $lib . '.txt', $content); + foreach ($this->getSourceLicenses($source_name) as $index => $license) { + file_put_contents("{$target_dir}/lib_{$lib}_{$index}.txt", $license); + } } foreach ($this->sources as $source) { - file_put_contents($target_dir . '/src_' . $source . '.txt', $this->getSourceLicense($source)); + foreach ($this->getSourceLicenses($source) as $index => $license) { + file_put_contents("{$target_dir}/src_{$source}_{$index}.txt", $license); + } } return true; } /** + * @return string[] * @throws FileSystemException * @throws RuntimeException */ - private function getSourceLicense(string $source_name): ?string + private function getSourceLicenses(string $source_name): iterable { - $src = Config::getSource($source_name)['license'] ?? null; - if ($src === null) { - throw new RuntimeException('source [' . $source_name . '] license meta is not exist'); + $licenses = Config::getSource($source_name)['license'] ?? []; + if ($licenses === []) { + throw new RuntimeException('source [' . $source_name . '] license meta not exist'); } - return match ($src['type']) { - 'text' => $src['text'], - 'file' => $this->loadSourceFile($source_name, $src['path'], Config::getSource($source_name)['path'] ?? null), - default => throw new RuntimeException('source [' . $source_name . '] license type is not allowed'), - }; + if (!array_is_list($licenses)) { + $licenses = [$licenses]; + } + + foreach ($licenses as $license) { + yield match ($license['type']) { + 'text' => $license['text'], + 'file' => $this->loadSourceFile($source_name, $license['path'], Config::getSource($source_name)['path'] ?? null), + default => throw new RuntimeException('source [' . $source_name . '] license type is not allowed'), + }; + } } /** @@ -93,8 +105,9 @@ class LicenseDumper private function loadSourceFile(string $source_name, string $in_path, ?string $custom_base_path = null): string { if (!file_exists(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $in_path)) { - throw new RuntimeException('source [' . $source_name . '] license file [' . $in_path . '] is not exist'); + throw new RuntimeException('source [' . $source_name . '] license file [' . $in_path . '] not exist'); } + return file_get_contents(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $in_path); } } From 33798ff108dce9a2c9578cd04e8c5660cd14b4f4 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 5 Sep 2023 12:28:12 +0200 Subject: [PATCH 128/296] Add simple unit test --- .gitignore | 6 ++- .php-cs-fixer.php | 2 +- composer.json | 16 ++++-- tests/SPC/util/LicenseDumperTest.php | 80 ++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 tests/SPC/util/LicenseDumperTest.php diff --git a/.gitignore b/.gitignore index 23162fad..278ef459 100644 --- a/.gitignore +++ b/.gitignore @@ -17,11 +17,15 @@ composer.lock # default source build root directory /buildroot/ -# php cs fixer cache file +# tools cache files .php-cs-fixer.cache +.phpunit.result.cache # exclude self-runtime /bin/* !/bin/spc !/bin/setup-runtime !/bin/spc-alpine-docker + +# default test directory +/tests/var/ diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index e3778666..143407b8 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -65,5 +65,5 @@ return (new PhpCsFixer\Config()) 'phpdoc_var_without_name' => false, ]) ->setFinder( - PhpCsFixer\Finder::create()->in(__DIR__ . '/src') + PhpCsFixer\Finder::create()->in([__DIR__ . '/src', __DIR__ . '/tests/SPC']) ); diff --git a/composer.json b/composer.json index 4249d0d2..a23d7adf 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,12 @@ "zhamao/logger": "^1.0" }, "require-dev": { - "nunomaduro/collision": "*", - "friendsofphp/php-cs-fixer": "^3.2 != 3.7.0", - "phpstan/phpstan": "^1.1", "captainhook/captainhook": "^5.10", - "captainhook/plugin-composer": "^5.3" + "captainhook/plugin-composer": "^5.3", + "friendsofphp/php-cs-fixer": "^3.2 != 3.7.0", + "nunomaduro/collision": "*", + "phpstan/phpstan": "^1.1", + "phpunit/phpunit": "^10.3" }, "autoload": { "psr-4": { @@ -32,13 +33,18 @@ "src/globals/functions.php" ] }, + "autoload-dev": { + "psr-4": { + "SPC\\Tests\\": "tests/SPC" + } + }, "bin": [ "bin/spc" ], "scripts": { "analyse": "phpstan analyse --memory-limit 300M", "cs-fix": "php-cs-fixer fix", - "test": "bin/phpunit --no-coverage" + "test": "vendor/bin/phpunit tests/ --no-coverage" }, "config": { "allow-plugins": { diff --git a/tests/SPC/util/LicenseDumperTest.php b/tests/SPC/util/LicenseDumperTest.php new file mode 100644 index 00000000..18a31277 --- /dev/null +++ b/tests/SPC/util/LicenseDumperTest.php @@ -0,0 +1,80 @@ + [ + 'source' => 'fake_lib', + ], + ]; + Config::$source = [ + 'fake_lib' => [ + 'license' => [ + 'type' => 'text', + 'text' => 'license', + ], + ], + ]; + + $dumper = new LicenseDumper(); + $dumper->addLibs(['fake_lib']); + $dumper->dump(self::DIRECTORY); + + $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_0.txt'); + } + + public function testDumpWithMultipleLicenses(): void + { + Config::$lib = [ + 'fake_lib' => [ + 'source' => 'fake_lib', + ], + ]; + Config::$source = [ + 'fake_lib' => [ + 'license' => [ + [ + 'type' => 'text', + 'text' => 'license', + ], + [ + 'type' => 'text', + 'text' => 'license', + ], + ], + ], + ]; + + $dumper = new LicenseDumper(); + $dumper->addLibs(['fake_lib']); + $dumper->dump(self::DIRECTORY); + + $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_0.txt'); + $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_1.txt'); + } +} From c0830a9e1f15546510a270e1774c71a361970ad6 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 5 Sep 2023 20:05:09 +0200 Subject: [PATCH 129/296] Allow setting suffix for licence name --- src/SPC/util/LicenseDumper.php | 4 ++-- tests/SPC/util/LicenseDumperTest.php | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/SPC/util/LicenseDumper.php b/src/SPC/util/LicenseDumper.php index 4ebff36b..d5f43909 100644 --- a/src/SPC/util/LicenseDumper.php +++ b/src/SPC/util/LicenseDumper.php @@ -90,8 +90,8 @@ class LicenseDumper $licenses = [$licenses]; } - foreach ($licenses as $license) { - yield match ($license['type']) { + foreach ($licenses as $index => $license) { + yield ($license['suffix'] ?? $index) => match ($license['type']) { 'text' => $license['text'], 'file' => $this->loadSourceFile($source_name, $license['path'], Config::getSource($source_name)['path'] ?? null), default => throw new RuntimeException('source [' . $source_name . '] license type is not allowed'), diff --git a/tests/SPC/util/LicenseDumperTest.php b/tests/SPC/util/LicenseDumperTest.php index 18a31277..e1ca06c9 100644 --- a/tests/SPC/util/LicenseDumperTest.php +++ b/tests/SPC/util/LicenseDumperTest.php @@ -37,6 +37,7 @@ final class LicenseDumperTest extends TestCase 'license' => [ 'type' => 'text', 'text' => 'license', + 'suffix' => 'zend', ], ], ]; @@ -45,7 +46,7 @@ final class LicenseDumperTest extends TestCase $dumper->addLibs(['fake_lib']); $dumper->dump(self::DIRECTORY); - $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_0.txt'); + $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_zend.txt'); } public function testDumpWithMultipleLicenses(): void @@ -66,6 +67,11 @@ final class LicenseDumperTest extends TestCase 'type' => 'text', 'text' => 'license', ], + [ + 'type' => 'text', + 'text' => 'license', + 'suffix' => 'zend', + ], ], ], ]; @@ -76,5 +82,6 @@ final class LicenseDumperTest extends TestCase $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_0.txt'); $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_1.txt'); + $this->assertFileExists(self::DIRECTORY . '/lib_fake_lib_zend.txt'); } } From cae7bb1dda30a8c89a3a347f5acd814c6e89f391 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Wed, 6 Sep 2023 09:13:27 +0200 Subject: [PATCH 130/296] Add GH Action for tests --- .github/workflows/tests.yml | 98 +++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..d7223f64 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,98 @@ +name: Tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + tools: pecl, composer, php-cs-fixer + + - name: Run PHP-CS-Fixer fix + run: php-cs-fixer fix --dry-run --diff --ansi + + phpstan: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + tools: composer + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-phpstan- + + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: Run phpstan + run: vendor/bin/phpstan analyse + + phpunit: + name: PHPUnit (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + matrix: + include: + - php: '8.1' + - php: '8.2' + fail-fast: false + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + tools: pecl, composer + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: Run PHPUnit tests + run: | + vendor/bin/phpunit tests/ --no-coverage From c22c5617ad545543a267410fedec208707ed1176 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 6 Sep 2023 16:05:38 +0800 Subject: [PATCH 131/296] Update README.md --- README.md | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 57c79e08..49d046f5 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # static-php-cli -Compile A Statically Linked PHP With Swoole and other Extensions. +Build single static PHP binary, with PHP project together, with popular extensions included. **If you are using English, see [English README](README-en.md).** @@ -181,18 +181,6 @@ cat micro.sfx code.php > single-app && chmod +x single-app 指定 `php-fpm.conf` 可以使用命令参数 `-y`,例如:`./php-fpm -y php-fpm.conf`。 -## 项目支持情况 - -- [X] 基础结构编写(采用 `symfony/console`) -- [X] 错误处理 -- [X] macOS 支持 -- [ ] Windows 支持 -- [X] Linux 支持 -- [X] PHP 7.4 支持 -- [X] fpm 支持 - -更多功能和特性正在陆续支持中,详见:https://github.com/crazywhalecc/static-php-cli/issues/32 - ## 贡献 目前支持的扩展较少,如果缺少你需要的扩展,可发起 Issue。如果你对本项目较熟悉,也欢迎为本项目发起 Pull Request。 @@ -224,4 +212,4 @@ cat micro.sfx code.php > single-app && chmod +x single-app ## 进阶 -本项目重构分支为模块化编写。如果你对本项目感兴趣,想加入开发,可以参照文档的 [贡献指南](https://static-php-cli.zhamao.me) 贡献代码或文档。(TODO) +本项目重构分支为模块化编写。如果你对本项目感兴趣,想加入开发,可以参照文档的 [贡献指南](https://static-php-cli.zhamao.me) 贡献代码或文档。 From e7230d9f506a9a2055d05429593cf804aaa2784d Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 6 Sep 2023 16:13:43 +0800 Subject: [PATCH 132/296] Update README-en.md --- README-en.md | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/README-en.md b/README-en.md index cd30bb4c..9bacd6e4 100755 --- a/README-en.md +++ b/README-en.md @@ -1,15 +1,15 @@ # static-php-cli -Compile A Statically Linked PHP With Swoole and other Extensions. +Build single static PHP binary, with PHP project together, with popular extensions included. Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI) -截屏2023-05-02 15 53 13 +2023-05-02 15 53 13 You can also use the micro binary file to combine php binary and php source code into one for distribution! This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro). (micro SAPI) -截屏2023-05-02 15 52 33 +2023-05-02 15 52 33 [![Version](https://img.shields.io/badge/Version-2.0--rc5-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() @@ -194,18 +194,6 @@ Because php-fpm must specify a configuration file before running, the php-fpm co Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`. -## Current Status - -- [X] Basic CLI framework (by `symfony/console`) -- [X] Linux support -- [X] macOS support -- [X] Exception handler -- [ ] Windows support -- [X] PHP 7.4 support -- [X] fpm support - -More functions and features are coming soon, Bugs and TODOs: https://github.com/crazywhalecc/static-php-cli/issues/32 - ## Contribution Currently, there are only a few supported extensions. @@ -236,8 +224,9 @@ You can sponsor my project on [this page](https://github.com/crazywhalecc/crazyw ## Open-Source License -This project is based on the tradition of using the MIT License for old versions, -while the new version references source code from some other projects: +This project itself is based on MIT License, +some newly added extensions and dependencies may originate from the following projects (including but not limited to), +and the headers of these code files will also be given additional instructions LICENSE and AUTHOR: - [dixyes/lwmbs](https://github.com/dixyes/lwmbs) (Mulun Permissive License) - [swoole/swoole-cli](https://github.com/swoole/swoole-cli) (Apache 2.0 LICENSE+SWOOLE-CLI LICENSE) @@ -253,4 +242,4 @@ and comply with the corresponding project's LICENSE. The refactoring branch of this project is written modularly. If you are interested in this project and want to join the development, -you can refer to the [Contribution Guide](https://static-php-cli.zhamao.me) of the documentation to contribute code or documentation. (TODO) +you can refer to the [Contribution Guide](https://static-php-cli.zhamao.me) of the documentation to contribute code or documentation. From 01111c51eedcdf4640872f8566325819ea81d89b Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 6 Sep 2023 16:26:22 +0800 Subject: [PATCH 133/296] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 49d046f5..9ea2bb50 100755 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Build single static PHP binary, with PHP project together, with popular extensio [![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() -> 项目已重命名 `refactor` 分支为 `main` 分支,请依赖的项目注意更改分支名称。 +> 项目名称是 static-php-cli,但其实支持 cli、fpm、micro 和 embed(正在路上)SAPI 😎 ## 编译环境需求 From b14179a8de04d6761172e2309e3f9d1eeceaff99 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 6 Sep 2023 16:26:51 +0800 Subject: [PATCH 134/296] Update README-en.md --- README-en.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README-en.md b/README-en.md index 9bacd6e4..9a2f5579 100755 --- a/README-en.md +++ b/README-en.md @@ -2,6 +2,8 @@ Build single static PHP binary, with PHP project together, with popular extensions included. +The project name is static-php-cli, but it actually supports cli, fpm, micro and embed (on the way) SAPI 😎 + Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI) 2023-05-02 15 53 13 @@ -19,8 +21,6 @@ This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro [![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() -> The project has renamed the `refactor` branch to the `main` branch, please pay attention to changing the branch name for dependent projects. - ## Compilation Requirements Yes, this project is written in PHP, pretty funny. From 4d0e825b433a9330c54a7b598081fda327260693 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Wed, 6 Sep 2023 09:04:24 +0200 Subject: [PATCH 135/296] Adjust dependencies in composer.json file Removed unsupported Symfony versions Bump minimal version of dev dependencies to the latest supported --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index a23d7adf..14f6189b 100644 --- a/composer.json +++ b/composer.json @@ -13,15 +13,15 @@ "ext-mbstring": "*", "ext-pcntl": "*", "laravel/prompts": "^0.1.3", - "symfony/console": "^6 || ^5 || ^4", + "symfony/console": "^5.4 || ^6 || ^7", "zhamao/logger": "^1.0" }, "require-dev": { "captainhook/captainhook": "^5.10", "captainhook/plugin-composer": "^5.3", - "friendsofphp/php-cs-fixer": "^3.2 != 3.7.0", - "nunomaduro/collision": "*", - "phpstan/phpstan": "^1.1", + "friendsofphp/php-cs-fixer": "^3.25", + "nunomaduro/collision": "^7.8", + "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^10.3" }, "autoload": { From 3bd037f48f321977297240ba4c7993741ae884c1 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Thu, 7 Sep 2023 11:46:57 +0200 Subject: [PATCH 136/296] Rework style of dev command showing extensions details --- src/SPC/command/dev/AllExtCommand.php | 44 +++++++++++++++++++++-- src/SPC/command/dev/ExtInfoCommand.php | 50 -------------------------- 2 files changed, 41 insertions(+), 53 deletions(-) delete mode 100644 src/SPC/command/dev/ExtInfoCommand.php diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index 7c77b5c5..f03356b4 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -6,15 +6,19 @@ namespace SPC\command\dev; use SPC\command\BaseCommand; use SPC\exception\FileSystemException; +use SPC\exception\WrongUsageException; use SPC\store\Config; +use SPC\util\DependencyUtil; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Style\SymfonyStyle; -#[AsCommand('dev:ext-all', 'Dev command', ['list-ext'])] +#[AsCommand('dev:extensions', 'Helper command that lists available extension details', ['list-ext'])] class AllExtCommand extends BaseCommand { public function configure(): void { - $this->addOption('line', 'l', null, 'Show with separate lines'); + $this->addArgument('extensions', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'Extension name', null); } /** @@ -22,7 +26,41 @@ class AllExtCommand extends BaseCommand */ public function handle(): int { - $this->output->writeln(implode($this->input->getOption('line') ? PHP_EOL : ',', array_keys(Config::getExts()))); + $extensions = $this->input->getArgument('extensions') ?: []; + + $style = new SymfonyStyle($this->input, $this->output); + $style->writeln($extensions ? 'Available extensions:' : 'Extensions:'); + + $data = []; + foreach (Config::getExts() as $extension => $details) { + if ($extensions !== [] && !\in_array($extension, $extensions, true)) { + continue; + } + + try { + [, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps([$extension]); + } catch (WrongUsageException) { + $libraries = $not_included = []; + } + + $lib_suggests = Config::getExt($extension, 'lib-suggests', []); + $ext_suggests = Config::getExt($extension, 'ext-suggests', []); + + $data[] = [ + $extension, + implode(', ', $libraries), + implode(', ', $lib_suggests), + implode(',', $not_included), + implode(', ', $ext_suggests), + Config::getExt($extension, 'unix-only', false) ? 'true' : 'false', + ]; + } + + $style->table( + ['Extension', 'lib-depends', 'lib-suggests', 'ext-depends', 'ext-suggests', 'unix-only'], + $data + ); + return static::SUCCESS; } } diff --git a/src/SPC/command/dev/ExtInfoCommand.php b/src/SPC/command/dev/ExtInfoCommand.php deleted file mode 100644 index fbab7db6..00000000 --- a/src/SPC/command/dev/ExtInfoCommand.php +++ /dev/null @@ -1,50 +0,0 @@ -addArgument('extensions', InputArgument::REQUIRED, 'The extension name you need to get info'); - } - - /** - * @throws WrongUsageException - * @throws FileSystemException - * @throws RuntimeException - */ - public function handle(): int - { - $extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions')))); - - // 根据提供的扩展列表获取依赖库列表并编译 - foreach ($extensions as $extension) { - $this->output->writeln('[ ' . $extension . ' ]'); - [, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps([$extension]); - $lib_suggests = Config::getExt($extension, 'lib-suggests', []); - $ext_suggests = Config::getExt($extension, 'ext-suggests', []); - $this->output->writeln("lib-depends:\t" . implode(', ', $libraries) . ''); - $this->output->writeln("lib-suggests:\t" . implode(', ', $lib_suggests) . ''); - $this->output->writeln("ext-depends:\t" . implode(',', $not_included) . ''); - $this->output->writeln("ext-suggests:\t" . implode(', ', $ext_suggests) . ''); - if (Config::getExt($extension, 'unix-only', false)) { - $this->output->writeln("Unix only:\ttrue"); - } - $this->output->writeln(''); - } - return static::SUCCESS; - } -} From e8b277ad0d0f9155c6301e3429c31f409016dbef Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Thu, 7 Sep 2023 12:57:49 +0200 Subject: [PATCH 137/296] Prevent unknown extension call --- src/SPC/command/dev/AllExtCommand.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index f03356b4..b47bdf8e 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -56,10 +56,14 @@ class AllExtCommand extends BaseCommand ]; } - $style->table( - ['Extension', 'lib-depends', 'lib-suggests', 'ext-depends', 'ext-suggests', 'unix-only'], - $data - ); + if ($data === []) { + $style->warning('Unknown extension selected: ' . implode(',', $extensions)); + } else { + $style->table( + ['Extension', 'lib-depends', 'lib-suggests', 'ext-depends', 'ext-suggests', 'unix-only'], + $data + ); + } return static::SUCCESS; } From 54e98666e7b41917c25922311d6a9e3b144a2ffa Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 8 Sep 2023 22:03:40 +0800 Subject: [PATCH 138/296] Update ConsoleApplication.php --- src/SPC/ConsoleApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index b687278e..f43463ee 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -14,7 +14,7 @@ use Symfony\Component\Console\Command\ListCommand; */ class ConsoleApplication extends Application { - public const VERSION = '2.0.0'; + public const VERSION = '2.0-rc6'; /** * @throws \ReflectionException From be8eb90b865097e3e22f2e6678caa696b3047101 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 8 Sep 2023 22:12:59 +0800 Subject: [PATCH 139/296] cs fix (#166) --- src/SPC/builder/traits/LibraryTrait.php | 4 +--- src/SPC/doctor/AsCheckItem.php | 3 +-- src/SPC/doctor/AsFixItem.php | 4 +--- src/SPC/doctor/CheckResult.php | 4 +--- src/SPC/exception/DownloaderException.php | 4 +--- src/SPC/exception/FileSystemException.php | 4 +--- src/SPC/exception/InvalidArgumentException.php | 4 +--- src/SPC/exception/RuntimeException.php | 4 +--- src/SPC/exception/ValidationException.php | 4 +--- src/SPC/exception/WrongUsageException.php | 4 +--- src/SPC/util/CustomExt.php | 4 +--- 11 files changed, 11 insertions(+), 32 deletions(-) diff --git a/src/SPC/builder/traits/LibraryTrait.php b/src/SPC/builder/traits/LibraryTrait.php index 0d550c85..e05a47bf 100644 --- a/src/SPC/builder/traits/LibraryTrait.php +++ b/src/SPC/builder/traits/LibraryTrait.php @@ -4,6 +4,4 @@ declare(strict_types=1); namespace SPC\builder\traits; -trait LibraryTrait -{ -} +trait LibraryTrait {} diff --git a/src/SPC/doctor/AsCheckItem.php b/src/SPC/doctor/AsCheckItem.php index 0417bcfa..f64d914b 100644 --- a/src/SPC/doctor/AsCheckItem.php +++ b/src/SPC/doctor/AsCheckItem.php @@ -14,6 +14,5 @@ class AsCheckItem public ?string $limit_os = null, public int $level = 100, public bool $manual = false, - ) { - } + ) {} } diff --git a/src/SPC/doctor/AsFixItem.php b/src/SPC/doctor/AsFixItem.php index eb26d872..200bd1f7 100644 --- a/src/SPC/doctor/AsFixItem.php +++ b/src/SPC/doctor/AsFixItem.php @@ -7,7 +7,5 @@ namespace SPC\doctor; #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class AsFixItem { - public function __construct(public string $name) - { - } + public function __construct(public string $name) {} } diff --git a/src/SPC/doctor/CheckResult.php b/src/SPC/doctor/CheckResult.php index 112c14ae..406460ec 100644 --- a/src/SPC/doctor/CheckResult.php +++ b/src/SPC/doctor/CheckResult.php @@ -6,9 +6,7 @@ namespace SPC\doctor; class CheckResult { - public function __construct(private readonly bool $ok, private readonly ?string $message = null, private string $fix_item = '', private array $fix_params = []) - { - } + public function __construct(private readonly bool $ok, private readonly ?string $message = null, private string $fix_item = '', private array $fix_params = []) {} public static function fail(string $message, string $fix_item = '', array $fix_params = []): CheckResult { diff --git a/src/SPC/exception/DownloaderException.php b/src/SPC/exception/DownloaderException.php index 41a1d423..a2faec9d 100644 --- a/src/SPC/exception/DownloaderException.php +++ b/src/SPC/exception/DownloaderException.php @@ -4,6 +4,4 @@ declare(strict_types=1); namespace SPC\exception; -class DownloaderException extends \Exception -{ -} +class DownloaderException extends \Exception {} diff --git a/src/SPC/exception/FileSystemException.php b/src/SPC/exception/FileSystemException.php index ca72968e..d27e22af 100644 --- a/src/SPC/exception/FileSystemException.php +++ b/src/SPC/exception/FileSystemException.php @@ -4,6 +4,4 @@ declare(strict_types=1); namespace SPC\exception; -class FileSystemException extends \Exception -{ -} +class FileSystemException extends \Exception {} diff --git a/src/SPC/exception/InvalidArgumentException.php b/src/SPC/exception/InvalidArgumentException.php index 360a89bc..16db5524 100644 --- a/src/SPC/exception/InvalidArgumentException.php +++ b/src/SPC/exception/InvalidArgumentException.php @@ -4,6 +4,4 @@ declare(strict_types=1); namespace SPC\exception; -class InvalidArgumentException extends \Exception -{ -} +class InvalidArgumentException extends \Exception {} diff --git a/src/SPC/exception/RuntimeException.php b/src/SPC/exception/RuntimeException.php index d612e533..2d96acb9 100644 --- a/src/SPC/exception/RuntimeException.php +++ b/src/SPC/exception/RuntimeException.php @@ -4,6 +4,4 @@ declare(strict_types=1); namespace SPC\exception; -class RuntimeException extends \Exception -{ -} +class RuntimeException extends \Exception {} diff --git a/src/SPC/exception/ValidationException.php b/src/SPC/exception/ValidationException.php index 83ff86b7..08e7b4b9 100644 --- a/src/SPC/exception/ValidationException.php +++ b/src/SPC/exception/ValidationException.php @@ -4,6 +4,4 @@ declare(strict_types=1); namespace SPC\exception; -class ValidationException extends \Exception -{ -} +class ValidationException extends \Exception {} diff --git a/src/SPC/exception/WrongUsageException.php b/src/SPC/exception/WrongUsageException.php index c03000da..fa23c1f8 100644 --- a/src/SPC/exception/WrongUsageException.php +++ b/src/SPC/exception/WrongUsageException.php @@ -4,6 +4,4 @@ declare(strict_types=1); namespace SPC\exception; -class WrongUsageException extends \Exception -{ -} +class WrongUsageException extends \Exception {} diff --git a/src/SPC/util/CustomExt.php b/src/SPC/util/CustomExt.php index 89d1b6cf..db312007 100644 --- a/src/SPC/util/CustomExt.php +++ b/src/SPC/util/CustomExt.php @@ -13,9 +13,7 @@ class CustomExt { private static array $custom_ext_class = []; - public function __construct(protected string $ext_name) - { - } + public function __construct(protected string $ext_name) {} /** * Load all custom extension classes From 00a49c662b69f69f918f8a9e36ad490e42fb2cc6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 11 Sep 2023 23:44:30 +0800 Subject: [PATCH 140/296] add build:libs option --rebuild --- src/SPC/builder/BuilderBase.php | 2 +- src/SPC/command/BuildLibsCommand.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 1c3c84fb..6b49ca32 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -85,7 +85,7 @@ abstract class BuilderBase // build all libs foreach ($this->libs as $lib) { - match ($lib->tryBuild()) { + match ($lib->tryBuild($this->getOption('rebuild', false))) { BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'), BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'), BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'), diff --git a/src/SPC/command/BuildLibsCommand.php b/src/SPC/command/BuildLibsCommand.php index be49f86a..dc3989e6 100644 --- a/src/SPC/command/BuildLibsCommand.php +++ b/src/SPC/command/BuildLibsCommand.php @@ -20,6 +20,7 @@ class BuildLibsCommand extends BuildCommand $this->addArgument('libraries', InputArgument::REQUIRED, 'The libraries will be compiled, comma separated'); $this->addOption('clean', null, null, 'Clean old download cache and source before fetch'); $this->addOption('all', 'A', null, 'Build all libs that static-php-cli needed'); + $this->addOption('rebuild', 'r', null, 'Delete old build and rebuild'); } public function initialize(InputInterface $input, OutputInterface $output): void From fe2f658e087708bc364f8f935c12573bbf89bfb4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 12 Sep 2023 00:06:46 +0800 Subject: [PATCH 141/296] dev:sort-config add `\n` at the end of json --- src/SPC/command/dev/SortConfigCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/command/dev/SortConfigCommand.php b/src/SPC/command/dev/SortConfigCommand.php index 11360fd0..bee44ff9 100644 --- a/src/SPC/command/dev/SortConfigCommand.php +++ b/src/SPC/command/dev/SortConfigCommand.php @@ -34,7 +34,7 @@ class SortConfigCommand extends BaseCommand $file = json_decode(FileSystem::readFile(ROOT_DIR . '/config/lib.json'), true); ConfigValidator::validateLibs($file); ksort($file); - if (!file_put_contents(ROOT_DIR . '/config/lib.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))) { + if (!file_put_contents(ROOT_DIR . '/config/lib.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n")) { $this->output->writeln('Write file lib.json failed!'); return static::FAILURE; } @@ -43,7 +43,7 @@ class SortConfigCommand extends BaseCommand $file = json_decode(FileSystem::readFile(ROOT_DIR . '/config/source.json'), true); ConfigValidator::validateSource($file); uksort($file, fn ($a, $b) => $a === 'php-src' ? -1 : ($b === 'php-src' ? 1 : ($a < $b ? -1 : 1))); - if (!file_put_contents(ROOT_DIR . '/config/source.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))) { + if (!file_put_contents(ROOT_DIR . '/config/source.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n")) { $this->output->writeln('Write file source.json failed!'); return static::FAILURE; } @@ -52,7 +52,7 @@ class SortConfigCommand extends BaseCommand $file = json_decode(FileSystem::readFile(ROOT_DIR . '/config/ext.json'), true); ConfigValidator::validateExts($file); ksort($file); - if (!file_put_contents(ROOT_DIR . '/config/ext.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE))) { + if (!file_put_contents(ROOT_DIR . '/config/ext.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n")) { $this->output->writeln('Write file ext.json failed!'); return static::FAILURE; } From 5025850f71feeaa72c44b215d5bd805c84ed3926 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 12 Sep 2023 12:43:26 +0800 Subject: [PATCH 142/296] fix Alpine docker install packages --- bin/spc-alpine-docker | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index 39c4729b..cac01260 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -64,7 +64,6 @@ RUN apk update; \ bison \ build-base \ cmake \ - composer \ curl \ file \ flex \ @@ -77,16 +76,20 @@ RUN apk update; \ linux-headers \ m4 \ make \ - php81 \ - php81-common \ - php81-pcntl \ - php81-phar \ - php81-posix \ - php81-tokenizer \ - php81-xml \ + php82 \ + php82-common \ + php82-pcntl \ + php82-phar \ + php82-posix \ + php82-tokenizer \ + php82-dom \ + php82-xml \ + php82-xmlwriter \ + composer \ pkgconfig \ wget \ xz +RUN ln -s /usr/bin/php82 /usr/bin/php WORKDIR /app ADD ./src /app/src ADD ./composer.json /app/composer.json From ca3f8a350d1d8e65bcdcc9c9c678179e0904b24e Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 12 Sep 2023 11:29:22 +0200 Subject: [PATCH 143/296] Prevent fatal error when php source files are missing --- src/SPC/command/dev/PhpVerCommand.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/SPC/command/dev/PhpVerCommand.php b/src/SPC/command/dev/PhpVerCommand.php index 57374753..05af1267 100644 --- a/src/SPC/command/dev/PhpVerCommand.php +++ b/src/SPC/command/dev/PhpVerCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand('dev:php-ver', 'Dev command')] +#[AsCommand('dev:php-version', 'Returns version of PHP located source directory', ['dev:php-ver'])] class PhpVerCommand extends BaseCommand { public function initialize(InputInterface $input, OutputInterface $output): void @@ -22,11 +22,19 @@ class PhpVerCommand extends BaseCommand { // Find php from source/php-src $file = SOURCE_PATH . '/php-src/main/php_version.h'; + if (!file_exists($file)) { + $this->output->writeln('PHP source not found, maybe you need to extract first ?'); + + return static::FAILURE; + } + $result = preg_match('/#define PHP_VERSION "([^"]+)"/', file_get_contents($file), $match); if ($result === false) { $this->output->writeln('PHP source not found, maybe you need to extract first ?'); + return static::FAILURE; } + $this->output->writeln('' . $match[1] . ''); return static::SUCCESS; } From 085c1a159c0a6529af4c97c4bc40963f2c9e0687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 21 Aug 2023 09:30:46 +0200 Subject: [PATCH 144/296] feat: add support for libphp and the embed SAPI --- src/SPC/builder/BuilderBase.php | 3 ++ src/SPC/builder/linux/LinuxBuilder.php | 36 +++++++++++++++++++---- src/SPC/builder/macos/MacOSBuilder.php | 40 ++++++++++++++++++++------ src/SPC/command/BuildCliCommand.php | 7 +++-- src/globals/defines.php | 3 +- 5 files changed, 71 insertions(+), 18 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 6b49ca32..c0b66223 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -252,6 +252,9 @@ abstract class BuilderBase if (($type & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) { $ls[] = 'fpm'; } + if (($type & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) { + $ls[] = 'embed'; + } return implode(', ', $ls); } diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 431fe490..16533c65 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -179,6 +179,11 @@ class LinuxBuilder extends BuilderBase $zts = ''; } + $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; + $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; + $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; + $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + shell()->cd(SOURCE_PATH . '/php-src') ->exec( './configure ' . @@ -189,12 +194,13 @@ class LinuxBuilder extends BuilderBase '--disable-all ' . '--disable-cgi ' . '--disable-phpdbg ' . - '--enable-cli ' . - '--enable-fpm ' . + ($enableCli ? '--enable-cli ' : '') . + ($enableFpm ? '--enable-fpm ' : '') . + ($enableEmbed ? '--enable-embed=static ' : '') . $json_74 . $zts . $maxExecutionTimers . - '--enable-micro=all-static ' . + ($enableMicro ? '--enable-micro=all-static ' : '') . $this->makeExtensionArgs() . ' ' . $envs ); @@ -203,18 +209,22 @@ class LinuxBuilder extends BuilderBase $this->cleanMake(); - if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { + if ($enableCli) { logger()->info('building cli'); $this->buildCli($extra_libs, $use_lld); } - if (($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) { + if ($enableFpm) { logger()->info('building fpm'); $this->buildFpm($extra_libs, $use_lld); } - if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) { + if ($enableMicro) { logger()->info('building micro'); $this->buildMicro($extra_libs, $use_lld, $cflags); } + if ($enableEmbed) { + logger()->info('building embed'); + $this->buildEmbed($extra_libs, $use_lld); + } if (php_uname('m') === $this->getOption('arch')) { $this->sanityCheck($build_target); @@ -306,4 +316,18 @@ class LinuxBuilder extends BuilderBase $this->deployBinary(BUILD_TARGET_FPM); } + + public function buildEmbed(string $extra_libs, string $use_lld): void + { + $vars = SystemUtil::makeEnvVarString([ + 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), + 'EXTRA_LIBS' => $extra_libs, + 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", + ]); + + shell() + ->cd(SOURCE_PATH . '/php-src') + ->exec('sed -i "s|//lib|/lib|g" Makefile') + ->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install"); + } } diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 0e8c98f0..c87c9d2c 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -151,6 +151,11 @@ class MacOSBuilder extends BuilderBase $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : ''; + $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; + $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; + $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; + $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + shell()->cd(SOURCE_PATH . '/php-src') ->exec( './configure ' . @@ -162,9 +167,10 @@ class MacOSBuilder extends BuilderBase '--disable-all ' . '--disable-cgi ' . '--disable-phpdbg ' . - '--enable-cli ' . - '--enable-fpm ' . - '--enable-micro ' . + ($enableCli ? '--enable-cli ' : '') . + ($enableFpm ? '--enable-fpm ' : '') . + ($enableEmbed ? '--enable-embed=static ' : '') . + ($enableMicro ? '--enable-micro ' : '') . $json_74 . $zts . $this->makeExtensionArgs() . ' ' . @@ -175,18 +181,22 @@ class MacOSBuilder extends BuilderBase $this->cleanMake(); - if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { + if ($enableCli) { logger()->info('building cli'); $this->buildCli(); } - if (($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) { + if ($enableFpm) { logger()->info('building fpm'); $this->buildFpm(); } - if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) { + if ($enableMicro) { logger()->info('building micro'); $this->buildMicro(); } + if ($enableEmbed) { + logger()->info('building embed'); + $this->buildEmbed(); + } if (php_uname('m') === $this->getOption('arch')) { $this->sanityCheck($build_target); @@ -207,7 +217,7 @@ class MacOSBuilder extends BuilderBase { $vars = SystemUtil::makeEnvVarString([ 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size - 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS need it) + 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it) ]); $shell = shell()->cd(SOURCE_PATH . '/php-src'); @@ -237,7 +247,7 @@ class MacOSBuilder extends BuilderBase $vars = [ // with debug information, optimize for size, remove identifiers, patch fake cli for micro 'EXTRA_CFLAGS' => '-g -Os -fno-ident' . $enable_fake_cli, - // link resolv library (macOS need it) + // link resolv library (macOS needs it) 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", ]; if (!$this->getOption('no-strip', false)) { @@ -260,7 +270,7 @@ class MacOSBuilder extends BuilderBase { $vars = SystemUtil::makeEnvVarString([ 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size - 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS need it) + 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it) ]); $shell = shell()->cd(SOURCE_PATH . '/php-src'); @@ -270,4 +280,16 @@ class MacOSBuilder extends BuilderBase } $this->deployBinary(BUILD_TARGET_FPM); } + + public function buildEmbed(): void + { + $vars = SystemUtil::makeEnvVarString([ + 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size + 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it) + ]); + + shell() + ->cd(SOURCE_PATH . '/php-src') + ->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install"); + } } diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 517f30d7..ee461793 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -25,7 +25,8 @@ class BuildCliCommand extends BuildCommand $this->addOption('build-micro', null, null, 'build micro'); $this->addOption('build-cli', null, null, 'build cli'); $this->addOption('build-fpm', null, null, 'build fpm'); - $this->addOption('build-all', null, null, 'build cli, micro, fpm'); + $this->addOption('build-embed', null, null, 'build embed'); + $this->addOption('build-all', null, null, 'build cli, micro, fpm, embed'); $this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions'); $this->addOption('enable-zts', null, null, 'enable ZTS support'); $this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI'); @@ -43,13 +44,15 @@ class BuildCliCommand extends BuildCommand $rule = $rule | ($this->getOption('build-cli') ? BUILD_TARGET_CLI : BUILD_TARGET_NONE); $rule = $rule | ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE); $rule = $rule | ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE); + $rule = $rule | ($this->getOption('build-embed') ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE); $rule = $rule | ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); if ($rule === BUILD_TARGET_NONE) { $this->output->writeln('Please add at least one build target!'); $this->output->writeln("\t--build-cli\tBuild php-cli SAPI"); $this->output->writeln("\t--build-micro\tBuild phpmicro SAPI"); $this->output->writeln("\t--build-fpm\tBuild php-fpm SAPI"); - $this->output->writeln("\t--build-all\tBuild all SAPI: cli, micro, fpm"); + $this->output->writeln("\t--build-embed\tBuild embed SAPI/libphp"); + $this->output->writeln("\t--build-all\tBuild all SAPI: cli, micro, fpm, embed"); return static::FAILURE; } try { diff --git a/src/globals/defines.php b/src/globals/defines.php index 28473296..150b2753 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -43,7 +43,8 @@ const BUILD_TARGET_NONE = 0; // no target const BUILD_TARGET_CLI = 1; // build cli const BUILD_TARGET_MICRO = 2; // build micro const BUILD_TARGET_FPM = 4; // build fpm -const BUILD_TARGET_ALL = 7; // build all +const BUILD_TARGET_EMBED = 8; // build embed +const BUILD_TARGET_ALL = 15; // build all // doctor error fix policy const FIX_POLICY_DIE = 1; // die directly From 451a0c0e343f2640c9908408dab02c5123648d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 30 Aug 2023 17:47:29 +0200 Subject: [PATCH 145/296] workaround for macOS --- src/SPC/builder/macos/MacOSBuilder.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index c87c9d2c..65a7ebe4 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -290,6 +290,15 @@ class MacOSBuilder extends BuilderBase shell() ->cd(SOURCE_PATH . '/php-src') - ->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install"); + ->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install") + // https://github.com/php/php-src/issues/12082 + ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o') + ->exec('mkdir ' . BUILD_ROOT_PATH . '/lib/php-o') + ->cd(BUILD_ROOT_PATH . '/lib/php-o') + ->exec('ar x ' . BUILD_ROOT_PATH . '/lib/libphp.a') + ->exec('ls') + ->exec('rm ' . BUILD_ROOT_PATH . '/lib/libphp.a') + ->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o') + ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o'); } } From 899eb94b8b4d716da5f7970a003dce464328e6d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 30 Aug 2023 18:14:59 +0200 Subject: [PATCH 146/296] remove useless ls --- src/SPC/builder/macos/MacOSBuilder.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 65a7ebe4..d87c8c53 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -291,12 +291,11 @@ class MacOSBuilder extends BuilderBase shell() ->cd(SOURCE_PATH . '/php-src') ->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install") - // https://github.com/php/php-src/issues/12082 + // Workaround for https://github.com/php/php-src/issues/12082 ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o') ->exec('mkdir ' . BUILD_ROOT_PATH . '/lib/php-o') ->cd(BUILD_ROOT_PATH . '/lib/php-o') ->exec('ar x ' . BUILD_ROOT_PATH . '/lib/libphp.a') - ->exec('ls') ->exec('rm ' . BUILD_ROOT_PATH . '/lib/libphp.a') ->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o') ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o'); From 3b300698f39057eb44dcb7c05694d7eaaac70ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 30 Aug 2023 22:46:04 +0200 Subject: [PATCH 147/296] use lixml GH mirror because gitlab.gnome.org is down --- config/source.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index 2f1e2e41..3c052a26 100644 --- a/config/source.json +++ b/config/source.json @@ -249,7 +249,7 @@ }, "libxml2": { "type": "url", - "url": "https://gitlab.gnome.org/GNOME/libxml2/-/archive/v2.9.14/libxml2-v2.9.14.tar.gz", + "url": "https://github.com/GNOME/libxml2/archive/refs/tags/v2.9.14.tar.gz", "license": { "type": "file", "path": "Copyright" From 50d44d83100c5a8ee78abed11a8c5f88255a3d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sat, 2 Sep 2023 21:25:33 +0200 Subject: [PATCH 148/296] explicitly disable unneeded SAPIs --- src/SPC/builder/linux/LinuxBuilder.php | 8 ++++---- src/SPC/builder/macos/MacOSBuilder.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 16533c65..0e7d0e37 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -194,13 +194,13 @@ class LinuxBuilder extends BuilderBase '--disable-all ' . '--disable-cgi ' . '--disable-phpdbg ' . - ($enableCli ? '--enable-cli ' : '') . - ($enableFpm ? '--enable-fpm ' : '') . - ($enableEmbed ? '--enable-embed=static ' : '') . + ($enableCli ? '--enable-cli ' : '--disable-cli ') . + ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . + ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') . $json_74 . $zts . $maxExecutionTimers . - ($enableMicro ? '--enable-micro=all-static ' : '') . + ($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') . $this->makeExtensionArgs() . ' ' . $envs ); diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index d87c8c53..d179a1bc 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -167,10 +167,10 @@ class MacOSBuilder extends BuilderBase '--disable-all ' . '--disable-cgi ' . '--disable-phpdbg ' . - ($enableCli ? '--enable-cli ' : '') . - ($enableFpm ? '--enable-fpm ' : '') . - ($enableEmbed ? '--enable-embed=static ' : '') . - ($enableMicro ? '--enable-micro ' : '') . + ($enableCli ? '--enable-cli ' : '--disable-cli ') . + ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . + ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') . + ($enableMicro ? '--enable-micro ' : '--disable-micro ') . $json_74 . $zts . $this->makeExtensionArgs() . ' ' . From 9b1e784604a3667060c1bc1f97a52ce898f156c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 4 Sep 2023 22:51:30 +0200 Subject: [PATCH 149/296] fix: replace down URL --- config/source.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/source.json b/config/source.json index 3c052a26..8ccb7416 100644 --- a/config/source.json +++ b/config/source.json @@ -357,9 +357,8 @@ } }, "pkg-config": { - "type": "filelist", - "url": "https://pkgconfig.freedesktop.org/releases/", - "regex": "/href=\"(?pkg-config-(?[^\"]+)\\.tar\\.gz)\"/", + "type": "url", + "url": "https://gitlab.freedesktop.org/pkg-config/pkg-config/-/archive/pkg-config-0.29.2/pkg-config-pkg-config-0.29.2.tar.gz", "license": { "type": "file", "path": "COPYING" From 727d78a68992be2ed3d2b8791fa8b9702863aa2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 11 Sep 2023 14:30:42 +0200 Subject: [PATCH 150/296] Revert "fix: replace down URL" This reverts commit 6eadbca21bf9a3b57058160a2f7ea8f4cc5f21dd. --- config/source.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/source.json b/config/source.json index 8ccb7416..3c052a26 100644 --- a/config/source.json +++ b/config/source.json @@ -357,8 +357,9 @@ } }, "pkg-config": { - "type": "url", - "url": "https://gitlab.freedesktop.org/pkg-config/pkg-config/-/archive/pkg-config-0.29.2/pkg-config-pkg-config-0.29.2.tar.gz", + "type": "filelist", + "url": "https://pkgconfig.freedesktop.org/releases/", + "regex": "/href=\"(?pkg-config-(?[^\"]+)\\.tar\\.gz)\"/", "license": { "type": "file", "path": "COPYING" From dbec04389491c5c2f9266380072bac7ed4895a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 11 Sep 2023 15:54:20 +0200 Subject: [PATCH 151/296] temporary workaround for PECL certificate expiration --- src/SPC/store/Downloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index c8bdf179..514fc1af 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -395,7 +395,7 @@ class Downloader }; $headerArg = implode(' ', array_map(fn ($v) => '"-H' . $v . '"', $headers)); $check = !defined('DEBUG_MODE') ? 's' : '#'; - $cmd = "curl -{$check}fSL -o \"{$path}\" {$methodArg} {$headerArg} \"{$url}\""; + $cmd = "curl -{$check}fSLk -o \"{$path}\" {$methodArg} {$headerArg} \"{$url}\""; f_passthru($cmd); } } From 4bfca6fe933dde1c70f2d3bccddf59a5aaf0f364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 11 Sep 2023 19:37:09 +0200 Subject: [PATCH 152/296] always enable micro --- src/SPC/builder/linux/LinuxBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 0e7d0e37..cf0b8812 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -200,7 +200,7 @@ class LinuxBuilder extends BuilderBase $json_74 . $zts . $maxExecutionTimers . - ($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') . + '--enable-micro=all-static ' . $this->makeExtensionArgs() . ' ' . $envs ); From 1a32ddc70a34231e2cc79ae9bcc3c248cce0ddff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 11 Sep 2023 22:22:20 +0200 Subject: [PATCH 153/296] Revert "temporary workaround for PECL certificate expiration" This reverts commit 7c78003c9f2223b00a53e5274afba2c6f0e1c5db. --- src/SPC/store/Downloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 514fc1af..c8bdf179 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -395,7 +395,7 @@ class Downloader }; $headerArg = implode(' ', array_map(fn ($v) => '"-H' . $v . '"', $headers)); $check = !defined('DEBUG_MODE') ? 's' : '#'; - $cmd = "curl -{$check}fSLk -o \"{$path}\" {$methodArg} {$headerArg} \"{$url}\""; + $cmd = "curl -{$check}fSL -o \"{$path}\" {$methodArg} {$headerArg} \"{$url}\""; f_passthru($cmd); } } From adfa620ef4d0590b9d78ef6152cc3c9b2b4942c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 11 Sep 2023 22:22:41 +0200 Subject: [PATCH 154/296] Revert "always enable micro" This reverts commit eb8cefd9ca29d6eb31a4248edd242582b940ae10. --- src/SPC/builder/linux/LinuxBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index cf0b8812..0e7d0e37 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -200,7 +200,7 @@ class LinuxBuilder extends BuilderBase $json_74 . $zts . $maxExecutionTimers . - '--enable-micro=all-static ' . + ($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') . $this->makeExtensionArgs() . ' ' . $envs ); From dd2e7cc129dbe61de02f717e9765b4aff5e280c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 11 Sep 2023 22:26:26 +0200 Subject: [PATCH 155/296] static opcache patch --- src/SPC/builder/linux/LinuxBuilder.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 0e7d0e37..ef458c81 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -319,6 +319,8 @@ class LinuxBuilder extends BuilderBase public function buildEmbed(string $extra_libs, string $use_lld): void { + SourcePatcher::patchMicro(['static_opcache']); + $vars = SystemUtil::makeEnvVarString([ 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), 'EXTRA_LIBS' => $extra_libs, From 3183ecceafa1e10bf31451ace4f6b6dca1f288bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 11 Sep 2023 23:00:26 +0200 Subject: [PATCH 156/296] --disable-opcache-jit --- src/SPC/builder/linux/LinuxBuilder.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index ef458c81..7859139e 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -196,7 +196,7 @@ class LinuxBuilder extends BuilderBase '--disable-phpdbg ' . ($enableCli ? '--enable-cli ' : '--disable-cli ') . ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . - ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') . + ($enableEmbed ? '--enable-embed=static --disable-opcache-jit ' : '--disable-embed ') . $json_74 . $zts . $maxExecutionTimers . @@ -319,8 +319,6 @@ class LinuxBuilder extends BuilderBase public function buildEmbed(string $extra_libs, string $use_lld): void { - SourcePatcher::patchMicro(['static_opcache']); - $vars = SystemUtil::makeEnvVarString([ 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), 'EXTRA_LIBS' => $extra_libs, From 01c4538ce0043203bee854eb2f8f5c094f06bbfc Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 12 Sep 2023 22:44:19 +0800 Subject: [PATCH 157/296] update README for embed SAPI --- README-en.md | 14 ++++++++++++-- README.md | 13 ++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README-en.md b/README-en.md index 9a2f5579..afc35f94 100755 --- a/README-en.md +++ b/README-en.md @@ -2,7 +2,7 @@ Build single static PHP binary, with PHP project together, with popular extensions included. -The project name is static-php-cli, but it actually supports cli, fpm, micro and embed (on the way) SAPI 😎 +The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎 Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI) @@ -126,6 +126,7 @@ Now we support `cli`, `micro`, `fpm`, you can use one or more of the following p - `--build-cli`: build static cli executable - `--build-micro`: build static phpmicro self-extracted executable - `--build-fpm`: build static fpm binary +- `--build-embed`: build embed (libphp) - `--build-all`: build all If anything goes wrong, use `--debug` option to display full terminal output: @@ -194,9 +195,18 @@ Because php-fpm must specify a configuration file before running, the php-fpm co Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`. +### Embed Usage + +When using the project parameters `--build-embed` or `--build-all`, +the final compilation result will output a `libphp.a`, `php-config` and a series of header files, +stored in `buildroot/`, You can introduce them in your other projects. + +If you know embed SAPI, you should know how to use it. +You may require the introduction of other libraries during compilation, +you can use `buildroot/bin/php-config` to obtain the compile-time configuration. + ## Contribution -Currently, there are only a few supported extensions. If the extension you need is missing, you can create an issue. If you are familiar with this project, you are also welcome to initiate a pull request. diff --git a/README.md b/README.md index 9ea2bb50..62c9bab4 100755 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Build single static PHP binary, with PHP project together, with popular extensio [![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() -> 项目名称是 static-php-cli,但其实支持 cli、fpm、micro 和 embed(正在路上)SAPI 😎 +> 项目名称是 static-php-cli,但其实支持 cli、fpm、micro 和 embed SAPI 😎 ## 编译环境需求 @@ -120,6 +120,7 @@ chmod +x bin/spc - `--build-cli`:构建 cli 二进制 - `--build-micro`:构建 phpmicro 自执行二进制 - `--build-fpm`:构建 fpm +- `--build-embed`:构建 embed(libphp) - `--build-all`:构建所有 如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误: @@ -181,9 +182,15 @@ cat micro.sfx code.php > single-app && chmod +x single-app 指定 `php-fpm.conf` 可以使用命令参数 `-y`,例如:`./php-fpm -y php-fpm.conf`。 +### 使用 php-embed + +采用项目参数 `--build-embed` 或 `--build-all` 时,最后编译结果会输出一个 `libphp.a`、`php-config` 以及一系列头文件,存放在 `buildroot/`,你可以在你的其他代码中引入它们。 + +如果你知道 embed SAPI,你应该知道如何使用它。对于有可能编译用到引入其他库的问题,你可以使用 `buildroot/bin/php-config` 来获取编译时的配置。 + ## 贡献 -目前支持的扩展较少,如果缺少你需要的扩展,可发起 Issue。如果你对本项目较熟悉,也欢迎为本项目发起 Pull Request。 +如果缺少你需要的扩展,可发起 Issue。如果你对本项目较熟悉,也欢迎为本项目发起 Pull Request。 贡献基本原则如下: @@ -202,7 +209,7 @@ cat micro.sfx code.php > single-app && chmod +x single-app ## 开源协议 -本项目依据旧版本惯例采用 MIT License 开源,自身的部分代码引用或修改自以下项目: +本项目依据旧版本惯例采用 MIT License 开源,部分扩展的集成编译命令参考或修改自以下项目: - [dixyes/lwmbs](https://github.com/dixyes/lwmbs)(木兰宽松许可证) - [swoole/swoole-cli](https://github.com/swoole/swoole-cli)(Apache 2.0 LICENSE、SWOOLE-CLI LICENSE) From 52430cbdde43a271b84738bd0d07748dce21e3b9 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Sat, 9 Sep 2023 10:04:20 +0200 Subject: [PATCH 158/296] Rework doctor command --- src/SPC/command/DoctorCommand.php | 59 +++++++++++- src/SPC/doctor/CheckListHandler.php | 111 +++++----------------- tests/SPC/doctor/CheckListHandlerTest.php | 21 ++++ 3 files changed, 104 insertions(+), 87 deletions(-) create mode 100644 tests/SPC/doctor/CheckListHandlerTest.php diff --git a/src/SPC/command/DoctorCommand.php b/src/SPC/command/DoctorCommand.php index 74fc48b8..b184fa21 100644 --- a/src/SPC/command/DoctorCommand.php +++ b/src/SPC/command/DoctorCommand.php @@ -5,7 +5,11 @@ declare(strict_types=1); namespace SPC\command; use SPC\doctor\CheckListHandler; +use SPC\doctor\CheckResult; +use SPC\exception\RuntimeException; use Symfony\Component\Console\Attribute\AsCommand; +use Symfony\Component\Console\Helper\QuestionHelper; +use Symfony\Component\Console\Question\ConfirmationQuestion; #[AsCommand('doctor', 'Diagnose whether the current environment can compile normally')] class DoctorCommand extends BaseCommand @@ -18,14 +22,65 @@ class DoctorCommand extends BaseCommand public function handle(): int { try { - $checker = new CheckListHandler($this->input, $this->output); - $checker->runCheck($this->input->getOption('auto-fix') ? FIX_POLICY_AUTOFIX : FIX_POLICY_PROMPT); + $checker = new CheckListHandler(); + + $fix_policy = $this->input->getOption('auto-fix') ? FIX_POLICY_AUTOFIX : FIX_POLICY_PROMPT; + foreach ($checker->runChecks() as $check) { + if ($check->limit_os !== null && $check->limit_os !== PHP_OS_FAMILY) { + continue; + } + + $this->output->write('Checking ' . $check->item_name . ' ... '); + + $result = call_user_func($check->callback); + if ($result === null) { + $this->output->writeln('skipped'); + } elseif ($result instanceof CheckResult) { + if ($result->isOK()) { + $this->output->writeln($result->getMessage() ?? 'ok'); + + continue; + } + + // Failed + $this->output->writeln('' . $result->getMessage() . ''); + switch ($fix_policy) { + case FIX_POLICY_DIE: + throw new RuntimeException('Some check items can not be fixed !'); + case FIX_POLICY_PROMPT: + if ($result->getFixItem() !== '') { + $helper = new QuestionHelper(); + $question = new ConfirmationQuestion('Do you want to fix it? [Y/n] ', true); + if ($helper->ask($this->input, $this->output, $question)) { + $checker->emitFix($this->output, $result); + } else { + throw new RuntimeException('You cancelled fix'); + } + } else { + throw new RuntimeException('Some check items can not be fixed !'); + } + break; + case FIX_POLICY_AUTOFIX: + if ($result->getFixItem() !== '') { + $this->output->writeln('Automatically fixing ' . $result->getFixItem() . ' ...'); + $checker->emitFix($this->output, $result); + } else { + throw new RuntimeException('Some check items can not be fixed !'); + } + break; + } + } + } + $this->output->writeln('Doctor check complete !'); } catch (\Throwable $e) { $this->output->writeln('' . $e->getMessage() . ''); + pcntl_signal(SIGINT, SIG_IGN); + return static::FAILURE; } + return static::SUCCESS; } } diff --git a/src/SPC/doctor/CheckListHandler.php b/src/SPC/doctor/CheckListHandler.php index 414c89f9..bfeb39c4 100644 --- a/src/SPC/doctor/CheckListHandler.php +++ b/src/SPC/doctor/CheckListHandler.php @@ -7,105 +7,62 @@ namespace SPC\doctor; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; -use Symfony\Component\Console\Helper\QuestionHelper; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Question\ConfirmationQuestion; -class CheckListHandler +final class CheckListHandler { /** @var AsCheckItem[] */ private array $check_list = []; private array $fix_map = []; + public function __construct() {} + /** + * @return array * @throws \ReflectionException + * @throws RuntimeException * @throws FileSystemException - * @throws RuntimeException */ - public function __construct(private readonly InputInterface $input, private readonly OutputInterface $output, bool $include_manual = false) + public function runChecks(bool $include_manual = false): array { - $this->loadCheckList($include_manual); + return $this->loadCheckList($include_manual); } /** * @throws RuntimeException */ - public function runSingleCheck(string $item_name, int $fix_policy = FIX_POLICY_DIE): void + public function emitFix(OutputInterface $output, CheckResult $result): void { - foreach ($this->check_list as $item) { - if ($item->item_name === $item_name) { - $this->check_list = [$item]; - break; - } - } - $this->runCheck($fix_policy); - } + pcntl_signal(SIGINT, function () use ($output) { + $output->writeln('You cancelled fix'); + }); - /** - * @throws RuntimeException - */ - public function runCheck(int $fix_policy = FIX_POLICY_DIE): void - { - foreach ($this->check_list as $item) { - if ($item->limit_os !== null && $item->limit_os !== PHP_OS_FAMILY) { - continue; - } - $this->output->write('Checking ' . $item->item_name . ' ... '); - $result = call_user_func($item->callback); - if ($result === null) { - $this->output->writeln('skipped'); - } elseif ($result instanceof CheckResult) { - if ($result->isOK()) { - $this->output->writeln($result->getMessage() ?? 'ok'); - continue; - } - // Failed - $this->output->writeln('' . $result->getMessage() . ''); - switch ($fix_policy) { - case FIX_POLICY_DIE: - throw new RuntimeException('Some check items can not be fixed !'); - case FIX_POLICY_PROMPT: - if ($result->getFixItem() !== '') { - $helper = new QuestionHelper(); - $question = new ConfirmationQuestion('Do you want to fix it? [Y/n] ', true); - if ($helper->ask($this->input, $this->output, $question)) { - $this->emitFix($result); - } else { - throw new RuntimeException('You cancelled fix'); - } - } else { - throw new RuntimeException('Some check items can not be fixed !'); - } - break; - case FIX_POLICY_AUTOFIX: - if ($result->getFixItem() !== '') { - $this->output->writeln('Automatically fixing ' . $result->getFixItem() . ' ...'); - $this->emitFix($result); - } else { - throw new RuntimeException('Some check items can not be fixed !'); - } - break; - } - } + $fix_result = call_user_func($this->fix_map[$result->getFixItem()], ...$result->getFixParams()); + pcntl_signal(SIGINT, SIG_IGN); + + if ($fix_result) { + $output->writeln('Fix done'); + } else { + $output->writeln('Fix failed'); + throw new RuntimeException('Some check item are not fixed'); } } /** * Load Doctor check item list * + * @return array * @throws \ReflectionException * @throws RuntimeException * @throws FileSystemException */ - private function loadCheckList(bool $include_manual = false): void + private function loadCheckList(bool $include_manual = false): array { foreach (FileSystem::getClassesPsr4(__DIR__ . '/item', 'SPC\\doctor\\item') as $class) { $ref = new \ReflectionClass($class); foreach ($ref->getMethods() as $method) { - $attr = $method->getAttributes(); - foreach ($attr as $a) { + foreach ($method->getAttributes() as $a) { if (is_a($a->getName(), AsCheckItem::class, true)) { /** @var AsCheckItem $instance */ $instance = $a->newInstance(); @@ -126,26 +83,10 @@ class CheckListHandler } } } - // sort check list by level - usort($this->check_list, fn ($a, $b) => $a->level > $b->level ? -1 : ($a->level == $b->level ? 0 : 1)); - } - /** - * @throws RuntimeException - */ - private function emitFix(CheckResult $result): void - { - pcntl_signal(SIGINT, function () { - $this->output->writeln('You cancelled fix'); - }); - $fix = $this->fix_map[$result->getFixItem()]; - $fix_result = call_user_func($fix, ...$result->getFixParams()); - pcntl_signal(SIGINT, SIG_IGN); - if ($fix_result) { - $this->output->writeln('Fix done'); - } else { - $this->output->writeln('Fix failed'); - throw new RuntimeException('Some check item are not fixed'); - } + // sort check list by level + usort($this->check_list, fn (AsCheckItem $a, AsCheckItem $b) => $a->level > $b->level ? -1 : ($a->level == $b->level ? 0 : 1)); + + return $this->check_list; } } diff --git a/tests/SPC/doctor/CheckListHandlerTest.php b/tests/SPC/doctor/CheckListHandlerTest.php new file mode 100644 index 00000000..28b37cf5 --- /dev/null +++ b/tests/SPC/doctor/CheckListHandlerTest.php @@ -0,0 +1,21 @@ +assertCount(6, $list->runChecks()); + } +} From fa0740f2168363128050082ace2751541e8db0a6 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 12 Sep 2023 16:27:07 +0200 Subject: [PATCH 159/296] Explicitly define application commands --- src/SPC/ConsoleApplication.php | 50 +++++++++++++---------- src/SPC/command/DeployCommand.php | 2 +- src/SPC/command/dev/SortConfigCommand.php | 2 +- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index f43463ee..09c57238 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -4,7 +4,17 @@ declare(strict_types=1); namespace SPC; -use SPC\store\FileSystem; +use SPC\command\BuildCliCommand; +use SPC\command\BuildLibsCommand; +use SPC\command\DeployCommand; +use SPC\command\dev\AllExtCommand; +use SPC\command\dev\PhpVerCommand; +use SPC\command\dev\SortConfigCommand; +use SPC\command\DoctorCommand; +use SPC\command\DownloadCommand; +use SPC\command\DumpLicenseCommand; +use SPC\command\ExtractCommand; +use SPC\command\MicroCombineCommand; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\HelpCommand; use Symfony\Component\Console\Command\ListCommand; @@ -12,14 +22,10 @@ use Symfony\Component\Console\Command\ListCommand; /** * static-php-cli console app entry */ -class ConsoleApplication extends Application +final class ConsoleApplication extends Application { public const VERSION = '2.0-rc6'; - /** - * @throws \ReflectionException - * @throws exception\FileSystemException - */ public function __construct() { parent::__construct('static-php-cli', self::VERSION); @@ -29,21 +35,23 @@ class ConsoleApplication extends Application // Detailed debugging errors are not displayed in the production environment. Only the error display provided by Symfony console is used. $this->setCatchExceptions(file_exists(ROOT_DIR . '/.prod') || !in_array('--debug', $argv)); - // Add subcommands by scanning the directory src/static-php-cli/command/ - $commands = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/command', 'SPC\\command'); - $phar = class_exists('\\Phar') && \Phar::running() || !class_exists('\\Phar'); - $commands = array_filter($commands, function ($y) use ($phar) { - $archive_blacklist = [ - 'SPC\command\dev\SortConfigCommand', - 'SPC\command\DeployCommand', - ]; - if ($phar && in_array($y, $archive_blacklist)) { - return false; - } - $reflection = new \ReflectionClass($y); - return !$reflection->isAbstract() && !$reflection->isInterface(); - }); - $this->addCommands(array_map(function ($x) { return new $x(); }, $commands)); + $this->addCommands( + [ + new BuildCliCommand(), + new BuildLibsCommand(), + new DeployCommand(), + new DoctorCommand(), + new DownloadCommand(), + new DumpLicenseCommand(), + new ExtractCommand(), + new MicroCombineCommand(), + + // Dev commands + new AllExtCommand(), + new PhpVerCommand(), + new SortConfigCommand(), + ] + ); } protected function getDefaultCommands(): array diff --git a/src/SPC/command/DeployCommand.php b/src/SPC/command/DeployCommand.php index b5353619..770fc39c 100644 --- a/src/SPC/command/DeployCommand.php +++ b/src/SPC/command/DeployCommand.php @@ -13,7 +13,7 @@ use Symfony\Component\Console\Input\InputOption; use function Laravel\Prompts\confirm; use function Laravel\Prompts\text; -#[AsCommand('deploy', 'Deploy static-php-cli self to an .phar application')] +#[AsCommand('deploy', 'Deploy static-php-cli self to an .phar application', [], true)] class DeployCommand extends BaseCommand { public function configure(): void diff --git a/src/SPC/command/dev/SortConfigCommand.php b/src/SPC/command/dev/SortConfigCommand.php index bee44ff9..8eb7680a 100644 --- a/src/SPC/command/dev/SortConfigCommand.php +++ b/src/SPC/command/dev/SortConfigCommand.php @@ -15,7 +15,7 @@ use Symfony\Component\Console\Input\InputArgument; /** * Modify config file: sort lib, ext, source by name. */ -#[AsCommand('dev:sort-config', 'After config edited, sort it by alphabet', ['sort-config'])] +#[AsCommand('dev:sort-config', 'After config edited, sort it by alphabet', ['sort-config'], true)] class SortConfigCommand extends BaseCommand { public function configure(): void From 5efc15b40461725181179c45c50b5dc7c48d1b23 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 12 Sep 2023 00:09:49 +0800 Subject: [PATCH 160/296] fix libwebp pkgconfig patch, add custom patch argument --- src/SPC/builder/traits/UnixLibraryTrait.php | 3 ++- src/SPC/builder/unix/library/libwebp.php | 3 ++- src/globals/defines.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index 2f988945..0e4665a0 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -66,7 +66,7 @@ trait UnixLibraryTrait * @throws FileSystemException * @throws RuntimeException */ - public function patchPkgconfPrefix(array $files, int $patch_option = PKGCONF_PATCH_ALL): void + public function patchPkgconfPrefix(array $files, int $patch_option = PKGCONF_PATCH_ALL, ?array $custom_replace = null): void { logger()->info('Patching library [' . static::NAME . '] pkgconfig'); foreach ($files as $name) { @@ -81,6 +81,7 @@ trait UnixLibraryTrait $file = ($patch_option & PKGCONF_PATCH_EXEC_PREFIX) === PKGCONF_PATCH_EXEC_PREFIX ? preg_replace('/^exec_prefix=.*$/m', 'exec_prefix=${prefix}', $file) : $file; $file = ($patch_option & PKGCONF_PATCH_LIBDIR) === PKGCONF_PATCH_LIBDIR ? preg_replace('/^libdir=.*$/m', 'libdir=${prefix}/lib', $file) : $file; $file = ($patch_option & PKGCONF_PATCH_INCLUDEDIR) === PKGCONF_PATCH_INCLUDEDIR ? preg_replace('/^includedir=.*$/m', 'includedir=${prefix}/include', $file) : $file; + $file = ($patch_option & PKGCONF_PATCH_CUSTOM) === PKGCONF_PATCH_CUSTOM && $custom_replace !== null ? preg_replace($custom_replace[0], $custom_replace[1], $file) : $file; FileSystem::writeFile($realpath, $file); } } diff --git a/src/SPC/builder/unix/library/libwebp.php b/src/SPC/builder/unix/library/libwebp.php index 3cdeb3ff..32aa7201 100644 --- a/src/SPC/builder/unix/library/libwebp.php +++ b/src/SPC/builder/unix/library/libwebp.php @@ -32,7 +32,8 @@ trait libwebp ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); // patch pkgconfig - $this->patchPkgconfPrefix(['libsharpyuv.pc', 'libwebp.pc', 'libwebpdecoder.pc', 'libwebpdemux.pc', 'libwebpmux.pc'], PKGCONF_PATCH_PREFIX); + $this->patchPkgconfPrefix(['libsharpyuv.pc', 'libwebp.pc', 'libwebpdecoder.pc', 'libwebpdemux.pc', 'libwebpmux.pc'], PKGCONF_PATCH_PREFIX | PKGCONF_PATCH_LIBDIR); + $this->patchPkgconfPrefix(['libsharpyuv.pc'], PKGCONF_PATCH_CUSTOM, ['/^includedir=.*$/m', 'includedir=${prefix}/include/webp']); $this->cleanLaFiles(); } } diff --git a/src/globals/defines.php b/src/globals/defines.php index 150b2753..cd29fb42 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -56,6 +56,7 @@ const PKGCONF_PATCH_PREFIX = 1; const PKGCONF_PATCH_EXEC_PREFIX = 2; const PKGCONF_PATCH_LIBDIR = 4; const PKGCONF_PATCH_INCLUDEDIR = 8; -const PKGCONF_PATCH_ALL = 15; +const PKGCONF_PATCH_CUSTOM = 16; +const PKGCONF_PATCH_ALL = 31; ConsoleLogger::$date_format = 'H:i:s'; From 9da20497ccd7d5de0b2743e1e60d2e7d5b9c0c7c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 12 Sep 2023 00:11:41 +0800 Subject: [PATCH 161/296] fix ln src and dst for brotli --- src/SPC/builder/unix/library/brotli.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index 3dae0814..b84fc7ed 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -28,9 +28,9 @@ trait brotli ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']); shell()->cd(BUILD_ROOT_PATH . '/lib') - ->exec('ln -s libbrotlicommon-static.a libbrotlicommon.a') - ->exec('ln -s libbrotlidec-static.a libbrotlidec.a') - ->exec('ln -s libbrotlienc-static.a libbrotlienc.a'); + ->exec('ln -s libbrotlicommon.a libbrotlicommon-static.a') + ->exec('ln -s libbrotlidec.a libbrotlidec-static.a') + ->exec('ln -s libbrotlienc.a libbrotlienc-static.a'); foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) { if (str_starts_with($filename, 'libbrotli') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) { unlink(BUILD_ROOT_PATH . '/lib/' . $filename); From 4b500f2dd8bb349166273f22d36826ad737005db Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 12 Sep 2023 00:08:00 +0800 Subject: [PATCH 162/296] remove redundant libssh2 cmake build target option --- src/SPC/builder/unix/library/libssh2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/libssh2.php b/src/SPC/builder/unix/library/libssh2.php index 04aa5882..a207f27b 100644 --- a/src/SPC/builder/unix/library/libssh2.php +++ b/src/SPC/builder/unix/library/libssh2.php @@ -29,7 +29,7 @@ trait libssh2 "-DENABLE_ZLIB_COMPRESSION={$enable_zlib} " . '..' ) - ->exec("cmake --build . -j {$this->builder->concurrency} --target libssh2") + ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libssh2.pc']); } From c63136d4844176d593c18f1f16fb11fb66d0abe6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 12 Sep 2023 23:27:29 +0800 Subject: [PATCH 163/296] change dev:extensions argument to comma separated --- src/SPC/command/dev/AllExtCommand.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index b47bdf8e..cc8169ae 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -6,6 +6,7 @@ namespace SPC\command\dev; use SPC\command\BaseCommand; use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\util\DependencyUtil; @@ -18,15 +19,17 @@ class AllExtCommand extends BaseCommand { public function configure(): void { - $this->addArgument('extensions', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'Extension name', null); + $this->addArgument('extensions', InputArgument::OPTIONAL, 'The extensions will be shown, comma separated'); } /** * @throws FileSystemException + * @throws WrongUsageException + * @throws RuntimeException */ public function handle(): int { - $extensions = $this->input->getArgument('extensions') ?: []; + $extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions') ?? ''))); $style = new SymfonyStyle($this->input, $this->output); $style->writeln($extensions ? 'Available extensions:' : 'Extensions:'); From 1a81fe6a0d763a3b2119174e02b1fd3220063c78 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 12 Sep 2023 23:29:17 +0800 Subject: [PATCH 164/296] change help message for dev:extensions --- src/SPC/command/dev/AllExtCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index cc8169ae..52eb38dc 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -19,7 +19,7 @@ class AllExtCommand extends BaseCommand { public function configure(): void { - $this->addArgument('extensions', InputArgument::OPTIONAL, 'The extensions will be shown, comma separated'); + $this->addArgument('extensions', InputArgument::OPTIONAL, 'List of extensions that will be displayed, comma separated'); } /** From 4b1d59c5a918a436e84ff29eb9d85cfb8c78905f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Tue, 12 Sep 2023 22:25:31 +0200 Subject: [PATCH 165/296] Link to FrankenPHP docs about embed SAPI in README-en.md --- README-en.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README-en.md b/README-en.md index afc35f94..8ed058f5 100755 --- a/README-en.md +++ b/README-en.md @@ -199,12 +199,14 @@ Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./ph When using the project parameters `--build-embed` or `--build-all`, the final compilation result will output a `libphp.a`, `php-config` and a series of header files, -stored in `buildroot/`, You can introduce them in your other projects. +stored in `buildroot/`. You can introduce them in your other projects. -If you know embed SAPI, you should know how to use it. +If you know [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed), you should know how to use it. You may require the introduction of other libraries during compilation, you can use `buildroot/bin/php-config` to obtain the compile-time configuration. +For an advanced example of how to use this feature, take a look at [how to use it to build a static version of FrankenPHP](https://github.com/dunglas/frankenphp/blob/main/docs/static.md). + ## Contribution If the extension you need is missing, you can create an issue. From 06f29712e2bc76c4129cd06b2022bede04c58f84 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 13 Sep 2023 10:01:08 +0800 Subject: [PATCH 166/296] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 62c9bab4..65196b1f 100755 --- a/README.md +++ b/README.md @@ -186,7 +186,9 @@ cat micro.sfx code.php > single-app && chmod +x single-app 采用项目参数 `--build-embed` 或 `--build-all` 时,最后编译结果会输出一个 `libphp.a`、`php-config` 以及一系列头文件,存放在 `buildroot/`,你可以在你的其他代码中引入它们。 -如果你知道 embed SAPI,你应该知道如何使用它。对于有可能编译用到引入其他库的问题,你可以使用 `buildroot/bin/php-config` 来获取编译时的配置。 +如果你知道 [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed),你应该知道如何使用它。对于有可能编译用到引入其他库的问题,你可以使用 `buildroot/bin/php-config` 来获取编译时的配置。 + +另外,有关如何使用此功能的高级示例,请查看[如何使用它构建 FrankenPHP 的静态版本](https://github.com/dunglas/frankenphp/blob/main/docs/static.md)。 ## 贡献 From 4a17491aaa2562af18414a1b473756238b298c93 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 12 Sep 2023 10:42:40 +0200 Subject: [PATCH 167/296] Initial code to get Box for phar building --- .github/workflows/phar-build.yml | 64 ++++++++++++++++++++++++++++++++ box.json | 10 +++++ composer.json | 4 +- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/phar-build.yml create mode 100644 box.json diff --git a/.github/workflows/phar-build.yml b/.github/workflows/phar-build.yml new file mode 100644 index 00000000..ff2de60b --- /dev/null +++ b/.github/workflows/phar-build.yml @@ -0,0 +1,64 @@ +name: Build PHAR + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build-phar: + name: "Build PHAR" + + runs-on: ${{ matrix.operating-system }} + + strategy: + fail-fast: false + matrix: + dependencies: + - "locked" + php-version: + - "8.1" + operating-system: + - "ubuntu-latest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: none + tools: composer:v2 + php-version: "${{ matrix.php-version }}" + ini-values: memory_limit=-1 + + - name: "Get Composer Cache Directory" + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: "Cache Composer dependencies" + uses: "actions/cache@v3" + with: + path: "${{ steps.composer-cache.outputs.dir }}" + key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}" + restore-keys: | + php-${{ matrix.php-version }}-locked-composer- + + - name: "Install locked dependencies" + run: "composer install --no-interaction --no-progress" + + - name: "Build PHAR file" + run: "composer build:phar" + + - name: "Test PHAR file" + run: "./spc.phar dev:extensions" + + - uses: actions/upload-artifact@v3 + with: + path: spc.phar diff --git a/box.json b/box.json new file mode 100644 index 00000000..e688155e --- /dev/null +++ b/box.json @@ -0,0 +1,10 @@ +{ + "alias": "spc-php.phar", + "banner": false, + "blacklist": [ + ".github", + "tests" + ], + "git-commit-short": "git_commit_short", + "output": "spc.phar" +} diff --git a/composer.json b/composer.json index 14f6189b..706f8d64 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "captainhook/captainhook": "^5.10", "captainhook/plugin-composer": "^5.3", "friendsofphp/php-cs-fixer": "^3.25", + "humbug/box": "^4.3", "nunomaduro/collision": "^7.8", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^10.3" @@ -44,7 +45,8 @@ "scripts": { "analyse": "phpstan analyse --memory-limit 300M", "cs-fix": "php-cs-fixer fix", - "test": "vendor/bin/phpunit tests/ --no-coverage" + "test": "vendor/bin/phpunit tests/ --no-coverage", + "build:phar": "vendor/bin/box compile" }, "config": { "allow-plugins": { From 6b061e6332bafd4b11f1b50dc4b29e859b6ce1dc Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 12 Sep 2023 16:11:32 +0200 Subject: [PATCH 168/296] Adjust box configuration for smaller phar size --- box.json | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/box.json b/box.json index e688155e..ad1d3c01 100644 --- a/box.json +++ b/box.json @@ -2,8 +2,15 @@ "alias": "spc-php.phar", "banner": false, "blacklist": [ - ".github", - "tests" + ".github" + ], + "directories": [ + "config", + "src", + "vendor/psr", + "vendor/laravel/prompts", + "vendor/symfony", + "vendor/zhamao" ], "git-commit-short": "git_commit_short", "output": "spc.phar" From a63e3f45755fd460da698c0e235f8fc52c30ecf3 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 12 Sep 2023 17:58:46 +0200 Subject: [PATCH 169/296] Add version into phar --- box.json | 1 + 1 file changed, 1 insertion(+) diff --git a/box.json b/box.json index ad1d3c01..e5f82806 100644 --- a/box.json +++ b/box.json @@ -13,5 +13,6 @@ "vendor/zhamao" ], "git-commit-short": "git_commit_short", + "metadata": "ConsoleApplication::VERSION", "output": "spc.phar" } From 16cc5df66dc17f9c87e44b14180f300e230f5b40 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 12 Sep 2023 18:06:39 +0200 Subject: [PATCH 170/296] Temporary disable phar build in GH actions --- .github/workflows/phar-build.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/phar-build.yml b/.github/workflows/phar-build.yml index ff2de60b..a1029e9e 100644 --- a/.github/workflows/phar-build.yml +++ b/.github/workflows/phar-build.yml @@ -1,10 +1,11 @@ name: Build PHAR -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] +# Temporary disabled, please follow: https://github.com/crazywhalecc/static-php-cli/issues/179 +#on: +# push: +# branches: [ "main" ] +# pull_request: +# branches: [ "main" ] permissions: contents: read From b2ea479fac1a3236047461f9c843d24afa951ac1 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Wed, 13 Sep 2023 15:06:08 +0200 Subject: [PATCH 171/296] Remove the phar workflow temporary --- .github/workflows/phar-build.yml | 65 -------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 .github/workflows/phar-build.yml diff --git a/.github/workflows/phar-build.yml b/.github/workflows/phar-build.yml deleted file mode 100644 index a1029e9e..00000000 --- a/.github/workflows/phar-build.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Build PHAR - -# Temporary disabled, please follow: https://github.com/crazywhalecc/static-php-cli/issues/179 -#on: -# push: -# branches: [ "main" ] -# pull_request: -# branches: [ "main" ] - -permissions: - contents: read - -jobs: - build-phar: - name: "Build PHAR" - - runs-on: ${{ matrix.operating-system }} - - strategy: - fail-fast: false - matrix: - dependencies: - - "locked" - php-version: - - "8.1" - operating-system: - - "ubuntu-latest" - - steps: - - name: "Checkout" - uses: "actions/checkout@v4" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: none - tools: composer:v2 - php-version: "${{ matrix.php-version }}" - ini-values: memory_limit=-1 - - - name: "Get Composer Cache Directory" - id: composer-cache - run: | - echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: "Cache Composer dependencies" - uses: "actions/cache@v3" - with: - path: "${{ steps.composer-cache.outputs.dir }}" - key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}" - restore-keys: | - php-${{ matrix.php-version }}-locked-composer- - - - name: "Install locked dependencies" - run: "composer install --no-interaction --no-progress" - - - name: "Build PHAR file" - run: "composer build:phar" - - - name: "Test PHAR file" - run: "./spc.phar dev:extensions" - - - uses: actions/upload-artifact@v3 - with: - path: spc.phar From f1d5916090677bd7e2dc1b1788a3b57b42517052 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 13 Sep 2023 21:33:12 +0800 Subject: [PATCH 172/296] remove unused old deploy command --- src/SPC/ConsoleApplication.php | 2 - src/SPC/command/DeployCommand.php | 166 ------------------------------ 2 files changed, 168 deletions(-) delete mode 100644 src/SPC/command/DeployCommand.php diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 09c57238..b3e1de8b 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -6,7 +6,6 @@ namespace SPC; use SPC\command\BuildCliCommand; use SPC\command\BuildLibsCommand; -use SPC\command\DeployCommand; use SPC\command\dev\AllExtCommand; use SPC\command\dev\PhpVerCommand; use SPC\command\dev\SortConfigCommand; @@ -39,7 +38,6 @@ final class ConsoleApplication extends Application [ new BuildCliCommand(), new BuildLibsCommand(), - new DeployCommand(), new DoctorCommand(), new DownloadCommand(), new DumpLicenseCommand(), diff --git a/src/SPC/command/DeployCommand.php b/src/SPC/command/DeployCommand.php deleted file mode 100644 index 770fc39c..00000000 --- a/src/SPC/command/DeployCommand.php +++ /dev/null @@ -1,166 +0,0 @@ -addArgument('target', InputArgument::OPTIONAL, 'The file or directory to pack.'); - $this->addOption('auto-phar-fix', null, InputOption::VALUE_NONE, 'Automatically fix ini option.'); - $this->addOption('overwrite', 'W', InputOption::VALUE_NONE, 'Overwrite existing files.'); - $this->addOption('with-no-dev', 'D', InputOption::VALUE_NONE, 'Automatically use non-dev composer dependencies to reduce size'); - $this->addOption('with-dev', 'd', InputOption::VALUE_NONE, 'Automatically use dev composer dependencies'); - } - - /** - * @throws \PharException - */ - public function handle(): int - { - $composer = require ROOT_DIR . '/vendor/composer/installed.php'; - if (($composer['root']['dev'] ?? false) === true) { - if (!$this->getOption('with-no-dev')) { - $this->output->writeln('Current static-php-cli dependencies have installed dev-dependencies'); - $this->output->writeln('If you want to remove, you can choose "Yes" to run command "composer update --no-dev" to remove.'); - $this->output->writeln('Or choose "No", just pack, deploy.'); - $ask = confirm('Do you want to remove dev-dependencies to reduce size of phar file?'); - } elseif (!$this->getOption('with-dev')) { - $ask = true; - } else { - $ask = false; - } - if ($ask) { - [$code] = shell()->execWithResult('composer update --no-dev'); - if ($code !== 0) { - $this->output->writeln('"composer update --no-dev" failed with exit code [' . $code . ']'); - $this->output->writeln('You may need to run this command by your own.'); - return static::FAILURE; - } - $this->output->writeln('Update successfully, you need to re-run deploy command to pack.'); - return static::SUCCESS; - } - } - // 首先得确认是不是关闭了readonly模式 - if (ini_get('phar.readonly') == 1) { - if ($this->getOption('auto-phar-fix')) { - $ask = true; - } else { - $this->output->writeln('pack command needs "phar.readonly" = "Off" !'); - $ask = confirm('Do you want to automatically set it and continue ?'); - // $ask = $prompt->requireBool('pack command needs "phar.readonly" = "Off" !' . PHP_EOL . 'If you want to automatically set it and continue, just Enter', true); - } - if ($ask) { - global $argv; - $args = array_merge(['-d', 'phar.readonly=0'], $_SERVER['argv'], ['--no-motd']); - if (function_exists('pcntl_exec')) { - $this->output->writeln('Changing to phar.readonly=0 mode ...'); - if (pcntl_exec(PHP_BINARY, $args) === false) { - throw new \PharException('Switching to read write mode failed, please check the environment.'); - } - } else { - $this->output->writeln('Now running command in child process.'); - passthru(PHP_BINARY . ' -d phar.readonly=0 ' . implode(' ', $argv), $retcode); - exit($retcode); - } - } - } - // 获取路径 - $path = WORKING_DIR; - // 如果是目录,则将目录下的所有文件打包 - $phar_path = text('Please input the phar target filename', default: '/tmp/static-php-cli.phar'); - // $phar_path = $prompt->requireArgument('target', 'Please input the phar target filename', 'static-php-cli.phar'); - - if (FileSystem::isRelativePath($phar_path)) { - $phar_path = WORKING_DIR . '/' . $phar_path; - } - if (file_exists($phar_path)) { - if (!$this->getOption('overwrite')) { - $this->output->writeln('The file "' . $phar_path . '" already exists.'); - $ask = confirm('Do you want to overwrite it?'); - } else { - $ask = true; - } - if (!$ask) { - $this->output->writeln('User canceled.'); - return static::FAILURE; - } - @unlink($phar_path); - } - $phar = new \Phar($phar_path); - $phar->startBuffering(); - - $all = FileSystem::scanDirFiles($path, true, true); - - $all = array_filter($all, function ($x) { - $dirs = preg_match('/(^(config|src|vendor)\\/|^(composer\\.json|README\\.md|source\\.json|LICENSE|README-en\\.md)$)/', $x); - return !($dirs !== 1); - }); - sort($all); - $map = []; - foreach ($all as $v) { - $map[$v] = $path . '/' . $v; - } - - $this->output->writeln('Start packing files...'); - try { - foreach ($this->progress()->iterate($map) as $file => $origin_file) { - $phar->addFromString($file, php_strip_whitespace($origin_file)); - } - // $phar->buildFromIterator(new SeekableArrayIterator($map, new ProgressBar($output))); - $phar->addFromString( - '.phar-entry.php', - str_replace( - '/../vendor/autoload.php', - '/vendor/autoload.php', - file_get_contents(ROOT_DIR . '/bin/spc') - ) - ); - $stub = '.phar-entry.php'; - $phar->setStub($phar->createDefaultStub($stub)); - } catch (\Throwable $e) { - $this->output->writeln($e); - return static::FAILURE; - } - $phar->addFromString('.prod', 'true'); - $phar->stopBuffering(); - $this->output->writeln(PHP_EOL . 'Done! Phar file is generated at "' . $phar_path . '".'); - if (file_exists(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx')) { - $this->output->writeln('Detected you have already compiled micro binary, I will make executable now for you!'); - file_put_contents( - pathinfo($phar_path, PATHINFO_DIRNAME) . '/spc', - file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx') . - file_get_contents($phar_path) - ); - chmod(pathinfo($phar_path, PATHINFO_DIRNAME) . '/spc', 0755); - $this->output->writeln('Binary Executable: ' . pathinfo($phar_path, PATHINFO_DIRNAME) . '/spc'); - } - chmod($phar_path, 0755); - $this->output->writeln('Phar Executable: ' . $phar_path . ''); - return static::SUCCESS; - } - - private function progress(): ProgressBar - { - $progress = new ProgressBar($this->output, 0); - $progress->setBarCharacter('⚬'); - $progress->setEmptyBarCharacter('⚬'); - $progress->setProgressCharacter('➤'); - $progress->setFormat( - "%current%/%max% [%bar%] %percent:3s%%\n🪅 %estimated:-20s% %memory:20s%" . PHP_EOL - ); - return $progress; - } -} From be321908298eb85231d928fb9bd747f72ff06f55 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Wed, 13 Sep 2023 13:07:22 +0200 Subject: [PATCH 173/296] Sanity check extensions by inline their test code --- src/SPC/builder/traits/UnixBuilderTrait.php | 11 ++++++++++- src/globals/tests/dom.php | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/traits/UnixBuilderTrait.php b/src/SPC/builder/traits/UnixBuilderTrait.php index 8dafe20a..5ca62f1b 100644 --- a/src/SPC/builder/traits/UnixBuilderTrait.php +++ b/src/SPC/builder/traits/UnixBuilderTrait.php @@ -66,14 +66,23 @@ trait UnixBuilderTrait if ($ret !== 0 || trim(implode('', $output)) !== 'hello') { throw new RuntimeException('cli failed sanity check'); } + foreach ($this->exts as $ext) { logger()->debug('testing ext: ' . $ext->getName()); [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $ext->getDistName() . '"', false); if ($ret !== 0) { throw new RuntimeException('extension ' . $ext->getName() . ' failed compile check'); } + if (file_exists(ROOT_DIR . '/src/globals/tests/' . $ext->getName() . '.php')) { - [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php ' . ROOT_DIR . '/src/globals/tests/' . $ext->getName() . '.php'); + // Trim additional content & escape special characters to allow inline usage + $test = str_replace( + ['getName() . '.php') + ); + + [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"'); if ($ret !== 0) { throw new RuntimeException('extension ' . $ext->getName() . ' failed sanity check'); } diff --git a/src/globals/tests/dom.php b/src/globals/tests/dom.php index f1f28d12..65e3617f 100644 --- a/src/globals/tests/dom.php +++ b/src/globals/tests/dom.php @@ -4,5 +4,5 @@ declare(strict_types=1); assert(class_exists('\\DOMDocument')); $doc = new DOMDocument(); -$doc->loadHtml("Hello"); +$doc->loadHtml('Hello'); assert($doc->getElementById('app')->nodeValue === 'Hello'); From 0c3885c33d8060dea23e4a383d4ed7e65903ba5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 14 Sep 2023 01:00:51 +0200 Subject: [PATCH 174/296] fix(docker): php82-sodium is required --- bin/spc-alpine-docker | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index cac01260..be3603d7 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -81,6 +81,7 @@ RUN apk update; \ php82-pcntl \ php82-phar \ php82-posix \ + php82-sodium \ php82-tokenizer \ php82-dom \ php82-xml \ @@ -88,8 +89,9 @@ RUN apk update; \ composer \ pkgconfig \ wget \ - xz -RUN ln -s /usr/bin/php82 /usr/bin/php + xz ; \ + ln -s /usr/bin/php82 /usr/bin/php + WORKDIR /app ADD ./src /app/src ADD ./composer.json /app/composer.json From 965e7a25e2967dca7bad9f47767aaf28016f6122 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Wed, 13 Sep 2023 19:04:54 +0200 Subject: [PATCH 175/296] Add `composer.lock` into repository --- .gitignore | 3 +- bin/spc-alpine-docker | 3 +- composer.lock | 5950 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 5953 insertions(+), 3 deletions(-) create mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index 278ef459..1f749916 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,7 @@ docker/libraries/ docker/extensions/ docker/source/ -# Composer file -composer.lock +# Vendor files /vendor/ # default source extract directory diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index be3603d7..a5cb31cc 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -95,8 +95,9 @@ RUN apk update; \ WORKDIR /app ADD ./src /app/src ADD ./composer.json /app/composer.json +ADD ./composer.lock /app/composer.lock ADD ./bin /app/bin -RUN composer update --no-dev --classmap-authoritative +RUN composer install --no-dev --classmap-authoritative EOF fi diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000..95f2b21b --- /dev/null +++ b/composer.lock @@ -0,0 +1,5950 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "ea069b1a67a9a432f954fe6dbd4fea48", + "packages": [ + { + "name": "illuminate/collections", + "version": "v10.23.1", + "source": { + "type": "git", + "url": "https://github.com/illuminate/collections.git", + "reference": "72c3cc6d44416db499d2ad11b8b27ae22e60a661" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/collections/zipball/72c3cc6d44416db499d2ad11b8b27ae22e60a661", + "reference": "72c3cc6d44416db499d2ad11b8b27ae22e60a661", + "shasum": "" + }, + "require": { + "illuminate/conditionable": "^10.0", + "illuminate/contracts": "^10.0", + "illuminate/macroable": "^10.0", + "php": "^8.1" + }, + "suggest": { + "symfony/var-dumper": "Required to use the dump method (^6.2)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "10.x-dev" + } + }, + "autoload": { + "files": [ + "helpers.php" + ], + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Collections package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2023-09-07T14:13:46+00:00" + }, + { + "name": "illuminate/conditionable", + "version": "v10.23.1", + "source": { + "type": "git", + "url": "https://github.com/illuminate/conditionable.git", + "reference": "d0958e4741fc9d6f516a552060fd1b829a85e009" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/conditionable/zipball/d0958e4741fc9d6f516a552060fd1b829a85e009", + "reference": "d0958e4741fc9d6f516a552060fd1b829a85e009", + "shasum": "" + }, + "require": { + "php": "^8.0.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "10.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Conditionable package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2023-02-03T08:06:17+00:00" + }, + { + "name": "illuminate/contracts", + "version": "v10.23.1", + "source": { + "type": "git", + "url": "https://github.com/illuminate/contracts.git", + "reference": "6c39fba7b2311e28f5c6ac7d729e3d49a2a98406" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/6c39fba7b2311e28f5c6ac7d729e3d49a2a98406", + "reference": "6c39fba7b2311e28f5c6ac7d729e3d49a2a98406", + "shasum": "" + }, + "require": { + "php": "^8.1", + "psr/container": "^1.1.1|^2.0.1", + "psr/simple-cache": "^1.0|^2.0|^3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "10.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Contracts\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Contracts package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2023-09-05T19:07:46+00:00" + }, + { + "name": "illuminate/macroable", + "version": "v10.23.1", + "source": { + "type": "git", + "url": "https://github.com/illuminate/macroable.git", + "reference": "dff667a46ac37b634dcf68909d9d41e94dc97c27" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/macroable/zipball/dff667a46ac37b634dcf68909d9d41e94dc97c27", + "reference": "dff667a46ac37b634dcf68909d9d41e94dc97c27", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "10.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Macroable package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2023-06-05T12:46:42+00:00" + }, + { + "name": "laravel/prompts", + "version": "v0.1.7", + "source": { + "type": "git", + "url": "https://github.com/laravel/prompts.git", + "reference": "554e7d855a22e87942753d68e23b327ad79b2070" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/prompts/zipball/554e7d855a22e87942753d68e23b327ad79b2070", + "reference": "554e7d855a22e87942753d68e23b327ad79b2070", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "illuminate/collections": "^10.0|^11.0", + "php": "^8.1", + "symfony/console": "^6.2" + }, + "require-dev": { + "mockery/mockery": "^1.5", + "pestphp/pest": "^2.3", + "phpstan/phpstan": "^1.10", + "phpstan/phpstan-mockery": "^1.1" + }, + "suggest": { + "ext-pcntl": "Required for the spinner to be animated." + }, + "type": "library", + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Laravel\\Prompts\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "support": { + "issues": "https://github.com/laravel/prompts/issues", + "source": "https://github.com/laravel/prompts/tree/v0.1.7" + }, + "time": "2023-09-12T11:09:22+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "psr/log", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.0" + }, + "time": "2021-07-14T16:46:02+00:00" + }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + }, + "time": "2021-10-29T13:26:27+00:00" + }, + { + "name": "symfony/console", + "version": "v6.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/eca495f2ee845130855ddf1cf18460c38966c8b6", + "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/string": "^5.4|^6.0" + }, + "conflict": { + "symfony/dependency-injection": "<5.4", + "symfony/dotenv": "<5.4", + "symfony/event-dispatcher": "<5.4", + "symfony/lock": "<5.4", + "symfony/process": "<5.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/event-dispatcher": "^5.4|^6.0", + "symfony/lock": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0", + "symfony/var-dumper": "^5.4|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command-line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v6.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-08-16T10:10:12+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-23T14:45:45+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.28.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-26T09:26:14+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.28.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "875e90aeea2777b6f135677f618529449334a612" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/875e90aeea2777b6f135677f618529449334a612", + "reference": "875e90aeea2777b6f135677f618529449334a612", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.28.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-26T09:26:14+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.28.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-26T09:26:14+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.28.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "42292d99c55abe617799667f454222c54c60e229" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", + "reference": "42292d99c55abe617799667f454222c54c60e229", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-07-28T09:04:16+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v3.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", + "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/container": "^2.0" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v3.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-23T14:45:45+00:00" + }, + { + "name": "symfony/string", + "version": "v6.3.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "53d1a83225002635bca3482fcbf963001313fb68" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/53d1a83225002635bca3482fcbf963001313fb68", + "reference": "53d1a83225002635bca3482fcbf963001313fb68", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/translation-contracts": "<2.5" + }, + "require-dev": { + "symfony/error-handler": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/intl": "^6.2", + "symfony/translation-contracts": "^2.5|^3.0", + "symfony/var-exporter": "^5.4|^6.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v6.3.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-07-05T08:41:27+00:00" + }, + { + "name": "zhamao/logger", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/zhamao-robot/zhamao-logger.git", + "reference": "1b7e34349330a842887d816f0344aba996cfeec0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zhamao-robot/zhamao-logger/zipball/1b7e34349330a842887d816f0344aba996cfeec0", + "reference": "1b7e34349330a842887d816f0344aba996cfeec0", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^7.3 || ^7.4 || ^8.0 || ^8.1", + "psr/log": "^1 || ^2 || ^3", + "symfony/polyfill-mbstring": "^1.0" + }, + "require-dev": { + "brainmaestro/composer-git-hooks": "^2.8", + "friendsofphp/php-cs-fixer": "^3.2", + "phpstan/phpstan": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.0", + "roave/security-advisories": "dev-latest" + }, + "suggest": { + "ext-mbstring": "Use C/C++ extension instead of polyfill will be more efficient" + }, + "type": "library", + "extra": { + "hooks": { + "post-merge": "composer install", + "pre-commit": [ + "echo committing as $(git config user.name)", + "composer cs-fix -- --diff" + ], + "pre-push": [ + "composer cs-fix -- --dry-run --diff", + "composer analyse" + ] + } + }, + "autoload": { + "psr-4": { + "ZM\\Logger\\": "src/ZM/Logger" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "jerry", + "email": "admin@zhamao.me" + }, + { + "name": "sunxyw", + "email": "dev@sunxyw.xyz" + } + ], + "description": "Another Console Logger for CLI Applications", + "support": { + "issues": "https://github.com/zhamao-robot/zhamao-logger/issues", + "source": "https://github.com/zhamao-robot/zhamao-logger/tree/1.1.1" + }, + "time": "2023-03-09T15:41:10+00:00" + } + ], + "packages-dev": [ + { + "name": "amphp/amp", + "version": "v2.6.2", + "source": { + "type": "git", + "url": "https://github.com/amphp/amp.git", + "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/amp/zipball/9d5100cebffa729aaffecd3ad25dc5aeea4f13bb", + "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1", + "ext-json": "*", + "jetbrains/phpstorm-stubs": "^2019.3", + "phpunit/phpunit": "^7 | ^8 | ^9", + "psalm/phar": "^3.11@dev", + "react/promise": "^2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "files": [ + "lib/functions.php", + "lib/Internal/functions.php" + ], + "psr-4": { + "Amp\\": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Bob Weinand", + "email": "bobwei9@hotmail.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A non-blocking concurrency framework for PHP applications.", + "homepage": "https://amphp.org/amp", + "keywords": [ + "async", + "asynchronous", + "awaitable", + "concurrency", + "event", + "event-loop", + "future", + "non-blocking", + "promise" + ], + "support": { + "irc": "irc://irc.freenode.org/amphp", + "issues": "https://github.com/amphp/amp/issues", + "source": "https://github.com/amphp/amp/tree/v2.6.2" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2022-02-20T17:52:18+00:00" + }, + { + "name": "amphp/byte-stream", + "version": "v1.8.1", + "source": { + "type": "git", + "url": "https://github.com/amphp/byte-stream.git", + "reference": "acbd8002b3536485c997c4e019206b3f10ca15bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/acbd8002b3536485c997c4e019206b3f10ca15bd", + "reference": "acbd8002b3536485c997c4e019206b3f10ca15bd", + "shasum": "" + }, + "require": { + "amphp/amp": "^2", + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1.4", + "friendsofphp/php-cs-fixer": "^2.3", + "jetbrains/phpstorm-stubs": "^2019.3", + "phpunit/phpunit": "^6 || ^7 || ^8", + "psalm/phar": "^3.11.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Amp\\ByteStream\\": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A stream abstraction to make working with non-blocking I/O simple.", + "homepage": "http://amphp.org/byte-stream", + "keywords": [ + "amp", + "amphp", + "async", + "io", + "non-blocking", + "stream" + ], + "support": { + "irc": "irc://irc.freenode.org/amphp", + "issues": "https://github.com/amphp/byte-stream/issues", + "source": "https://github.com/amphp/byte-stream/tree/v1.8.1" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2021-03-30T17:13:30+00:00" + }, + { + "name": "amphp/parallel", + "version": "v1.4.3", + "source": { + "type": "git", + "url": "https://github.com/amphp/parallel.git", + "reference": "3aac213ba7858566fd83d38ccb85b91b2d652cb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/parallel/zipball/3aac213ba7858566fd83d38ccb85b91b2d652cb0", + "reference": "3aac213ba7858566fd83d38ccb85b91b2d652cb0", + "shasum": "" + }, + "require": { + "amphp/amp": "^2", + "amphp/byte-stream": "^1.6.1", + "amphp/parser": "^1", + "amphp/process": "^1", + "amphp/serialization": "^1", + "amphp/sync": "^1.0.1", + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1.1", + "phpunit/phpunit": "^8 || ^7" + }, + "type": "library", + "autoload": { + "files": [ + "lib/Context/functions.php", + "lib/Sync/functions.php", + "lib/Worker/functions.php" + ], + "psr-4": { + "Amp\\Parallel\\": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Stephen Coakley", + "email": "me@stephencoakley.com" + } + ], + "description": "Parallel processing component for Amp.", + "homepage": "https://github.com/amphp/parallel", + "keywords": [ + "async", + "asynchronous", + "concurrent", + "multi-processing", + "multi-threading" + ], + "support": { + "issues": "https://github.com/amphp/parallel/issues", + "source": "https://github.com/amphp/parallel/tree/v1.4.3" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2023-03-23T08:04:23+00:00" + }, + { + "name": "amphp/parallel-functions", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/amphp/parallel-functions.git", + "reference": "04e92fcacfc921a56dfe12c23b3265e62593a7cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/parallel-functions/zipball/04e92fcacfc921a56dfe12c23b3265e62593a7cb", + "reference": "04e92fcacfc921a56dfe12c23b3265e62593a7cb", + "shasum": "" + }, + "require": { + "amphp/amp": "^2.0.3", + "amphp/parallel": "^1.4", + "amphp/serialization": "^1.0", + "laravel/serializable-closure": "^1.0", + "php": ">=7.4" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "v2.x-dev", + "amphp/phpunit-util": "^2.0", + "phpunit/phpunit": "^9.5.11" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Amp\\ParallelFunctions\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Parallel processing made simple.", + "support": { + "issues": "https://github.com/amphp/parallel-functions/issues", + "source": "https://github.com/amphp/parallel-functions/tree/v1.1.0" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2022-02-03T19:32:41+00:00" + }, + { + "name": "amphp/parser", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/amphp/parser.git", + "reference": "ff1de4144726c5dad5fab97f66692ebe8de3e151" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/parser/zipball/ff1de4144726c5dad5fab97f66692ebe8de3e151", + "reference": "ff1de4144726c5dad5fab97f66692ebe8de3e151", + "shasum": "" + }, + "require": { + "php": ">=7.4" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Amp\\Parser\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A generator parser to make streaming parsers simple.", + "homepage": "https://github.com/amphp/parser", + "keywords": [ + "async", + "non-blocking", + "parser", + "stream" + ], + "support": { + "issues": "https://github.com/amphp/parser/issues", + "source": "https://github.com/amphp/parser/tree/v1.1.0" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2022-12-30T18:08:47+00:00" + }, + { + "name": "amphp/process", + "version": "v1.1.4", + "source": { + "type": "git", + "url": "https://github.com/amphp/process.git", + "reference": "76e9495fd6818b43a20167cb11d8a67f7744ee0f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/process/zipball/76e9495fd6818b43a20167cb11d8a67f7744ee0f", + "reference": "76e9495fd6818b43a20167cb11d8a67f7744ee0f", + "shasum": "" + }, + "require": { + "amphp/amp": "^2", + "amphp/byte-stream": "^1.4", + "php": ">=7" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1", + "phpunit/phpunit": "^6" + }, + "type": "library", + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Amp\\Process\\": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bob Weinand", + "email": "bobwei9@hotmail.com" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Asynchronous process manager.", + "homepage": "https://github.com/amphp/process", + "support": { + "issues": "https://github.com/amphp/process/issues", + "source": "https://github.com/amphp/process/tree/v1.1.4" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2022-07-06T23:50:12+00:00" + }, + { + "name": "amphp/serialization", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/amphp/serialization.git", + "reference": "693e77b2fb0b266c3c7d622317f881de44ae94a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/serialization/zipball/693e77b2fb0b266c3c7d622317f881de44ae94a1", + "reference": "693e77b2fb0b266c3c7d622317f881de44ae94a1", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "phpunit/phpunit": "^9 || ^8 || ^7" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Amp\\Serialization\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Serialization tools for IPC and data storage in PHP.", + "homepage": "https://github.com/amphp/serialization", + "keywords": [ + "async", + "asynchronous", + "serialization", + "serialize" + ], + "support": { + "issues": "https://github.com/amphp/serialization/issues", + "source": "https://github.com/amphp/serialization/tree/master" + }, + "time": "2020-03-25T21:39:07+00:00" + }, + { + "name": "amphp/sync", + "version": "v1.4.2", + "source": { + "type": "git", + "url": "https://github.com/amphp/sync.git", + "reference": "85ab06764f4f36d63b1356b466df6111cf4b89cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/sync/zipball/85ab06764f4f36d63b1356b466df6111cf4b89cf", + "reference": "85ab06764f4f36d63b1356b466df6111cf4b89cf", + "shasum": "" + }, + "require": { + "amphp/amp": "^2.2", + "php": ">=7.1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "dev-master", + "amphp/phpunit-util": "^1.1", + "phpunit/phpunit": "^9 || ^8 || ^7" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php", + "src/ConcurrentIterator/functions.php" + ], + "psr-4": { + "Amp\\Sync\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Stephen Coakley", + "email": "me@stephencoakley.com" + } + ], + "description": "Mutex, Semaphore, and other synchronization tools for Amp.", + "homepage": "https://github.com/amphp/sync", + "keywords": [ + "async", + "asynchronous", + "mutex", + "semaphore", + "synchronization" + ], + "support": { + "issues": "https://github.com/amphp/sync/issues", + "source": "https://github.com/amphp/sync/tree/v1.4.2" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2021-10-25T18:29:10+00:00" + }, + { + "name": "captainhook/captainhook", + "version": "5.16.4", + "source": { + "type": "git", + "url": "https://github.com/captainhookphp/captainhook.git", + "reference": "524c8660551bafe9c7211440a71a35984e8dfc4b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/524c8660551bafe9c7211440a71a35984e8dfc4b", + "reference": "524c8660551bafe9c7211440a71a35984e8dfc4b", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-spl": "*", + "ext-xml": "*", + "php": ">=7.4", + "sebastianfeldmann/camino": "^0.9.2", + "sebastianfeldmann/cli": "^3.3", + "sebastianfeldmann/git": "^3.8.9", + "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0", + "symfony/filesystem": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0", + "symfony/process": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0" + }, + "replace": { + "sebastianfeldmann/captainhook": "*" + }, + "require-dev": { + "composer/composer": "~1 || ^2.0", + "mikey179/vfsstream": "~1" + }, + "bin": [ + "bin/captainhook" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0.x-dev" + }, + "captainhook": { + "config": "captainhook.json" + } + }, + "autoload": { + "psr-4": { + "CaptainHook\\App\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian Feldmann", + "email": "sf@sebastian-feldmann.info" + } + ], + "description": "PHP git hook manager", + "homepage": "https://github.com/captainhookphp/captainhook", + "keywords": [ + "commit-msg", + "git", + "hooks", + "post-merge", + "pre-commit", + "pre-push", + "prepare-commit-msg" + ], + "support": { + "issues": "https://github.com/captainhookphp/captainhook/issues", + "source": "https://github.com/captainhookphp/captainhook/tree/5.16.4" + }, + "funding": [ + { + "url": "https://github.com/sponsors/sebastianfeldmann", + "type": "github" + } + ], + "time": "2023-04-17T19:48:47+00:00" + }, + { + "name": "captainhook/plugin-composer", + "version": "5.3.3", + "source": { + "type": "git", + "url": "https://github.com/captainhookphp/plugin-composer.git", + "reference": "0a802aaf7742ef22b5cbccd586d99e16d9d23a39" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/captainhookphp/plugin-composer/zipball/0a802aaf7742ef22b5cbccd586d99e16d9d23a39", + "reference": "0a802aaf7742ef22b5cbccd586d99e16d9d23a39", + "shasum": "" + }, + "require": { + "captainhook/captainhook": "^5.0", + "composer-plugin-api": "^1.1|^2.0", + "php": ">=7.1" + }, + "require-dev": { + "composer/composer": "*" + }, + "type": "composer-plugin", + "extra": { + "class": "CaptainHook\\Plugin\\Composer\\ComposerPlugin", + "branch-alias": { + "dev-fluffy_hedgehog": "5.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "CaptainHook\\Plugin\\Composer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Heigl", + "email": "andreas@heigl.org" + }, + { + "name": "Sebastian Feldmann", + "email": "sf@sebastian-feldmann.info" + } + ], + "description": "Composer-Plugin handling your git-hooks", + "support": { + "issues": "https://github.com/captainhookphp/plugin-composer/issues", + "source": "https://github.com/captainhookphp/plugin-composer/tree/5.3.3" + }, + "time": "2022-01-28T04:35:22+00:00" + }, + { + "name": "composer/pcre", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.1.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-11-17T09:50:14+00:00" + }, + { + "name": "composer/semver", + "version": "3.4.0", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.4", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2023-08-31T09:50:34+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "ced299686f41dce890debac69273b47ffe98a40c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c", + "reference": "ced299686f41dce890debac69273b47ffe98a40c", + "shasum": "" + }, + "require": { + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.3" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-02-25T21:32:43+00:00" + }, + { + "name": "doctrine/deprecations", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9", + "phpstan/phpstan": "1.4.10 || 1.10.15", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "0.18.4", + "psr/log": "^1 || ^2 || ^3", + "vimeo/psalm": "4.30.0 || 5.12.0" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" + }, + "time": "2023-06-03T09:27:29+00:00" + }, + { + "name": "fidry/console", + "version": "0.5.5", + "source": { + "type": "git", + "url": "https://github.com/theofidry/console.git", + "reference": "bc1fe03f600c63f12ec0a39c6b746c1a1fb77bf7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theofidry/console/zipball/bc1fe03f600c63f12ec0a39c6b746c1a1fb77bf7", + "reference": "bc1fe03f600c63f12ec0a39c6b746c1a1fb77bf7", + "shasum": "" + }, + "require": { + "php": "^7.4.0 || ^8.0.0", + "symfony/console": "^4.4 || ^5.4 || ^6.1", + "symfony/event-dispatcher-contracts": "^1.0 || ^2.5 || ^3.0", + "symfony/service-contracts": "^1.0 || ^2.5 || ^3.0", + "thecodingmachine/safe": "^1.3 || ^2.0", + "webmozart/assert": "^1.11" + }, + "conflict": { + "symfony/dependency-injection": "<5.3.0", + "symfony/framework-bundle": "<5.3.0", + "symfony/http-kernel": "<5.3.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4", + "composer/semver": "^3.3", + "ergebnis/composer-normalize": "^2.28", + "infection/infection": "^0.26", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.4.3", + "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.1", + "symfony/framework-bundle": "^4.4 || ^5.4 || ^6.1", + "symfony/http-kernel": "^4.4 || ^5.4 || ^6.1", + "symfony/phpunit-bridge": "^4.4.47 || ^5.4 || ^6.0", + "symfony/yaml": "^4.4 || ^5.4 || ^6.1", + "webmozarts/strict-phpunit": "^7.3" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": false, + "forward-command": false + }, + "branch-alias": { + "dev-main": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Fidry\\Console\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Théo Fidry", + "email": "theo.fidry@gmail.com" + } + ], + "description": "Library to create CLI applications", + "keywords": [ + "cli", + "console", + "symfony" + ], + "support": { + "issues": "https://github.com/theofidry/console/issues", + "source": "https://github.com/theofidry/console/tree/0.5.5" + }, + "funding": [ + { + "url": "https://github.com/theofidry", + "type": "github" + } + ], + "time": "2022-12-18T10:49:34+00:00" + }, + { + "name": "filp/whoops", + "version": "2.15.3", + "source": { + "type": "git", + "url": "https://github.com/filp/whoops.git", + "reference": "c83e88a30524f9360b11f585f71e6b17313b7187" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/filp/whoops/zipball/c83e88a30524f9360b11f585f71e6b17313b7187", + "reference": "c83e88a30524f9360b11f585f71e6b17313b7187", + "shasum": "" + }, + "require": { + "php": "^5.5.9 || ^7.0 || ^8.0", + "psr/log": "^1.0.1 || ^2.0 || ^3.0" + }, + "require-dev": { + "mockery/mockery": "^0.9 || ^1.0", + "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.3", + "symfony/var-dumper": "^2.6 || ^3.0 || ^4.0 || ^5.0" + }, + "suggest": { + "symfony/var-dumper": "Pretty print complex values better with var-dumper available", + "whoops/soap": "Formats errors as SOAP responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Whoops\\": "src/Whoops/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Filipe Dobreira", + "homepage": "https://github.com/filp", + "role": "Developer" + } + ], + "description": "php error handling for cool kids", + "homepage": "https://filp.github.io/whoops/", + "keywords": [ + "error", + "exception", + "handling", + "library", + "throwable", + "whoops" + ], + "support": { + "issues": "https://github.com/filp/whoops/issues", + "source": "https://github.com/filp/whoops/tree/2.15.3" + }, + "funding": [ + { + "url": "https://github.com/denis-sokolov", + "type": "github" + } + ], + "time": "2023-07-13T12:00:00+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v3.26.1", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", + "reference": "d023ba6684055f6ea1da1352d8a02baca0426983" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/d023ba6684055f6ea1da1352d8a02baca0426983", + "reference": "d023ba6684055f6ea1da1352d8a02baca0426983", + "shasum": "" + }, + "require": { + "composer/semver": "^3.3", + "composer/xdebug-handler": "^3.0.3", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^7.4 || ^8.0", + "sebastian/diff": "^4.0 || ^5.0", + "symfony/console": "^5.4 || ^6.0", + "symfony/event-dispatcher": "^5.4 || ^6.0", + "symfony/filesystem": "^5.4 || ^6.0", + "symfony/finder": "^5.4 || ^6.0", + "symfony/options-resolver": "^5.4 || ^6.0", + "symfony/polyfill-mbstring": "^1.27", + "symfony/polyfill-php80": "^1.27", + "symfony/polyfill-php81": "^1.27", + "symfony/process": "^5.4 || ^6.0", + "symfony/stopwatch": "^5.4 || ^6.0" + }, + "require-dev": { + "facile-it/paraunit": "^1.3 || ^2.0", + "justinrainbow/json-schema": "^5.2", + "keradus/cli-executor": "^2.0", + "mikey179/vfsstream": "^1.6.11", + "php-coveralls/php-coveralls": "^2.5.3", + "php-cs-fixer/accessible-object": "^1.1", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", + "phpspec/prophecy": "^1.16", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.5", + "phpunitgoodpractices/polyfill": "^1.6", + "phpunitgoodpractices/traits": "^1.9.2", + "symfony/phpunit-bridge": "^6.2.3", + "symfony/yaml": "^5.4 || ^6.0" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "keywords": [ + "Static code analysis", + "fixer", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.26.1" + }, + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], + "time": "2023-09-08T19:09:07+00:00" + }, + { + "name": "humbug/box", + "version": "4.3.8", + "source": { + "type": "git", + "url": "https://github.com/box-project/box.git", + "reference": "55344067891d8be61e6efa50f7c2e59114f32704" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/box-project/box/zipball/55344067891d8be61e6efa50f7c2e59114f32704", + "reference": "55344067891d8be61e6efa50f7c2e59114f32704", + "shasum": "" + }, + "require": { + "amphp/parallel-functions": "^1.1", + "composer-plugin-api": "^2.2", + "composer/semver": "^3.3.2", + "composer/xdebug-handler": "^3.0.3", + "ext-phar": "*", + "ext-sodium": "*", + "fidry/console": "^0.5.3", + "humbug/php-scoper": "^0.18.3", + "justinrainbow/json-schema": "^5.2.12", + "laravel/serializable-closure": "^1.2.2", + "nikic/iter": "^2.2", + "nikic/php-parser": "^4.15.2", + "paragonie/constant_time_encoding": "^2.6", + "php": "^8.1", + "phpdocumentor/reflection-docblock": "^5.3", + "psr/log": "^3.0", + "seld/jsonlint": "^1.9", + "symfony/console": "^6.1.7", + "symfony/filesystem": "^6.1.5", + "symfony/finder": "^6.1.3", + "symfony/process": "^6.1.3", + "symfony/var-dumper": "^6.1.6", + "webmozart/assert": "^1.11" + }, + "replace": { + "paragonie/sodium_compat": "*", + "symfony/polyfill-php80": "*", + "symfony/polyfill-php81": "*" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ergebnis/composer-normalize": "^2.29", + "fidry/makefile": "^0.2.1", + "mikey179/vfsstream": "^1.6.11", + "phpspec/prophecy-phpunit": "^2.0.1", + "phpunit/phpunit": "^9.5.26", + "symfony/phpunit-bridge": "^6.1.6", + "symfony/yaml": "^6.2", + "webmozarts/strict-phpunit": "^7.6" + }, + "suggest": { + "ext-openssl": "To accelerate private key generation." + }, + "bin": [ + "bin/box" + ], + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": false, + "forward-command": false + }, + "branch-alias": { + "dev-main": "4.x-dev" + } + }, + "autoload": { + "files": [ + "src/FileSystem/file_system.php", + "src/consts.php", + "src/functions.php" + ], + "psr-4": { + "KevinGH\\Box\\": "src" + }, + "exclude-from-classmap": [ + "/Test/", + "vendor/humbug/php-scoper/vendor-hotfix" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Herrera", + "email": "kevin@herrera.io", + "homepage": "http://kevin.herrera.io" + }, + { + "name": "Théo Fidry", + "email": "theo.fidry@gmail.com" + } + ], + "description": "Fast, zero config application bundler with PHARs.", + "keywords": [ + "phar" + ], + "support": { + "issues": "https://github.com/box-project/box/issues", + "source": "https://github.com/box-project/box/tree/4.3.8" + }, + "time": "2023-03-17T08:30:03+00:00" + }, + { + "name": "humbug/php-scoper", + "version": "0.18.3", + "source": { + "type": "git", + "url": "https://github.com/humbug/php-scoper.git", + "reference": "1a49b88b7961152daf534757137b8f86f67fde23" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/humbug/php-scoper/zipball/1a49b88b7961152daf534757137b8f86f67fde23", + "reference": "1a49b88b7961152daf534757137b8f86f67fde23", + "shasum": "" + }, + "require": { + "fidry/console": "^0.5.0", + "jetbrains/phpstorm-stubs": "^v2022.2", + "nikic/php-parser": "^4.12", + "php": "^8.1", + "symfony/console": "^5.2 || ^6.0", + "symfony/filesystem": "^5.2 || ^6.0", + "symfony/finder": "^5.2 || ^6.0", + "thecodingmachine/safe": "^1.3 || ^2.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.1", + "ergebnis/composer-normalize": "^2.28", + "fidry/makefile": "^0.2.1", + "humbug/box": "^4.0", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.0", + "symfony/yaml": "^6.1" + }, + "bin": [ + "bin/php-scoper" + ], + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": false, + "forward-command": false + }, + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Humbug\\PhpScoper\\": "src/" + }, + "classmap": [ + "vendor-hotfix/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + }, + { + "name": "Théo Fidry", + "email": "theo.fidry@gmail.com" + }, + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com" + } + ], + "description": "Prefixes all PHP namespaces in a file or directory.", + "support": { + "issues": "https://github.com/humbug/php-scoper/issues", + "source": "https://github.com/humbug/php-scoper/tree/0.18.3" + }, + "time": "2023-03-16T22:49:19+00:00" + }, + { + "name": "jetbrains/phpstorm-stubs", + "version": "v2022.3", + "source": { + "type": "git", + "url": "https://github.com/JetBrains/phpstorm-stubs.git", + "reference": "6b568c153cea002dc6fad96285c3063d07cab18d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/JetBrains/phpstorm-stubs/zipball/6b568c153cea002dc6fad96285c3063d07cab18d", + "reference": "6b568c153cea002dc6fad96285c3063d07cab18d", + "shasum": "" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "@stable", + "nikic/php-parser": "@stable", + "php": "^8.0", + "phpdocumentor/reflection-docblock": "@stable", + "phpunit/phpunit": "@stable" + }, + "type": "library", + "autoload": { + "files": [ + "PhpStormStubsMap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "PHP runtime & extensions header files for PhpStorm", + "homepage": "https://www.jetbrains.com/phpstorm", + "keywords": [ + "autocomplete", + "code", + "inference", + "inspection", + "jetbrains", + "phpstorm", + "stubs", + "type" + ], + "support": { + "source": "https://github.com/JetBrains/phpstorm-stubs/tree/v2022.3" + }, + "time": "2022-10-17T09:21:37+00:00" + }, + { + "name": "justinrainbow/json-schema", + "version": "5.2.12", + "source": { + "type": "git", + "url": "https://github.com/justinrainbow/json-schema.git", + "reference": "ad87d5a5ca981228e0e205c2bc7dfb8e24559b60" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/ad87d5a5ca981228e0e205c2bc7dfb8e24559b60", + "reference": "ad87d5a5ca981228e0e205c2bc7dfb8e24559b60", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1", + "json-schema/json-schema-test-suite": "1.2.0", + "phpunit/phpunit": "^4.8.35" + }, + "bin": [ + "bin/validate-json" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "JsonSchema\\": "src/JsonSchema/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bruno Prieto Reis", + "email": "bruno.p.reis@gmail.com" + }, + { + "name": "Justin Rainbow", + "email": "justin.rainbow@gmail.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + }, + { + "name": "Robert Schönthal", + "email": "seroscho@googlemail.com" + } + ], + "description": "A library to validate a json schema.", + "homepage": "https://github.com/justinrainbow/json-schema", + "keywords": [ + "json", + "schema" + ], + "support": { + "issues": "https://github.com/justinrainbow/json-schema/issues", + "source": "https://github.com/justinrainbow/json-schema/tree/5.2.12" + }, + "time": "2022-04-13T08:02:27+00:00" + }, + { + "name": "laravel/serializable-closure", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/laravel/serializable-closure.git", + "reference": "e5a3057a5591e1cfe8183034b0203921abe2c902" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/e5a3057a5591e1cfe8183034b0203921abe2c902", + "reference": "e5a3057a5591e1cfe8183034b0203921abe2c902", + "shasum": "" + }, + "require": { + "php": "^7.3|^8.0" + }, + "require-dev": { + "nesbot/carbon": "^2.61", + "pestphp/pest": "^1.21.3", + "phpstan/phpstan": "^1.8.2", + "symfony/var-dumper": "^5.4.11" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Laravel\\SerializableClosure\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + }, + { + "name": "Nuno Maduro", + "email": "nuno@laravel.com" + } + ], + "description": "Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.", + "keywords": [ + "closure", + "laravel", + "serializable" + ], + "support": { + "issues": "https://github.com/laravel/serializable-closure/issues", + "source": "https://github.com/laravel/serializable-closure" + }, + "time": "2023-07-14T13:56:28+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.11.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2023-03-08T13:26:56+00:00" + }, + { + "name": "nikic/iter", + "version": "v2.3.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/iter.git", + "reference": "d9f88bc04b5b453914373e70c041353d8e67c3f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/iter/zipball/d9f88bc04b5b453914373e70c041353d8e67c3f5", + "reference": "d9f88bc04b5b453914373e70c041353d8e67c3f5", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpstan/phpstan": "^1.4", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "vimeo/psalm": "^4.18 || ^5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/iter.func.php", + "src/iter.php", + "src/iter.rewindable.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov", + "email": "nikic@php.net" + } + ], + "description": "Iteration primitives using generators", + "keywords": [ + "functional", + "generator", + "iterator" + ], + "support": { + "issues": "https://github.com/nikic/iter/issues", + "source": "https://github.com/nikic/iter/tree/v2.3.0" + }, + "time": "2023-07-25T19:55:40+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.17.1", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.9-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" + }, + "time": "2023-08-13T19:53:39+00:00" + }, + { + "name": "nunomaduro/collision", + "version": "v7.8.1", + "source": { + "type": "git", + "url": "https://github.com/nunomaduro/collision.git", + "reference": "61553ad3260845d7e3e49121b7074619233d361b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/61553ad3260845d7e3e49121b7074619233d361b", + "reference": "61553ad3260845d7e3e49121b7074619233d361b", + "shasum": "" + }, + "require": { + "filp/whoops": "^2.15.3", + "nunomaduro/termwind": "^1.15.1", + "php": "^8.1.0", + "symfony/console": "^6.3.2" + }, + "require-dev": { + "brianium/paratest": "^7.2.4", + "laravel/framework": "^10.17.1", + "laravel/pint": "^1.10.5", + "laravel/sail": "^1.23.1", + "laravel/sanctum": "^3.2.5", + "laravel/tinker": "^2.8.1", + "nunomaduro/larastan": "^2.6.4", + "orchestra/testbench-core": "^8.5.9", + "pestphp/pest": "^2.12.1", + "phpunit/phpunit": "^10.3.1", + "sebastian/environment": "^6.0.1", + "spatie/laravel-ignition": "^2.2.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "./src/Adapters/Phpunit/Autoload.php" + ], + "psr-4": { + "NunoMaduro\\Collision\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Cli error handling for console/command-line PHP applications.", + "keywords": [ + "artisan", + "cli", + "command-line", + "console", + "error", + "handling", + "laravel", + "laravel-zero", + "php", + "symfony" + ], + "support": { + "issues": "https://github.com/nunomaduro/collision/issues", + "source": "https://github.com/nunomaduro/collision" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2023-08-07T08:03:21+00:00" + }, + { + "name": "nunomaduro/termwind", + "version": "v1.15.1", + "source": { + "type": "git", + "url": "https://github.com/nunomaduro/termwind.git", + "reference": "8ab0b32c8caa4a2e09700ea32925441385e4a5dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/8ab0b32c8caa4a2e09700ea32925441385e4a5dc", + "reference": "8ab0b32c8caa4a2e09700ea32925441385e4a5dc", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^8.0", + "symfony/console": "^5.3.0|^6.0.0" + }, + "require-dev": { + "ergebnis/phpstan-rules": "^1.0.", + "illuminate/console": "^8.0|^9.0", + "illuminate/support": "^8.0|^9.0", + "laravel/pint": "^1.0.0", + "pestphp/pest": "^1.21.0", + "pestphp/pest-plugin-mock": "^1.0", + "phpstan/phpstan": "^1.4.6", + "phpstan/phpstan-strict-rules": "^1.1.0", + "symfony/var-dumper": "^5.2.7|^6.0.0", + "thecodingmachine/phpstan-strict-rules": "^1.0.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Termwind\\Laravel\\TermwindServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "src/Functions.php" + ], + "psr-4": { + "Termwind\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Its like Tailwind CSS, but for the console.", + "keywords": [ + "cli", + "console", + "css", + "package", + "php", + "style" + ], + "support": { + "issues": "https://github.com/nunomaduro/termwind/issues", + "source": "https://github.com/nunomaduro/termwind/tree/v1.15.1" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://github.com/xiCO2k", + "type": "github" + } + ], + "time": "2023-02-08T01:06:31+00:00" + }, + { + "name": "paragonie/constant_time_encoding", + "version": "v2.6.3", + "source": { + "type": "git", + "url": "https://github.com/paragonie/constant_time_encoding.git", + "reference": "58c3f47f650c94ec05a151692652a868995d2938" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/58c3f47f650c94ec05a151692652a868995d2938", + "reference": "58c3f47f650c94ec05a151692652a868995d2938", + "shasum": "" + }, + "require": { + "php": "^7|^8" + }, + "require-dev": { + "phpunit/phpunit": "^6|^7|^8|^9", + "vimeo/psalm": "^1|^2|^3|^4" + }, + "type": "library", + "autoload": { + "psr-4": { + "ParagonIE\\ConstantTime\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com", + "role": "Maintainer" + }, + { + "name": "Steve 'Sc00bz' Thomas", + "email": "steve@tobtu.com", + "homepage": "https://www.tobtu.com", + "role": "Original Developer" + } + ], + "description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)", + "keywords": [ + "base16", + "base32", + "base32_decode", + "base32_encode", + "base64", + "base64_decode", + "base64_encode", + "bin2hex", + "encoding", + "hex", + "hex2bin", + "rfc4648" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/constant_time_encoding/issues", + "source": "https://github.com/paragonie/constant_time_encoding" + }, + "time": "2022-06-14T06:56:20+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, + "time": "2021-07-20T11:28:43+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "5.3.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", + "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" + }, + "require-dev": { + "mockery/mockery": "~1.3.2", + "psalm/phar": "^4.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + }, + "time": "2021-10-19T17:43:47+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.7.3", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.0", + "php": "^7.4 || ^8.0", + "phpdocumentor/reflection-common": "^2.0", + "phpstan/phpdoc-parser": "^1.13" + }, + "require-dev": { + "ext-tokenizer": "*", + "phpbench/phpbench": "^1.2", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^9.5", + "rector/rector": "^0.13.9", + "vimeo/psalm": "^4.25" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.3" + }, + "time": "2023-08-12T11:01:26+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "1.24.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6", + "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^4.15", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.5", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0" + }, + "time": "2023-09-07T20:46:32+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.10.34", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "7f806b6f1403e6914c778140e2ba07c293cb4901" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7f806b6f1403e6914c778140e2ba07c293cb4901", + "reference": "7f806b6f1403e6914c778140e2ba07c293cb4901", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2023-09-13T09:49:47+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "10.1.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "1df504e42a88044c27a90136910f0b3fe9e91939" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1df504e42a88044c27a90136910f0b3fe9e91939", + "reference": "1df504e42a88044c27a90136910f0b3fe9e91939", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.15", + "php": ">=8.1", + "phpunit/php-file-iterator": "^4.0", + "phpunit/php-text-template": "^3.0", + "sebastian/code-unit-reverse-lookup": "^3.0", + "sebastian/complexity": "^3.0", + "sebastian/environment": "^6.0", + "sebastian/lines-of-code": "^2.0", + "sebastian/version": "^4.0", + "theseer/tokenizer": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.1" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "10.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-09-12T14:37:22+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "4.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c", + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-08-31T06:24:48+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^10.0" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:56:09+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-08-31T14:07:24+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "6.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:57:52+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "10.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "b8d59476f19115c9774b3b447f78131781c6c32b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b8d59476f19115c9774b3b447f78131781c6c32b", + "reference": "b8d59476f19115c9774b3b447f78131781c6c32b", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", + "php": ">=8.1", + "phpunit/php-code-coverage": "^10.1.5", + "phpunit/php-file-iterator": "^4.0", + "phpunit/php-invoker": "^4.0", + "phpunit/php-text-template": "^3.0", + "phpunit/php-timer": "^6.0", + "sebastian/cli-parser": "^2.0", + "sebastian/code-unit": "^2.0", + "sebastian/comparator": "^5.0", + "sebastian/diff": "^5.0", + "sebastian/environment": "^6.0", + "sebastian/exporter": "^5.0", + "sebastian/global-state": "^6.0.1", + "sebastian/object-enumerator": "^5.0", + "sebastian/recursion-context": "^5.0", + "sebastian/type": "^4.0", + "sebastian/version": "^4.0" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "10.3-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.4" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2023-09-12T14:42:28+00:00" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/efdc130dbbbb8ef0b545a994fd811725c5282cae", + "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:58:15+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503", + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:58:43+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:59:15+00:00" + }, + { + "name": "sebastian/comparator", + "version": "5.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "2db5010a484d53ebf536087a70b4a5423c102372" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2db5010a484d53ebf536087a70b4a5423c102372", + "reference": "2db5010a484d53ebf536087a70b4a5423c102372", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/diff": "^5.0", + "sebastian/exporter": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "security": "https://github.com/sebastianbergmann/comparator/security/policy", + "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-08-14T13:18:12+00:00" + }, + { + "name": "sebastian/complexity", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "c70b73893e10757af9c6a48929fa6a333b56a97a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/c70b73893e10757af9c6a48929fa6a333b56a97a", + "reference": "c70b73893e10757af9c6a48929fa6a333b56a97a", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.10", + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "security": "https://github.com/sebastianbergmann/complexity/security/policy", + "source": "https://github.com/sebastianbergmann/complexity/tree/3.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-08-31T09:55:53+00:00" + }, + { + "name": "sebastian/diff", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b", + "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "security": "https://github.com/sebastianbergmann/diff/security/policy", + "source": "https://github.com/sebastianbergmann/diff/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-05-01T07:48:21+00:00" + }, + { + "name": "sebastian/environment", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/43c751b41d74f96cbbd4e07b7aec9675651e2951", + "reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "https://github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "security": "https://github.com/sebastianbergmann/environment/security/policy", + "source": "https://github.com/sebastianbergmann/environment/tree/6.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-04-11T05:39:26+00:00" + }, + { + "name": "sebastian/exporter", + "version": "5.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "32ff03d078fed1279c4ec9a407d08c5e9febb480" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/32ff03d078fed1279c4ec9a407d08c5e9febb480", + "reference": "32ff03d078fed1279c4ec9a407d08c5e9febb480", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "security": "https://github.com/sebastianbergmann/exporter/security/policy", + "source": "https://github.com/sebastianbergmann/exporter/tree/5.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-09-08T04:46:58+00:00" + }, + { + "name": "sebastian/global-state", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/7ea9ead78f6d380d2a667864c132c2f7b83055e4", + "reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "security": "https://github.com/sebastianbergmann/global-state/security/policy", + "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-07-19T07:19:23+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/649e40d279e243d985aa8fb6e74dd5bb28dc185d", + "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.10", + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-08-31T09:25:50+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "5.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906", + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T07:08:32+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957", + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T07:06:18+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "5.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "05909fb5bc7df4c52992396d0116aed689f93712" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/05909fb5bc7df4c52992396d0116aed689f93712", + "reference": "05909fb5bc7df4c52992396d0116aed689f93712", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T07:05:40+00:00" + }, + { + "name": "sebastian/type", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf", + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T07:10:45+00:00" + }, + { + "name": "sebastian/version", + "version": "4.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/4.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-07T11:34:05+00:00" + }, + { + "name": "sebastianfeldmann/camino", + "version": "0.9.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianfeldmann/camino.git", + "reference": "bf2e4c8b2a029e9eade43666132b61331e3e8184" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianfeldmann/camino/zipball/bf2e4c8b2a029e9eade43666132b61331e3e8184", + "reference": "bf2e4c8b2a029e9eade43666132b61331e3e8184", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "SebastianFeldmann\\Camino\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian Feldmann", + "email": "sf@sebastian-feldmann.info" + } + ], + "description": "Path management the OO way", + "homepage": "https://github.com/sebastianfeldmann/camino", + "keywords": [ + "file system", + "path" + ], + "support": { + "issues": "https://github.com/sebastianfeldmann/camino/issues", + "source": "https://github.com/sebastianfeldmann/camino/tree/0.9.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianfeldmann", + "type": "github" + } + ], + "time": "2022-01-03T13:15:10+00:00" + }, + { + "name": "sebastianfeldmann/cli", + "version": "3.4.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianfeldmann/cli.git", + "reference": "8a932e99e9455981fb32fa6c085492462fe8f8cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianfeldmann/cli/zipball/8a932e99e9455981fb32fa6c085492462fe8f8cf", + "reference": "8a932e99e9455981fb32fa6c085492462fe8f8cf", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "require-dev": { + "symfony/process": "^4.3 | ^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4.x-dev" + } + }, + "autoload": { + "psr-4": { + "SebastianFeldmann\\Cli\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian Feldmann", + "email": "sf@sebastian-feldmann.info" + } + ], + "description": "PHP cli helper classes", + "homepage": "https://github.com/sebastianfeldmann/cli", + "keywords": [ + "cli" + ], + "support": { + "issues": "https://github.com/sebastianfeldmann/cli/issues", + "source": "https://github.com/sebastianfeldmann/cli/tree/3.4.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianfeldmann", + "type": "github" + } + ], + "time": "2021-12-20T14:59:49+00:00" + }, + { + "name": "sebastianfeldmann/git", + "version": "3.8.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianfeldmann/git.git", + "reference": "38586be69b0932b630337afcc8db12e5b7981254" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianfeldmann/git/zipball/38586be69b0932b630337afcc8db12e5b7981254", + "reference": "38586be69b0932b630337afcc8db12e5b7981254", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-xml": "*", + "php": ">=7.2", + "sebastianfeldmann/cli": "^3.0" + }, + "require-dev": { + "mikey179/vfsstream": "^1.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "SebastianFeldmann\\Git\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian Feldmann", + "email": "sf@sebastian-feldmann.info" + } + ], + "description": "PHP git wrapper", + "homepage": "https://github.com/sebastianfeldmann/git", + "keywords": [ + "git" + ], + "support": { + "issues": "https://github.com/sebastianfeldmann/git/issues", + "source": "https://github.com/sebastianfeldmann/git/tree/3.8.9" + }, + "funding": [ + { + "url": "https://github.com/sebastianfeldmann", + "type": "github" + } + ], + "time": "2023-03-30T16:37:34+00:00" + }, + { + "name": "seld/jsonlint", + "version": "1.10.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/jsonlint.git", + "reference": "594fd6462aad8ecee0b45ca5045acea4776667f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/594fd6462aad8ecee0b45ca5045acea4776667f1", + "reference": "594fd6462aad8ecee0b45ca5045acea4776667f1", + "shasum": "" + }, + "require": { + "php": "^5.3 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.5", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^8.5.13" + }, + "bin": [ + "bin/jsonlint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Seld\\JsonLint\\": "src/Seld/JsonLint/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "JSON Linter", + "keywords": [ + "json", + "linter", + "parser", + "validator" + ], + "support": { + "issues": "https://github.com/Seldaek/jsonlint/issues", + "source": "https://github.com/Seldaek/jsonlint/tree/1.10.0" + }, + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/seld/jsonlint", + "type": "tidelift" + } + ], + "time": "2023-05-11T13:16:46+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v6.3.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/adb01fe097a4ee930db9258a3cc906b5beb5cf2e", + "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/event-dispatcher-contracts": "^2.5|^3" + }, + "conflict": { + "symfony/dependency-injection": "<5.4", + "symfony/service-contracts": "<2.5" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/error-handler": "^5.4|^6.0", + "symfony/expression-language": "^5.4|^6.0", + "symfony/http-foundation": "^5.4|^6.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/stopwatch": "^5.4|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v6.3.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-07-06T06:56:43+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v3.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "a76aed96a42d2b521153fb382d418e30d18b59df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/a76aed96a42d2b521153fb382d418e30d18b59df", + "reference": "a76aed96a42d2b521153fb382d418e30d18b59df", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/event-dispatcher": "^1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-23T14:45:45+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v6.3.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v6.3.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-06-01T08:30:39+00:00" + }, + { + "name": "symfony/finder", + "version": "v6.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/9915db259f67d21eefee768c1abcf1cc61b1fc9e", + "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "symfony/filesystem": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v6.3.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-07-31T08:31:44+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/a10f19f5198d589d5c33333cffe98dc9820332dd", + "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v6.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-12T14:21:09+00:00" + }, + { + "name": "symfony/process", + "version": "v6.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/0b5c29118f2e980d455d2e34a5659f4579847c54", + "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v6.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-08-07T10:39:22+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2", + "reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/service-contracts": "^2.5|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v6.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-02-16T10:14:28+00:00" + }, + { + "name": "symfony/var-dumper", + "version": "v6.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-dumper.git", + "reference": "2027be14f8ae8eae999ceadebcda5b4909b81d45" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/2027be14f8ae8eae999ceadebcda5b4909b81d45", + "reference": "2027be14f8ae8eae999ceadebcda5b4909b81d45", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/console": "<5.4" + }, + "require-dev": { + "ext-iconv": "*", + "symfony/console": "^5.4|^6.0", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0", + "symfony/uid": "^5.4|^6.0", + "twig/twig": "^2.13|^3.0.4" + }, + "bin": [ + "Resources/bin/var-dump-server" + ], + "type": "library", + "autoload": { + "files": [ + "Resources/functions/dump.php" + ], + "psr-4": { + "Symfony\\Component\\VarDumper\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides mechanisms for walking through any arbitrary PHP variable", + "homepage": "https://symfony.com", + "keywords": [ + "debug", + "dump" + ], + "support": { + "source": "https://github.com/symfony/var-dumper/tree/v6.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-08-24T14:51:05+00:00" + }, + { + "name": "thecodingmachine/safe", + "version": "v2.5.0", + "source": { + "type": "git", + "url": "https://github.com/thecodingmachine/safe.git", + "reference": "3115ecd6b4391662b4931daac4eba6b07a2ac1f0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thecodingmachine/safe/zipball/3115ecd6b4391662b4931daac4eba6b07a2ac1f0", + "reference": "3115ecd6b4391662b4931daac4eba6b07a2ac1f0", + "shasum": "" + }, + "require": { + "php": "^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.5", + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "^3.2", + "thecodingmachine/phpstan-strict-rules": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "files": [ + "deprecated/apc.php", + "deprecated/array.php", + "deprecated/datetime.php", + "deprecated/libevent.php", + "deprecated/misc.php", + "deprecated/password.php", + "deprecated/mssql.php", + "deprecated/stats.php", + "deprecated/strings.php", + "lib/special_cases.php", + "deprecated/mysqli.php", + "generated/apache.php", + "generated/apcu.php", + "generated/array.php", + "generated/bzip2.php", + "generated/calendar.php", + "generated/classobj.php", + "generated/com.php", + "generated/cubrid.php", + "generated/curl.php", + "generated/datetime.php", + "generated/dir.php", + "generated/eio.php", + "generated/errorfunc.php", + "generated/exec.php", + "generated/fileinfo.php", + "generated/filesystem.php", + "generated/filter.php", + "generated/fpm.php", + "generated/ftp.php", + "generated/funchand.php", + "generated/gettext.php", + "generated/gmp.php", + "generated/gnupg.php", + "generated/hash.php", + "generated/ibase.php", + "generated/ibmDb2.php", + "generated/iconv.php", + "generated/image.php", + "generated/imap.php", + "generated/info.php", + "generated/inotify.php", + "generated/json.php", + "generated/ldap.php", + "generated/libxml.php", + "generated/lzf.php", + "generated/mailparse.php", + "generated/mbstring.php", + "generated/misc.php", + "generated/mysql.php", + "generated/network.php", + "generated/oci8.php", + "generated/opcache.php", + "generated/openssl.php", + "generated/outcontrol.php", + "generated/pcntl.php", + "generated/pcre.php", + "generated/pgsql.php", + "generated/posix.php", + "generated/ps.php", + "generated/pspell.php", + "generated/readline.php", + "generated/rpminfo.php", + "generated/rrd.php", + "generated/sem.php", + "generated/session.php", + "generated/shmop.php", + "generated/sockets.php", + "generated/sodium.php", + "generated/solr.php", + "generated/spl.php", + "generated/sqlsrv.php", + "generated/ssdeep.php", + "generated/ssh2.php", + "generated/stream.php", + "generated/strings.php", + "generated/swoole.php", + "generated/uodbc.php", + "generated/uopz.php", + "generated/url.php", + "generated/var.php", + "generated/xdiff.php", + "generated/xml.php", + "generated/xmlrpc.php", + "generated/yaml.php", + "generated/yaz.php", + "generated/zip.php", + "generated/zlib.php" + ], + "classmap": [ + "lib/DateTime.php", + "lib/DateTimeImmutable.php", + "lib/Exceptions/", + "deprecated/Exceptions/", + "generated/Exceptions/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHP core functions that throw exceptions instead of returning FALSE on error", + "support": { + "issues": "https://github.com/thecodingmachine/safe/issues", + "source": "https://github.com/thecodingmachine/safe/tree/v2.5.0" + }, + "time": "2023-04-05T11:54:14+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2021-07-28T10:34:58+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.11.0", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "php": "^7.2 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<4.6.1 || 4.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.11.0" + }, + "time": "2022-06-03T18:03:27+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">= 8.1", + "ext-mbstring": "*", + "ext-pcntl": "*" + }, + "platform-dev": [], + "plugin-api-version": "2.6.0" +} From 7b6a1b4212549323fd4bba1151391938fc3d2e81 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Thu, 14 Sep 2023 11:15:53 +0200 Subject: [PATCH 176/296] Simplify adding composer in `bin/spc-alpine-docker` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kévin Dunglas --- bin/spc-alpine-docker | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index a5cb31cc..e51b020b 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -94,8 +94,7 @@ RUN apk update; \ WORKDIR /app ADD ./src /app/src -ADD ./composer.json /app/composer.json -ADD ./composer.lock /app/composer.lock +COPY ./composer.* /app/ ADD ./bin /app/bin RUN composer install --no-dev --classmap-authoritative EOF From 49149cebf1d4e42a66ce3461bc98646e0d651d6b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 13 Sep 2023 23:39:52 +0800 Subject: [PATCH 177/296] Add new GH action to build binary SPC --- .github/workflows/release-build.yml | 96 +++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/release-build.yml diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml new file mode 100644 index 00000000..59c7fab9 --- /dev/null +++ b/.github/workflows/release-build.yml @@ -0,0 +1,96 @@ +name: Build Release Artifacts + +on: + release: + types: + - published + workflow_dispatch: + +jobs: + build-release-artifacts: + name: "Build Release Artifacts" + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + php-version: + - "8.1" + operating-system: + - "ubuntu-latest" + - "macos-latest" + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: none + tools: composer:v2 + php-version: "${{ matrix.php-version }}" + ini-values: memory_limit=-1 + + - name: "Get Composer Cache Directory" + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: "Cache Composer dependencies" + uses: "actions/cache@v3" + with: + path: "${{ steps.composer-cache.outputs.dir }}" + key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}" + restore-keys: | + php-${{ matrix.php-version }}-locked-composer- + - name: "Install locked dependencies" + run: "composer install --no-interaction --no-progress" + + # Cache downloaded source + - id: cache-download + uses: actions/cache@v3 + with: + path: downloads + key: php-${{ matrix.php-version }}-dependencies + + # If there's no dependencies cache, fetch sources + - if: steps.cache-download.outputs.cache-hit != 'true' + name: "Download sources" + run: bin/spc download --with-php=${{ matrix.php-version }} --all + + - name: "Build phpmicro" + run: | + SPC_USE_SUDO=yes bin/spc doctor --auto-fix + bin/spc build pcntl,posix,mbstring,tokenizer,phar --build-micro --debug + + - name: "Build PHAR file" + run: "composer build:phar" + + - name: "Generate Executable" + run: "bin/spc micro:combine spc.phar -O spc" + + - name: "Archive Executable" + run: | + OS="" + if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then + OS="linux-x86_64" + elif [ "${{ matrix.operating-system }}" = "macos-latest" ]; then + OS="macos-x86_64" + fi + tar -czf spc-$OS.tar.gz spc + echo "filename=spc-$OS.tar.gz" >> $GITHUB_ENV + echo "OS=$OS" >> $GITHUB_ENV + + - name: "Test Micro file" + run: "./spc dev:extensions" + + - name: upload binaries to release + uses: softprops/action-gh-release@v1 + if: ${{startsWith(github.ref, 'refs/tags/') }} + with: + files: ${{ env.filename }} + + - name: "Upload Artifact" + uses: actions/upload-artifact@v3 + with: + path: spc + name: spc-${{ env.OS }} From fe6a98b30ded05c73c60d26425a34d86c5729d58 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 15 Sep 2023 19:01:48 +0800 Subject: [PATCH 178/296] remove debug option --- .github/workflows/release-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 59c7fab9..21b4e286 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -60,7 +60,7 @@ jobs: - name: "Build phpmicro" run: | SPC_USE_SUDO=yes bin/spc doctor --auto-fix - bin/spc build pcntl,posix,mbstring,tokenizer,phar --build-micro --debug + bin/spc build pcntl,posix,mbstring,tokenizer,phar --build-micro - name: "Build PHAR file" run: "composer build:phar" From 824748c2a7604db0513877908b972bf69d1ac4a7 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 15 Sep 2023 19:06:41 +0800 Subject: [PATCH 179/296] remove download cache and minimize download sources --- .github/workflows/release-build.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 21b4e286..77c7c728 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -45,17 +45,8 @@ jobs: - name: "Install locked dependencies" run: "composer install --no-interaction --no-progress" - # Cache downloaded source - - id: cache-download - uses: actions/cache@v3 - with: - path: downloads - key: php-${{ matrix.php-version }}-dependencies - - # If there's no dependencies cache, fetch sources - - if: steps.cache-download.outputs.cache-hit != 'true' - name: "Download sources" - run: bin/spc download --with-php=${{ matrix.php-version }} --all + - name: "Download sources" + run: bin/spc download --with-php=${{ matrix.php-version }} php-src,micro,pkg-config,onig,zlib - name: "Build phpmicro" run: | From 4e99211bc37ae37aae6ee7918fc7669be505bc9a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 15 Sep 2023 23:24:40 +0800 Subject: [PATCH 180/296] add hardcoded-ini option for embed SAPI --- src/SPC/ConsoleApplication.php | 2 +- src/SPC/store/SourcePatcher.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index b3e1de8b..16f4442e 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.0-rc6'; + public const VERSION = '2.0.0'; public function __construct() { diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 970f22c0..7fbfb1b5 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -158,6 +158,8 @@ class SourcePatcher $cli_c_bak = SOURCE_PATH . '/php-src/sapi/cli/php_cli.c.bak'; $micro_c = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c'; $micro_c_bak = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c.bak'; + $embed_c = SOURCE_PATH . '/php-src/sapi/embed/php_embed.c'; + $embed_c_bak = SOURCE_PATH . '/php-src/sapi/embed/php_embed.c.bak'; // Try to reverse backup file $find_str = 'const char HARDCODED_INI[] ='; @@ -168,13 +170,14 @@ class SourcePatcher $patch_str = "const char HARDCODED_INI[] =\n{$patch_str}"; // Detect backup, if we have backup, it means we need to reverse first - if (file_exists($cli_c_bak) || file_exists($micro_c_bak)) { + if (file_exists($cli_c_bak) || file_exists($micro_c_bak) || file_exists($embed_c_bak)) { self::unpatchHardcodedINI(); } // Backup it $result = file_put_contents($cli_c_bak, file_get_contents($cli_c)); $result = $result && file_put_contents($micro_c_bak, file_get_contents($micro_c)); + $result = $result && file_put_contents($embed_c_bak, file_get_contents($embed_c)); if ($result === false) { return false; } @@ -182,6 +185,7 @@ class SourcePatcher // Patch it FileSystem::replaceFileStr($cli_c, $find_str, $patch_str); FileSystem::replaceFileStr($micro_c, $find_str, $patch_str); + FileSystem::replaceFileStr($embed_c, $find_str, $patch_str); return true; } @@ -191,13 +195,17 @@ class SourcePatcher $cli_c_bak = SOURCE_PATH . '/php-src/sapi/cli/php_cli.c.bak'; $micro_c = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c'; $micro_c_bak = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c.bak'; - if (!file_exists($cli_c_bak) && !file_exists($micro_c_bak)) { + $embed_c = SOURCE_PATH . '/php-src/sapi/embed/php_embed.c'; + $embed_c_bak = SOURCE_PATH . '/php-src/sapi/embed/php_embed.c.bak'; + if (!file_exists($cli_c_bak) && !file_exists($micro_c_bak) && !file_exists($embed_c_bak)) { return false; } $result = file_put_contents($cli_c, file_get_contents($cli_c_bak)); $result = $result && file_put_contents($micro_c, file_get_contents($micro_c_bak)); + $result = $result && file_put_contents($embed_c, file_get_contents($embed_c_bak)); @unlink($cli_c_bak); @unlink($micro_c_bak); + @unlink($embed_c_bak); return $result; } } From 6ed974973239b68d982a182c62137c91342eca37 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 23 Sep 2023 17:02:56 +0800 Subject: [PATCH 181/296] cs fix and composer update --- composer.lock | 134 ++++++++++++++-------------- src/SPC/command/BuildCliCommand.php | 10 +-- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/composer.lock b/composer.lock index 95f2b21b..604913f1 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "illuminate/collections", - "version": "v10.23.1", + "version": "v10.24.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "72c3cc6d44416db499d2ad11b8b27ae22e60a661" + "reference": "939a975daa8a5f77974ffa6a24067f5e947683f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/72c3cc6d44416db499d2ad11b8b27ae22e60a661", - "reference": "72c3cc6d44416db499d2ad11b8b27ae22e60a661", + "url": "https://api.github.com/repos/illuminate/collections/zipball/939a975daa8a5f77974ffa6a24067f5e947683f4", + "reference": "939a975daa8a5f77974ffa6a24067f5e947683f4", "shasum": "" }, "require": { @@ -59,11 +59,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-09-07T14:13:46+00:00" + "time": "2023-09-18T18:32:31+00:00" }, { "name": "illuminate/conditionable", - "version": "v10.23.1", + "version": "v10.24.0", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -109,7 +109,7 @@ }, { "name": "illuminate/contracts", - "version": "v10.23.1", + "version": "v10.24.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -157,7 +157,7 @@ }, { "name": "illuminate/macroable", - "version": "v10.23.1", + "version": "v10.24.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -203,16 +203,16 @@ }, { "name": "laravel/prompts", - "version": "v0.1.7", + "version": "v0.1.8", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "554e7d855a22e87942753d68e23b327ad79b2070" + "reference": "68dcc65babf92e1fb43cba0b3f78fc3d8002709c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/554e7d855a22e87942753d68e23b327ad79b2070", - "reference": "554e7d855a22e87942753d68e23b327ad79b2070", + "url": "https://api.github.com/repos/laravel/prompts/zipball/68dcc65babf92e1fb43cba0b3f78fc3d8002709c", + "reference": "68dcc65babf92e1fb43cba0b3f78fc3d8002709c", "shasum": "" }, "require": { @@ -245,9 +245,9 @@ ], "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.7" + "source": "https://github.com/laravel/prompts/tree/v0.1.8" }, - "time": "2023-09-12T11:09:22+00:00" + "time": "2023-09-19T15:33:56+00:00" }, { "name": "psr/container", @@ -2240,16 +2240,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.26.1", + "version": "v3.28.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "d023ba6684055f6ea1da1352d8a02baca0426983" + "reference": "113e09fea3d2306319ffaa2423fe3de768b28cff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/d023ba6684055f6ea1da1352d8a02baca0426983", - "reference": "d023ba6684055f6ea1da1352d8a02baca0426983", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/113e09fea3d2306319ffaa2423fe3de768b28cff", + "reference": "113e09fea3d2306319ffaa2423fe3de768b28cff", "shasum": "" }, "require": { @@ -2323,7 +2323,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.26.1" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.28.0" }, "funding": [ { @@ -2331,7 +2331,7 @@ "type": "github" } ], - "time": "2023-09-08T19:09:07+00:00" + "time": "2023-09-22T20:43:40+00:00" }, { "name": "humbug/box", @@ -2872,37 +2872,37 @@ }, { "name": "nunomaduro/collision", - "version": "v7.8.1", + "version": "v7.9.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "61553ad3260845d7e3e49121b7074619233d361b" + "reference": "296d0cf9fe462837ac0da8a568b56fc026b132da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/61553ad3260845d7e3e49121b7074619233d361b", - "reference": "61553ad3260845d7e3e49121b7074619233d361b", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/296d0cf9fe462837ac0da8a568b56fc026b132da", + "reference": "296d0cf9fe462837ac0da8a568b56fc026b132da", "shasum": "" }, "require": { "filp/whoops": "^2.15.3", "nunomaduro/termwind": "^1.15.1", "php": "^8.1.0", - "symfony/console": "^6.3.2" + "symfony/console": "^6.3.4" }, "require-dev": { - "brianium/paratest": "^7.2.4", - "laravel/framework": "^10.17.1", - "laravel/pint": "^1.10.5", - "laravel/sail": "^1.23.1", - "laravel/sanctum": "^3.2.5", - "laravel/tinker": "^2.8.1", + "brianium/paratest": "^7.2.7", + "laravel/framework": "^10.23.1", + "laravel/pint": "^1.13.1", + "laravel/sail": "^1.25.0", + "laravel/sanctum": "^3.3.1", + "laravel/tinker": "^2.8.2", "nunomaduro/larastan": "^2.6.4", - "orchestra/testbench-core": "^8.5.9", - "pestphp/pest": "^2.12.1", - "phpunit/phpunit": "^10.3.1", + "orchestra/testbench-core": "^8.11.0", + "pestphp/pest": "^2.19.1", + "phpunit/phpunit": "^10.3.5", "sebastian/environment": "^6.0.1", - "spatie/laravel-ignition": "^2.2.0" + "spatie/laravel-ignition": "^2.3.0" }, "type": "library", "extra": { @@ -2961,7 +2961,7 @@ "type": "patreon" } ], - "time": "2023-08-07T08:03:21+00:00" + "time": "2023-09-19T10:45:09+00:00" }, { "name": "nunomaduro/termwind", @@ -3397,16 +3397,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.0", + "version": "1.24.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6" + "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01", + "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01", "shasum": "" }, "require": { @@ -3438,22 +3438,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.1" }, - "time": "2023-09-07T20:46:32+00:00" + "time": "2023-09-18T12:18:02+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.34", + "version": "1.10.35", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "7f806b6f1403e6914c778140e2ba07c293cb4901" + "reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7f806b6f1403e6914c778140e2ba07c293cb4901", - "reference": "7f806b6f1403e6914c778140e2ba07c293cb4901", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e730e5facb75ffe09dfb229795e8c01a459f26c3", + "reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3", "shasum": "" }, "require": { @@ -3502,20 +3502,20 @@ "type": "tidelift" } ], - "time": "2023-09-13T09:49:47+00:00" + "time": "2023-09-19T15:27:56+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "10.1.5", + "version": "10.1.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "1df504e42a88044c27a90136910f0b3fe9e91939" + "reference": "56f33548fe522c8d82da7ff3824b42829d324364" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1df504e42a88044c27a90136910f0b3fe9e91939", - "reference": "1df504e42a88044c27a90136910f0b3fe9e91939", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/56f33548fe522c8d82da7ff3824b42829d324364", + "reference": "56f33548fe522c8d82da7ff3824b42829d324364", "shasum": "" }, "require": { @@ -3572,7 +3572,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.5" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.6" }, "funding": [ { @@ -3580,7 +3580,7 @@ "type": "github" } ], - "time": "2023-09-12T14:37:22+00:00" + "time": "2023-09-19T04:59:03+00:00" }, { "name": "phpunit/php-file-iterator", @@ -3827,16 +3827,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.3.4", + "version": "10.3.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "b8d59476f19115c9774b3b447f78131781c6c32b" + "reference": "747c3b2038f1139e3dcd9886a3f5a948648b7503" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b8d59476f19115c9774b3b447f78131781c6c32b", - "reference": "b8d59476f19115c9774b3b447f78131781c6c32b", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/747c3b2038f1139e3dcd9886a3f5a948648b7503", + "reference": "747c3b2038f1139e3dcd9886a3f5a948648b7503", "shasum": "" }, "require": { @@ -3860,7 +3860,7 @@ "sebastian/comparator": "^5.0", "sebastian/diff": "^5.0", "sebastian/environment": "^6.0", - "sebastian/exporter": "^5.0", + "sebastian/exporter": "^5.1", "sebastian/global-state": "^6.0.1", "sebastian/object-enumerator": "^5.0", "sebastian/recursion-context": "^5.0", @@ -3908,7 +3908,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.4" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.5" }, "funding": [ { @@ -3924,7 +3924,7 @@ "type": "tidelift" } ], - "time": "2023-09-12T14:42:28+00:00" + "time": "2023-09-19T05:42:37+00:00" }, { "name": "psr/event-dispatcher", @@ -4411,16 +4411,16 @@ }, { "name": "sebastian/exporter", - "version": "5.0.1", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "32ff03d078fed1279c4ec9a407d08c5e9febb480" + "reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/32ff03d078fed1279c4ec9a407d08c5e9febb480", - "reference": "32ff03d078fed1279c4ec9a407d08c5e9febb480", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c3fa8483f9539b190f7cd4bfc4a07631dd1df344", + "reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344", "shasum": "" }, "require": { @@ -4477,7 +4477,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", "security": "https://github.com/sebastianbergmann/exporter/security/policy", - "source": "https://github.com/sebastianbergmann/exporter/tree/5.0.1" + "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.0" }, "funding": [ { @@ -4485,7 +4485,7 @@ "type": "github" } ], - "time": "2023-09-08T04:46:58+00:00" + "time": "2023-09-18T07:15:37+00:00" }, { "name": "sebastian/global-state", @@ -5946,5 +5946,5 @@ "ext-pcntl": "*" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.2.0" } diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index ee461793..00be7559 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -41,11 +41,11 @@ class BuildCliCommand extends BuildCommand $extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions')))); $rule = BUILD_TARGET_NONE; - $rule = $rule | ($this->getOption('build-cli') ? BUILD_TARGET_CLI : BUILD_TARGET_NONE); - $rule = $rule | ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE); - $rule = $rule | ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE); - $rule = $rule | ($this->getOption('build-embed') ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE); - $rule = $rule | ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); + $rule |= ($this->getOption('build-cli') ? BUILD_TARGET_CLI : BUILD_TARGET_NONE); + $rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE); + $rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE); + $rule |= ($this->getOption('build-embed') ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE); + $rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); if ($rule === BUILD_TARGET_NONE) { $this->output->writeln('Please add at least one build target!'); $this->output->writeln("\t--build-cli\tBuild php-cli SAPI"); From db8aa15677194d1bd577d9bc83332e0a483e21b7 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 23 Sep 2023 17:00:42 +0800 Subject: [PATCH 182/296] adjust micro's phar patch execution location --- src/SPC/builder/linux/LinuxBuilder.php | 8 ++++---- src/SPC/builder/macos/MacOSBuilder.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 7859139e..1c8f207f 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -229,10 +229,6 @@ class LinuxBuilder extends BuilderBase if (php_uname('m') === $this->getOption('arch')) { $this->sanityCheck($build_target); } - - if ($this->phar_patched) { - SourcePatcher::patchMicro(['phar'], true); - } } /** @@ -290,6 +286,10 @@ class LinuxBuilder extends BuilderBase } $this->deployBinary(BUILD_TARGET_MICRO); + + if ($this->phar_patched) { + SourcePatcher::patchMicro(['phar'], true); + } } /** diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index d179a1bc..bbf4a791 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -201,10 +201,6 @@ class MacOSBuilder extends BuilderBase if (php_uname('m') === $this->getOption('arch')) { $this->sanityCheck($build_target); } - - if ($this->phar_patched) { - SourcePatcher::patchMicro(['phar'], true); - } } /** @@ -258,6 +254,10 @@ class MacOSBuilder extends BuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec("make -j{$this->concurrency} {$vars} micro"); $this->deployBinary(BUILD_TARGET_MICRO); + + if ($this->phar_patched) { + SourcePatcher::patchMicro(['phar'], true); + } } /** From 87e073a0b9a9f75499d8e298fccf82437c7513ec Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 26 Sep 2023 18:29:45 +0800 Subject: [PATCH 183/296] Change domain --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 65196b1f..7e41d4e3 100755 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Build single static PHP binary, with PHP project together, with popular extensio ## 文档 -点击这里查看文档:。 +点击这里查看文档:。 ## 使用 @@ -54,7 +54,7 @@ Build single static PHP binary, with PHP project together, with popular extensio ### 支持的扩展情况 -[扩展支持列表](https://static-php-cli.zhamao.me/zh/guide/extensions.html) +[扩展支持列表](https://static-php.dev/zh/guide/extensions.html) > 如果这里没有你需要的扩展,可以提交 Issue。 @@ -221,4 +221,4 @@ cat micro.sfx code.php > single-app && chmod +x single-app ## 进阶 -本项目重构分支为模块化编写。如果你对本项目感兴趣,想加入开发,可以参照文档的 [贡献指南](https://static-php-cli.zhamao.me) 贡献代码或文档。 +本项目重构分支为模块化编写。如果你对本项目感兴趣,想加入开发,可以参照文档的 [贡献指南](https://static-php.dev) 贡献代码或文档。 From 3b793005fe9e7707f47fc42c5e4bdaf3355b153f Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 26 Sep 2023 18:32:18 +0800 Subject: [PATCH 184/296] Change domain --- README-en.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README-en.md b/README-en.md index 8ed058f5..a12d1a78 100755 --- a/README-en.md +++ b/README-en.md @@ -41,7 +41,7 @@ Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1` ## Docs -docs here: . +docs here: . ## Simple Usage @@ -55,7 +55,7 @@ If you don't compile yourself, you can download pre-compiled artifact from Actio ### Supported Extensions -[Supported Extension List](https://static-php-cli.zhamao.me/en/guide/extensions.html) +[Supported Extension List](https://static-php.dev/en/guide/extensions.html) > If there is no extension you need here, you can submit an issue. @@ -254,4 +254,4 @@ and comply with the corresponding project's LICENSE. The refactoring branch of this project is written modularly. If you are interested in this project and want to join the development, -you can refer to the [Contribution Guide](https://static-php-cli.zhamao.me) of the documentation to contribute code or documentation. +you can refer to the [Contribution Guide](https://static-php.dev) of the documentation to contribute code or documentation. From cd04a9ea4fd27eb5a660a8e1599bda0df1580bb1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 26 Sep 2023 22:27:44 +0800 Subject: [PATCH 185/296] change all related url to static-php.dev --- README-en.md | 2 +- README.md | 2 +- bin/setup-runtime | 4 ++-- ext-support.md | 2 +- src/SPC/store/source/PhpSource.php | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README-en.md b/README-en.md index a12d1a78..5957ac7f 100755 --- a/README-en.md +++ b/README-en.md @@ -49,7 +49,7 @@ Please first select the extension you want to compile based on the extension lis ### Direct Download -If you don't compile yourself, you can download pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.zhamao.xin/static-php-cli/) +If you don't compile yourself, you can download pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.static-php.dev/static-php-cli/common/) > self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` diff --git a/README.md b/README.md index 7e41d4e3..8dc62561 100755 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Build single static PHP binary, with PHP project together, with popular extensio ### 自托管直接下载 -如果你不想自行编译,可以从本项目现有的 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.zhamao.xin/static-php-cli/) +如果你不想自行编译,可以从本项目现有的 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.static-php.dev/static-php-cli/common/) > 自托管的服务器默认包含的扩展有:`bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` diff --git a/bin/setup-runtime b/bin/setup-runtime index b02e3177..bd7144b7 100755 --- a/bin/setup-runtime +++ b/bin/setup-runtime @@ -25,7 +25,7 @@ __DIR__=$(cd "$(dirname "$0")" && pwd) __PROJECT__=$(cd "${__DIR__}"/../ && pwd) # set download dir -__PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.6-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" +__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.10-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" __COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar" # use china mirror @@ -46,7 +46,7 @@ done case "$mirror" in china) - __PHP_RUNTIME_URL__="https://dl.zhamao.xin/static-php-cli/php-8.2.6-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" + __PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.10-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" __COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar" ;; diff --git a/ext-support.md b/ext-support.md index 19102e5a..a7068e65 100644 --- a/ext-support.md +++ b/ext-support.md @@ -1,3 +1,3 @@ # Extension List -See: [Docs - Extensions](https://static-php-cli.zhamao.me/en/guide/extensions.html) +See: [Docs - Extensions](https://static-php.dev/en/guide/extensions.html) diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index ce7483f6..30e583a8 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -45,7 +45,6 @@ class PhpSource extends CustomSourceBase return [ 'type' => 'url', 'url' => "https://www.php.net/distributions/php-{$version}.tar.gz", - // 'url' => "https://mirrors.zhamao.xin/php/php-{$version}.tar.gz", ]; } } From ff128df76b7de0f1478275efe7f0cf3a1c710fae Mon Sep 17 00:00:00 2001 From: Rif'at Ahdi R <10791791+atrifat@users.noreply.github.com> Date: Fri, 29 Sep 2023 01:02:25 +0000 Subject: [PATCH 186/296] Update libwebp dependency (fix #208) --- config/source.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index 3c052a26..95bb0a13 100644 --- a/config/source.json +++ b/config/source.json @@ -241,7 +241,7 @@ }, "libwebp": { "type": "url", - "url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.0.tar.gz", + "url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz", "license": { "type": "file", "path": "COPYING" From 3b83c1fa7b533aaade1b4368dab0dd45ad4d4f9e Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Fri, 29 Sep 2023 18:08:29 +0200 Subject: [PATCH 187/296] Remove dead code from `ConsoleApplication` class --- src/SPC/ConsoleApplication.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 16f4442e..5ab014fa 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -29,11 +29,6 @@ final class ConsoleApplication extends Application { parent::__construct('static-php-cli', self::VERSION); - global $argv; - - // Detailed debugging errors are not displayed in the production environment. Only the error display provided by Symfony console is used. - $this->setCatchExceptions(file_exists(ROOT_DIR . '/.prod') || !in_array('--debug', $argv)); - $this->addCommands( [ new BuildCliCommand(), From dd9a5d83161a0066362acddcafe74211a03d8035 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 18 Sep 2023 12:52:12 +0200 Subject: [PATCH 188/296] add rhel and almalinux support --- src/SPC/doctor/item/LinuxMuslCheck.php | 6 ++++-- src/SPC/doctor/item/LinuxToolCheckList.php | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index 28232a9e..860a23be 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -24,7 +24,7 @@ class LinuxMuslCheck // non-exist, need to recognize distro $distro = SystemUtil::getOSRelease(); return match ($distro['dist']) { - 'ubuntu', 'alpine', 'debian' => CheckResult::fail('musl-libc is not installed on your system', 'fix-musl', [$distro]), + 'ubuntu', 'alpine', 'debian', 'rhel', 'almalinux' => CheckResult::fail('musl-libc is not installed on your system', 'fix-musl', [$distro]), default => CheckResult::fail('musl-libc is not installed on your system'), }; } @@ -39,7 +39,9 @@ class LinuxMuslCheck $install_cmd = match ($distro['dist']) { 'ubuntu', 'debian' => 'apt-get install musl musl-tools -y', 'alpine' => 'apk add musl musl-utils musl-dev', - default => throw new RuntimeException('Current linux distro is not supported for auto-install musl packages'), + 'rhel' => 'dnf install tar wget git zip bison flex bzip2 cmake patch && wget https://musl.libc.org/releases/musl-1.2.4.tar.gz && tar -zxvf musl-1.2.4.tar.gz && rm musl-1.2.4.tar.gz && cd musl-1.2.4 && ./configure && make -j && make install && cd ..', + 'almalinux' => 'dnf install bison flex bzip2 cmake patch && wget https://musl.libc.org/releases/musl-1.2.4.tar.gz && tar -zxvf musl-1.2.4.tar.gz && rm musl-1.2.4.tar.gz && cd musl-1.2.4 && ./configure && make -j && make install && export PATH="/usr/local/musl/bin:$PATH" cd ..', + default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'), }; $prefix = ''; if (get_current_user() !== 'root') { diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 557ba3df..e4d6951c 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -16,7 +16,7 @@ class LinuxToolCheckList use UnixSystemUtilTrait; public const TOOLS_ALPINE = [ - 'make', 'bison', 'flex', + 'perl', 'make', 'bison', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'gcc', @@ -24,7 +24,7 @@ class LinuxToolCheckList ]; public const TOOLS_DEBIAN = [ - 'make', 'bison', 'flex', + 'perl', 'make', 'bison', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'patch', @@ -49,7 +49,11 @@ class LinuxToolCheckList } if (!empty($missing)) { return match ($distro['dist']) { - 'ubuntu', 'alpine', 'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]), + 'ubuntu', + 'alpine', + 'rhel', + 'almalinux', + 'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]), default => CheckResult::fail(implode(', ', $missing) . ' not installed on your system'), }; } @@ -80,7 +84,9 @@ class LinuxToolCheckList $install_cmd = match ($distro['dist']) { 'ubuntu', 'debian' => 'apt-get install -y', 'alpine' => 'apk add', - default => throw new RuntimeException('Current linux distro is not supported for auto-install musl packages'), + 'rhel' => 'dnf install -y', + 'almalinux' => 'dnf install -y', + default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'), }; $prefix = ''; if (get_current_user() !== 'root') { @@ -88,7 +94,9 @@ class LinuxToolCheckList logger()->warning('Current user is not root, using sudo for running command'); } try { - shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', str_replace('xz', 'xz-utils', $missing))); + $is_rhel = in_array($distro['dist'], ['rhel', 'almalinux']); + $to_install = $is_rhel ? $missing : str_replace('xz', 'xz-utils', $missing); + shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', $to_install)); } catch (RuntimeException) { return false; } From e3a4cd6e1db4f73b676c2a622b8d94d71bcafe03 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 18 Sep 2023 12:52:35 +0200 Subject: [PATCH 189/296] fix spelling mistake in README-en.md --- README-en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-en.md b/README-en.md index 5957ac7f..f64d6552 100755 --- a/README-en.md +++ b/README-en.md @@ -214,7 +214,7 @@ If you are familiar with this project, you are also welcome to initiate a pull r The basic principles for contributing are as follows: -- This project uses php-cs-fixer and phpstan as code formatting tools. Before contributing, please run `composer analyze` and `composer cs-fix` on the updated code. +- This project uses php-cs-fixer and phpstan as code formatting tools. Before contributing, please run `composer analyse` and `composer cs-fix` on the updated code. - If other open source libraries are involved, the corresponding licenses should be provided. Also, configuration files should be sorted using the command `sort-config` after modification. For more information about sorting commands, see the documentation. From 059c32e59cd4df60e5c1ae36a35daddfebf8d67b Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 18 Sep 2023 13:43:58 +0200 Subject: [PATCH 190/296] add ext-ldap (openldap) support --- config/ext.json | 8 +++++- config/lib.json | 7 +++++ config/source.json | 10 +++++++ src/SPC/builder/linux/library/ldap.php | 12 +++++++++ src/SPC/builder/macos/library/ldap.php | 12 +++++++++ src/SPC/builder/unix/library/curl.php | 4 +-- src/SPC/builder/unix/library/ldap.php | 29 +++++++++++++++++++++ src/SPC/builder/unix/library/postgresql.php | 3 +-- src/SPC/doctor/item/LinuxMuslCheck.php | 11 ++++++-- src/SPC/doctor/item/LinuxToolCheckList.php | 14 ++++++++-- 10 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 src/SPC/builder/linux/library/ldap.php create mode 100644 src/SPC/builder/macos/library/ldap.php create mode 100644 src/SPC/builder/unix/library/ldap.php diff --git a/config/ext.json b/config/ext.json index d5234e4e..92ad0598 100644 --- a/config/ext.json +++ b/config/ext.json @@ -153,9 +153,15 @@ }, "ldap": { "type": "builtin", - "arg-type": "with", + "arg-type": "with-prefix", "lib-depends": [ "ldap" + ], + "lib-suggests": [ + "openssl" + ], + "ext-suggests": [ + "openssl" ] }, "mbregex": { diff --git a/config/lib.json b/config/lib.json index 606a1be4..bc11d36c 100644 --- a/config/lib.json +++ b/config/lib.json @@ -139,6 +139,13 @@ "libxml2" ] }, + "ldap": { + "source": "ldap", + "static-libs-unix": [ + "liblber.a", + "libldap.a" + ] + }, "libavif": { "source": "libavif", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 95bb0a13..498e72a8 100644 --- a/config/source.json +++ b/config/source.json @@ -42,6 +42,16 @@ "path": "COPYING" } }, + "ldap": { + "type": "filelist", + "url": "https://www.openldap.org/software/download/OpenLDAP/openldap-release/", + "regex": "/href=\"(?openldap-(?[^\"]+)\\.tgz)\"/", + "path": "php-src/ext/ldap", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-event": { "type": "url", "url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz", diff --git a/src/SPC/builder/linux/library/ldap.php b/src/SPC/builder/linux/library/ldap.php new file mode 100644 index 00000000..2d3f591b --- /dev/null +++ b/src/SPC/builder/linux/library/ldap.php @@ -0,0 +1,12 @@ +builder->getLib('ldap') ? '-DCURL_DISABLE_LDAP=OFF ' : '-DCURL_DISABLE_LDAP=ON '; // lib:zstd $extra .= $this->builder->getLib('zstd') ? '-DCURL_ZSTD=ON ' : '-DCURL_ZSTD=OFF '; // lib:idn2 diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php new file mode 100644 index 00000000..63463432 --- /dev/null +++ b/src/SPC/builder/unix/library/ldap.php @@ -0,0 +1,29 @@ +cd($this->source_dir) + ->exec( + $this->builder->configure_env . ' ' . + 'LDFLAGS="-static"' . + ' ./configure ' . + '--enable-static ' . + '--disable-shared ' . + '--disable-slapd ' . + '--without-systemd ' . + ($this->builder->getLib('openssl') ? '--with-tls=openssl ' : '') . + '--prefix=' + ) + ->exec('make clean') + ->exec('make depend') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + $this->patchPkgconfPrefix(['ldap.pc', 'lber.pc']); + } +} diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index b2fa4b27..b02f46a7 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -57,15 +57,14 @@ trait postgresql '--with-ssl=openssl ' . '--with-readline ' . '--with-libxml ' . + ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . - '--without-ldap ' . '--without-libxslt ' . '--without-lz4 ' . '--without-zstd ' . '--without-perl ' . '--without-python ' . '--without-pam ' . - '--without-ldap ' . '--without-bonjour ' . '--without-tcl ' ); diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index 860a23be..0fc94a34 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -36,11 +36,18 @@ class LinuxMuslCheck #[AsFixItem('fix-musl')] public function fixMusl(array $distro): bool { + $rhel_install = 'dnf install tar wget git zip bison flex bzip2 cmake patch && \ + wget https://musl.libc.org/releases/musl-1.2.4.tar.gz && tar -zxvf musl-1.2.4.tar.gz && \ + rm -f musl-1.2.4.tar.gz && cd musl-1.2.4 && + if [[ ! "$PATH" =~ (^|:)"/usr/local/musl/bin"(:|$) ]]; then export PATH="/usr/local/musl/bin:$PATH" + fi && \ + ./configure --disable-shared --enable-wrapper=gcc && \ + make -j && make install && cd ..'; $install_cmd = match ($distro['dist']) { 'ubuntu', 'debian' => 'apt-get install musl musl-tools -y', 'alpine' => 'apk add musl musl-utils musl-dev', - 'rhel' => 'dnf install tar wget git zip bison flex bzip2 cmake patch && wget https://musl.libc.org/releases/musl-1.2.4.tar.gz && tar -zxvf musl-1.2.4.tar.gz && rm musl-1.2.4.tar.gz && cd musl-1.2.4 && ./configure && make -j && make install && cd ..', - 'almalinux' => 'dnf install bison flex bzip2 cmake patch && wget https://musl.libc.org/releases/musl-1.2.4.tar.gz && tar -zxvf musl-1.2.4.tar.gz && rm musl-1.2.4.tar.gz && cd musl-1.2.4 && ./configure && make -j && make install && export PATH="/usr/local/musl/bin:$PATH" cd ..', + 'rhel' => $rhel_install, + 'almalinux' => $rhel_install, default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'), }; $prefix = ''; diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index e4d6951c..0e483f2d 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -16,7 +16,7 @@ class LinuxToolCheckList use UnixSystemUtilTrait; public const TOOLS_ALPINE = [ - 'perl', 'make', 'bison', 'flex', + 'make', 'bison', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'gcc', @@ -24,13 +24,21 @@ class LinuxToolCheckList ]; public const TOOLS_DEBIAN = [ - 'perl', 'make', 'bison', 'flex', + 'make', 'bison', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'patch', 'xz', ]; + public const TOOLS_RHEL = [ + 'perl', 'make', 'bison', 'flex', + 'git', 'autoconf', 'automake', + 'tar', 'unzip', 'gzip', 'gcc', + 'bzip2', 'cmake', 'patch', + 'xz', + ]; + /** @noinspection PhpUnused */ #[AsCheckItem('if necessary tools are installed', limit_os: 'Linux')] public function checkCliTools(): ?CheckResult @@ -39,6 +47,8 @@ class LinuxToolCheckList $required = match ($distro['dist']) { 'alpine' => self::TOOLS_ALPINE, + 'almalinux' => self::TOOLS_RHEL, + 'rhel' => self::TOOLS_RHEL, default => self::TOOLS_DEBIAN, }; $missing = []; From 1437be3a9da2f604e9bd41a83c6625ad75335fd1 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 21 Sep 2023 12:56:52 +0200 Subject: [PATCH 191/296] gmp and libsodium for ldap if enabled only enable openssl when zlib ext is also enabled (missing 'deflate' otherwise) move back from source/php-src/ext/ldap to source/ldap (fix "LICENSE not found") --- config/ext.json | 8 ++++++-- config/source.json | 1 - src/SPC/builder/unix/library/ldap.php | 9 +++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/config/ext.json b/config/ext.json index 92ad0598..2914007f 100644 --- a/config/ext.json +++ b/config/ext.json @@ -158,10 +158,14 @@ "ldap" ], "lib-suggests": [ - "openssl" + "openssl", + "zlib", + "gmp", + "libsodium" ], "ext-suggests": [ - "openssl" + "openssl", + "zlib" ] }, "mbregex": { diff --git a/config/source.json b/config/source.json index 498e72a8..d204062e 100644 --- a/config/source.json +++ b/config/source.json @@ -46,7 +46,6 @@ "type": "filelist", "url": "https://www.openldap.org/software/download/OpenLDAP/openldap-release/", "regex": "/href=\"(?openldap-(?[^\"]+)\\.tgz)\"/", - "path": "php-src/ext/ldap", "license": { "type": "file", "path": "LICENSE" diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index 63463432..00078012 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -11,13 +11,18 @@ trait ldap shell()->cd($this->source_dir) ->exec( $this->builder->configure_env . ' ' . - 'LDFLAGS="-static"' . + 'CC="musl-gcc -I' . BUILD_INCLUDE_PATH . '" ' . + 'LDFLAGS="-static -L' . BUILD_LIB_PATH . '" ' . + ($this->builder->getLib('openssl') && $this->builder->getExt('zlib') ? 'LIBS="-lssl -lcrypto -lz" ' : '') . ' ./configure ' . '--enable-static ' . '--disable-shared ' . '--disable-slapd ' . + '--disable-slurpd ' . '--without-systemd ' . - ($this->builder->getLib('openssl') ? '--with-tls=openssl ' : '') . + ($this->builder->getLib('openssl') && $this->builder->getExt('zlib') ? '--with-tls=openssl ' : '') . + ($this->builder->getLib('gmp') ? '--with-mp=gmp ' : '') . + ($this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : '') . '--prefix=' ) ->exec('make clean') From a4e173f16d3cb6e1e16b75dbfe3153c0ee301856 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 23 Sep 2023 14:08:35 +0800 Subject: [PATCH 192/296] add configure flags for unix builder --- src/SPC/builder/traits/UnixBuilderTrait.php | 22 +++++++++++++++++++++ src/globals/defines.php | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/src/SPC/builder/traits/UnixBuilderTrait.php b/src/SPC/builder/traits/UnixBuilderTrait.php index 5ca62f1b..ce3795be 100644 --- a/src/SPC/builder/traits/UnixBuilderTrait.php +++ b/src/SPC/builder/traits/UnixBuilderTrait.php @@ -153,4 +153,26 @@ trait UnixBuilderTrait "-DCMAKE_INSTALL_INCLUDEDIR={$include} " . "-DCMAKE_TOOLCHAIN_FILE={$this->cmake_toolchain_file}"; } + + /** + * Generate configure flags + */ + public function makeAutoconfFlags(int $flag = AUTOCONF_ALL): string + { + $extra = ''; + // TODO: add auto pkg-config support + if (($flag & AUTOCONF_LIBS) === AUTOCONF_LIBS) { + $extra .= 'LIBS="' . BUILD_LIB_PATH . '" '; + } + if (($flag & AUTOCONF_CFLAGS) === AUTOCONF_CFLAGS) { + $extra .= 'CFLAGS="-I' . BUILD_INCLUDE_PATH . '" '; + } + if (($flag & AUTOCONF_CPPFLAGS) === AUTOCONF_CPPFLAGS) { + $extra .= 'CPPFLAGS="-I' . BUILD_INCLUDE_PATH . '" '; + } + if (($flag & AUTOCONF_LDFLAGS) === AUTOCONF_LDFLAGS) { + $extra .= 'LDFLAGS="-L' . BUILD_LIB_PATH . '" '; + } + return $extra; + } } diff --git a/src/globals/defines.php b/src/globals/defines.php index cd29fb42..1e5aa085 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -59,4 +59,11 @@ const PKGCONF_PATCH_INCLUDEDIR = 8; const PKGCONF_PATCH_CUSTOM = 16; const PKGCONF_PATCH_ALL = 31; +// autoconf flags +const AUTOCONF_LIBS = 1; +const AUTOCONF_CFLAGS = 2; +const AUTOCONF_CPPFLAGS = 4; +const AUTOCONF_LDFLAGS = 8; +const AUTOCONF_ALL = 15; + ConsoleLogger::$date_format = 'H:i:s'; From d7627dd81ac4d16264376ff5331f5dc5c4bb500e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 23 Sep 2023 14:08:59 +0800 Subject: [PATCH 193/296] correct libc name for linux --- src/SPC/builder/linux/LinuxBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 1c8f207f..bae67765 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -52,7 +52,7 @@ class LinuxBuilder extends BuilderBase // ---------- set necessary compile environments ---------- // set libc - $this->libc = 'musl'; // SystemUtil::selectLibc($this->cc); + $this->libc = $this->getOption('cc', 'gcc') === 'musl-gcc' ? 'musl_wrapper' : 'musl'; // SystemUtil::selectLibc($this->cc); // concurrency $this->concurrency = SystemUtil::getCpuCount(); // cflags From 68d176ad2648934654c131909648aa210bb99bcd Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 23 Sep 2023 14:09:29 +0800 Subject: [PATCH 194/296] prevent c compiler not found error --- src/SPC/builder/linux/SystemUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/SystemUtil.php b/src/SPC/builder/linux/SystemUtil.php index 13bc44b8..bb3cb7d5 100644 --- a/src/SPC/builder/linux/SystemUtil.php +++ b/src/SPC/builder/linux/SystemUtil.php @@ -121,7 +121,7 @@ class SystemUtil public static function checkCCFlag(string $flag, string $cc): string { - [$ret] = shell()->execWithResult("echo | {$cc} -E -x c - {$flag}"); + [$ret] = shell()->execWithResult("echo | {$cc} -E -x c - {$flag} 2>/dev/null"); if ($ret != 0) { return ''; } From fe39aecd72c05099b157ba5c04eed8f02bafb284 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 23 Sep 2023 14:09:51 +0800 Subject: [PATCH 195/296] adjust config order --- config/ext.json | 8 ++++---- config/lib.json | 5 +++++ config/source.json | 18 +++++++++--------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/config/ext.json b/config/ext.json index 2914007f..359533a9 100644 --- a/config/ext.json +++ b/config/ext.json @@ -158,14 +158,11 @@ "ldap" ], "lib-suggests": [ - "openssl", - "zlib", "gmp", "libsodium" ], "ext-suggests": [ - "openssl", - "zlib" + "openssl" ] }, "mbregex": { @@ -239,6 +236,9 @@ "arg-type": "with", "lib-depends": [ "openssl" + ], + "ext-depends": [ + "zlib" ] }, "pcntl": { diff --git a/config/lib.json b/config/lib.json index bc11d36c..63aa44a4 100644 --- a/config/lib.json +++ b/config/lib.json @@ -144,6 +144,11 @@ "static-libs-unix": [ "liblber.a", "libldap.a" + ], + "lib-suggests": [ + "openssl", + "gmp", + "libsodium" ] }, "libavif": { diff --git a/config/source.json b/config/source.json index d204062e..9859cd33 100644 --- a/config/source.json +++ b/config/source.json @@ -42,15 +42,6 @@ "path": "COPYING" } }, - "ldap": { - "type": "filelist", - "url": "https://www.openldap.org/software/download/OpenLDAP/openldap-release/", - "regex": "/href=\"(?openldap-(?[^\"]+)\\.tgz)\"/", - "license": { - "type": "file", - "path": "LICENSE" - } - }, "ext-event": { "type": "url", "url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz", @@ -162,6 +153,15 @@ "path": "LICENSE" } }, + "ldap": { + "type": "filelist", + "url": "https://www.openldap.org/software/download/OpenLDAP/openldap-release/", + "regex": "/href=\"(?openldap-(?[^\"]+)\\.tgz)\"/", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "libavif": { "type": "ghtar", "repo": "AOMediaCodec/libavif", From f2371d3702da0fd37aee2d3907c03e4c3c0ca8bc Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 23 Sep 2023 14:10:35 +0800 Subject: [PATCH 196/296] bugfix: complete ldap support for macOS and Linux --- src/SPC/builder/unix/library/ldap.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index 00078012..3ba74d65 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -11,22 +11,22 @@ trait ldap shell()->cd($this->source_dir) ->exec( $this->builder->configure_env . ' ' . - 'CC="musl-gcc -I' . BUILD_INCLUDE_PATH . '" ' . - 'LDFLAGS="-static -L' . BUILD_LIB_PATH . '" ' . - ($this->builder->getLib('openssl') && $this->builder->getExt('zlib') ? 'LIBS="-lssl -lcrypto -lz" ' : '') . + $this->builder->makeAutoconfFlags(AUTOCONF_LDFLAGS | AUTOCONF_CPPFLAGS) . ' ./configure ' . '--enable-static ' . '--disable-shared ' . '--disable-slapd ' . '--disable-slurpd ' . '--without-systemd ' . + '--without-cyrus-sasl ' . ($this->builder->getLib('openssl') && $this->builder->getExt('zlib') ? '--with-tls=openssl ' : '') . ($this->builder->getLib('gmp') ? '--with-mp=gmp ' : '') . ($this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : '') . '--prefix=' ) ->exec('make clean') - ->exec('make depend') + // remove tests and doc to prevent compile failed with error: soelim not found + ->exec('sed -i -e "s/SUBDIRS= include libraries clients servers tests doc/SUBDIRS= include libraries clients servers/g" Makefile') ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['ldap.pc', 'lber.pc']); From f9685b82a1645dee876f7bf4bae1c02502c7ec45 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 30 Sep 2023 23:18:53 +0800 Subject: [PATCH 197/296] adjust tool check level --- src/SPC/doctor/item/LinuxToolCheckList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 0e483f2d..6516731e 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -40,7 +40,7 @@ class LinuxToolCheckList ]; /** @noinspection PhpUnused */ - #[AsCheckItem('if necessary tools are installed', limit_os: 'Linux')] + #[AsCheckItem('if necessary tools are installed', limit_os: 'Linux', level: 999)] public function checkCliTools(): ?CheckResult { $distro = SystemUtil::getOSRelease(); From 654c5cba0ccf9259165dcc4b58280cd210b99536 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 30 Sep 2023 17:50:37 +0200 Subject: [PATCH 198/296] fix musl install on rhel --- src/SPC/doctor/item/LinuxMuslCheck.php | 9 ++++----- src/SPC/doctor/item/LinuxToolCheckList.php | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index 0fc94a34..3e5cb75a 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -36,13 +36,12 @@ class LinuxMuslCheck #[AsFixItem('fix-musl')] public function fixMusl(array $distro): bool { - $rhel_install = 'dnf install tar wget git zip bison flex bzip2 cmake patch && \ - wget https://musl.libc.org/releases/musl-1.2.4.tar.gz && tar -zxvf musl-1.2.4.tar.gz && \ + $rhel_install = 'wget https://musl.libc.org/releases/musl-1.2.4.tar.gz && tar -zxvf musl-1.2.4.tar.gz && \ rm -f musl-1.2.4.tar.gz && cd musl-1.2.4 && - if [[ ! "$PATH" =~ (^|:)"/usr/local/musl/bin"(:|$) ]]; then export PATH="/usr/local/musl/bin:$PATH" + if [[ ! "$PATH" =~ (^|:)"/usr/local/musl/bin"(:|$) ]]; then echo "export PATH=/usr/local/musl/bin:$PATH" >> ~/.bash_profile fi && \ - ./configure --disable-shared --enable-wrapper=gcc && \ - make -j && make install && cd ..'; + ./configure --enable-wrapper=gcc && \ + make -j && make install && cd .. && rm -rf musl-1.2.4'; $install_cmd = match ($distro['dist']) { 'ubuntu', 'debian' => 'apt-get install musl musl-tools -y', 'alpine' => 'apk add musl musl-utils musl-dev', diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 6516731e..897d4ef4 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -36,7 +36,7 @@ class LinuxToolCheckList 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'gcc', 'bzip2', 'cmake', 'patch', - 'xz', + 'xz', 'wget', // to get musl ]; /** @noinspection PhpUnused */ From 8f43a09533c0295abd5bf32f3e4616316db67789 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 1 Oct 2023 01:06:11 +0800 Subject: [PATCH 199/296] separate alternative libs --- src/SPC/builder/unix/library/ldap.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index 3ba74d65..d1ffcbd7 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -8,6 +8,13 @@ trait ldap { protected function build(): void { + $alt = ''; + // openssl support + $alt .= $this->builder->getLib('openssl') && $this->builder->getExt('zlib') ? '--with-tls=openssl ' : ''; + // gmp support + $alt .= $this->builder->getLib('gmp') ? '--with-mp=gmp ' : ''; + // libsodium support + $alt .= $this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : ''; shell()->cd($this->source_dir) ->exec( $this->builder->configure_env . ' ' . @@ -19,9 +26,7 @@ trait ldap '--disable-slurpd ' . '--without-systemd ' . '--without-cyrus-sasl ' . - ($this->builder->getLib('openssl') && $this->builder->getExt('zlib') ? '--with-tls=openssl ' : '') . - ($this->builder->getLib('gmp') ? '--with-mp=gmp ' : '') . - ($this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : '') . + $alt . '--prefix=' ) ->exec('make clean') From 8636f2e7c9303459ce8b2d12c683928c4f7180a6 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Sat, 30 Sep 2023 08:56:37 +0200 Subject: [PATCH 200/296] Throw proper exception when PHP source is not available --- src/SPC/builder/BuilderBase.php | 14 ++++++++++++-- src/SPC/builder/extension/openssl.php | 4 ++-- src/SPC/builder/extension/swow.php | 3 +-- src/SPC/util/Util.php | 18 ------------------ 4 files changed, 15 insertions(+), 24 deletions(-) delete mode 100644 src/SPC/util/Util.php diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index c0b66223..6ba6d9a8 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -227,12 +227,22 @@ abstract class BuilderBase /** * Get PHP Version ID from php-src/main/php_version.h + * + * @throws RuntimeException + * @throws WrongUsageException */ public function getPHPVersionID(): int { + if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { + throw new WrongUsageException('PHP source files are not available, you need to download them first'); + } + $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); - preg_match('/PHP_VERSION_ID (\d+)/', $file, $match); - return intval($match[1]); + if (preg_match('/PHP_VERSION_ID (\d+)/', $file, $match) !== 0) { + return intval($match[1]); + } + + throw new RuntimeException('PHP version file format is malformed, please remove it and download again'); } /** diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index 447011da..a81f24b5 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -6,7 +6,6 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\util\CustomExt; -use SPC\util\Util; #[CustomExt('openssl')] class openssl extends Extension @@ -14,12 +13,13 @@ class openssl extends Extension public function patchBeforeMake(): bool { // patch openssl3 with php8.0 bug - if (file_exists(SOURCE_PATH . '/openssl/VERSION.dat') && Util::getPHPVersionID() < 80100) { + if (file_exists(SOURCE_PATH . '/openssl/VERSION.dat') && $this->builder->getPHPVersionID() < 80100) { $openssl_c = file_get_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c'); $openssl_c = preg_replace('/REGISTER_LONG_CONSTANT\s*\(\s*"OPENSSL_SSLV23_PADDING"\s*.+;/', '', $openssl_c); file_put_contents(SOURCE_PATH . '/php-src/ext/openssl/openssl.c', $openssl_c); return true; } + return false; } } diff --git a/src/SPC/builder/extension/swow.php b/src/SPC/builder/extension/swow.php index fdea5a6e..a43fdc1d 100644 --- a/src/SPC/builder/extension/swow.php +++ b/src/SPC/builder/extension/swow.php @@ -7,7 +7,6 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\exception\RuntimeException; use SPC\util\CustomExt; -use SPC\util\Util; #[CustomExt('swow')] class swow extends Extension @@ -25,7 +24,7 @@ class swow extends Extension */ public function patchBeforeBuildconf(): bool { - if (Util::getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) { + if ($this->builder->getPHPVersionID() >= 80000 && !is_link(SOURCE_PATH . '/php-src/ext/swow')) { if (PHP_OS_FAMILY === 'Windows') { f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && mklink /D swow swow-src\ext'); } else { diff --git a/src/SPC/util/Util.php b/src/SPC/util/Util.php deleted file mode 100644 index ff017527..00000000 --- a/src/SPC/util/Util.php +++ /dev/null @@ -1,18 +0,0 @@ - Date: Sun, 1 Oct 2023 01:32:43 +0800 Subject: [PATCH 201/296] fix bugs when building micro and embed at the same time --- src/SPC/builder/linux/LinuxBuilder.php | 4 ++++ src/SPC/builder/macos/MacOSBuilder.php | 4 ++++ src/SPC/store/SourcePatcher.php | 2 ++ 3 files changed, 10 insertions(+) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index bae67765..4ea38a6b 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -10,6 +10,7 @@ use SPC\builder\traits\UnixBuilderTrait; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; +use SPC\store\FileSystem; use SPC\store\SourcePatcher; class LinuxBuilder extends BuilderBase @@ -223,6 +224,9 @@ class LinuxBuilder extends BuilderBase } if ($enableEmbed) { logger()->info('building embed'); + if ($enableMicro) { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la'); + } $this->buildEmbed($extra_libs, $use_lld); } diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index bbf4a791..49643678 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -10,6 +10,7 @@ use SPC\builder\traits\UnixBuilderTrait; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; +use SPC\store\FileSystem; use SPC\store\SourcePatcher; class MacOSBuilder extends BuilderBase @@ -195,6 +196,9 @@ class MacOSBuilder extends BuilderBase } if ($enableEmbed) { logger()->info('building embed'); + if ($enableMicro) { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la'); + } $this->buildEmbed(); } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 7fbfb1b5..1bbe0476 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -141,6 +141,8 @@ class SourcePatcher } FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', ''); + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'install-micro', ''); + // call extension patch before make foreach ($builder->getExts() as $ext) { if ($ext->patchBeforeMake() === true) { From fbe149bcac6613350b6a9c2ce830e64cdaf3f4ba Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 5 Oct 2023 21:58:42 +0800 Subject: [PATCH 202/296] reuse static-php-cli-hosted workflows --- .github/workflows/release-build.yml | 72 +++++++---------------------- 1 file changed, 16 insertions(+), 56 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 77c7c728..139d4a34 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -1,4 +1,4 @@ -name: Build Release Artifacts +name: Upload SPC Binary (Release) on: release: @@ -8,71 +8,31 @@ on: jobs: build-release-artifacts: - name: "Build Release Artifacts" - runs-on: ${{ matrix.operating-system }} + name: "Upload SPC Binary (Release)" + runs-on: ubuntu-latest strategy: - fail-fast: false matrix: - php-version: - - "8.1" operating-system: - - "ubuntu-latest" - - "macos-latest" + - "linux-x86_64" + - "macos-x86_64" + - "linux-aarch64" + - "macos-aarch64" steps: - name: "Checkout" uses: "actions/checkout@v4" - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" + - name: Reuse static-php-cli-hosted artifacts + uses: dawidd6/action-download-artifact@v2 with: - coverage: none - tools: composer:v2 - php-version: "${{ matrix.php-version }}" - ini-values: memory_limit=-1 - - - name: "Get Composer Cache Directory" - id: composer-cache - run: | - echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: "Cache Composer dependencies" - uses: "actions/cache@v3" - with: - path: "${{ steps.composer-cache.outputs.dir }}" - key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}" - restore-keys: | - php-${{ matrix.php-version }}-locked-composer- - - name: "Install locked dependencies" - run: "composer install --no-interaction --no-progress" - - - name: "Download sources" - run: bin/spc download --with-php=${{ matrix.php-version }} php-src,micro,pkg-config,onig,zlib - - - name: "Build phpmicro" - run: | - SPC_USE_SUDO=yes bin/spc doctor --auto-fix - bin/spc build pcntl,posix,mbstring,tokenizer,phar --build-micro - - - name: "Build PHAR file" - run: "composer build:phar" - - - name: "Generate Executable" - run: "bin/spc micro:combine spc.phar -O spc" + repo: crazywhalecc/static-php-cli-hosted + branch: master + workflow: build-spc-release.yml + name: "spc-${{ matrix.operating-system }}" - name: "Archive Executable" run: | - OS="" - if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then - OS="linux-x86_64" - elif [ "${{ matrix.operating-system }}" = "macos-latest" ]; then - OS="macos-x86_64" - fi - tar -czf spc-$OS.tar.gz spc - echo "filename=spc-$OS.tar.gz" >> $GITHUB_ENV - echo "OS=$OS" >> $GITHUB_ENV - - - name: "Test Micro file" - run: "./spc dev:extensions" + tar -czf spc-${{ matrix.operating-system }}.tar.gz spc + echo "filename=spc-${{ matrix.operating-system }}.tar.gz" >> $GITHUB_ENV - name: upload binaries to release uses: softprops/action-gh-release@v1 @@ -84,4 +44,4 @@ jobs: uses: actions/upload-artifact@v3 with: path: spc - name: spc-${{ env.OS }} + name: spc-${{ matrix.operating-system }} From 29be3a2e399e691768363b44c0ecf3edebb7c00b Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 5 Oct 2023 22:07:44 +0800 Subject: [PATCH 203/296] set version to 2.0-rc7 --- src/SPC/ConsoleApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 5ab014fa..967da910 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.0.0'; + public const VERSION = '2.0-rc7'; public function __construct() { From 56caef78e32bf43a757f33bbb7207cd4ac4192bf Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 7 Oct 2023 15:37:49 +0800 Subject: [PATCH 204/296] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8dc62561..19361dd4 100755 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Build single static PHP binary, with PHP project together, with popular extensio **If you are using English, see [English README](README-en.md).** +> 项目别名:standalone-php-compiler + 编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携!(cli SAPI) 截屏2023-05-02 15 53 13 From 630c0d3a5da9733e030d83a87e2bccca791d0285 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Oct 2023 11:18:02 +0800 Subject: [PATCH 205/296] add SourcePatcher::patchFile --- src/SPC/store/SourcePatcher.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 1bbe0476..b0edc303 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -117,6 +117,30 @@ class SourcePatcher return true; } + /** + * Use existing patch file for patching + * + * @param string $patch_name Patch file name in src/globals/patch/ + * @param string $cwd Working directory for patch command + * @param bool $reverse Reverse patches (default: False) + * @throws RuntimeException + */ + public static function patchFile(string $patch_name, string $cwd, bool $reverse = false): bool + { + if (!file_exists(ROOT_DIR . "/src/globals/patch/{$patch_name}")) { + return false; + } + + $patch_file = ROOT_DIR . "/src/globals/patch/{$patch_name}"; + $patch_str = str_replace('/', DIRECTORY_SEPARATOR, $patch_file); + + f_passthru( + 'cd ' . $cwd . ' && ' . + (PHP_OS_FAMILY === 'Windows' ? 'type' : 'cat') . ' ' . $patch_str . ' | patch -p1 ' . ($reverse ? '-R' : '') + ); + return true; + } + /** * @throws FileSystemException */ From 5d363bdb0b5cb89f93a520392ba1451a0c6878bb Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Oct 2023 11:22:46 +0800 Subject: [PATCH 206/296] adjust store classes --- src/SPC/store/FileSystem.php | 22 ++++++++++------------ src/SPC/store/SourceExtractor.php | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index f4bf8664..9cd32df1 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -55,7 +55,7 @@ class FileSystem /** * @throws FileSystemException */ - public static function replaceFileStr(string $filename, mixed $search = null, mixed $replace = null): bool|int + public static function replaceFileStr(string $filename, mixed $search = null, mixed $replace = null): false|int { return self::replaceFile($filename, REPLACE_FILE_STR, $search, $replace); } @@ -63,7 +63,7 @@ class FileSystem /** * @throws FileSystemException */ - public static function replaceFileRegex(string $filename, mixed $search = null, mixed $replace = null): bool|int + public static function replaceFileRegex(string $filename, mixed $search = null, mixed $replace = null): false|int { return self::replaceFile($filename, REPLACE_FILE_PREG, $search, $replace); } @@ -71,7 +71,7 @@ class FileSystem /** * @throws FileSystemException */ - public static function replaceFileUser(string $filename, mixed $callback = null): bool|int + public static function replaceFileUser(string $filename, mixed $callback = null): false|int { return self::replaceFile($filename, REPLACE_FILE_USER, $callback); } @@ -163,7 +163,6 @@ class FileSystem self::emitSourceExtractHook($name); return; } - if (PHP_OS_FAMILY === 'Darwin' || PHP_OS_FAMILY === 'Linux') { if (f_mkdir(directory: $target, recursive: true) !== true) { throw new FileSystemException('create ' . $name . 'source dir failed'); @@ -256,14 +255,13 @@ class FileSystem /** * 递归或非递归扫描目录,可返回相对目录的文件列表或绝对目录的文件列表 * - * @param string $dir 目录 - * @param bool $recursive 是否递归扫描子目录 - * @param bool|string $relative 是否返回相对目录,如果为true则返回相对目录,如果为false则返回绝对目录 - * @param bool $include_dir 非递归模式下,是否包含目录 - * @return array|false + * @param string $dir 目录 + * @param bool $recursive 是否递归扫描子目录 + * @param bool|string $relative 是否返回相对目录,如果为true则返回相对目录,如果为false则返回绝对目录 + * @param bool $include_dir 非递归模式下,是否包含目录 * @since 2.5 */ - public static function scanDirFiles(string $dir, bool $recursive = true, bool|string $relative = false, bool $include_dir = false): bool|array + public static function scanDirFiles(string $dir, bool $recursive = true, bool|string $relative = false, bool $include_dir = false): array|false { $dir = self::convertPath($dir); // 不是目录不扫,直接 false 处理 @@ -403,7 +401,7 @@ class FileSystem * @param mixed ...$args Arguments passed to file_put_contents * @throws FileSystemException */ - public static function writeFile(string $path, mixed $content, ...$args): bool|string|int + public static function writeFile(string $path, mixed $content, ...$args): bool|int|string { $dir = pathinfo($path, PATHINFO_DIRNAME); if (!is_dir($dir) && !mkdir($dir, 0755, true)) { @@ -446,7 +444,7 @@ class FileSystem /** * @throws FileSystemException */ - private static function replaceFile(string $filename, int $replace_type = REPLACE_FILE_STR, mixed $callback_or_search = null, mixed $to_replace = null): bool|int + private static function replaceFile(string $filename, int $replace_type = REPLACE_FILE_STR, mixed $callback_or_search = null, mixed $to_replace = null): false|int { logger()->debug('Replacing file with type[' . $replace_type . ']: ' . $filename); $file = self::readFile($filename); diff --git a/src/SPC/store/SourceExtractor.php b/src/SPC/store/SourceExtractor.php index 4a68bef8..fd8f1e54 100644 --- a/src/SPC/store/SourceExtractor.php +++ b/src/SPC/store/SourceExtractor.php @@ -52,7 +52,7 @@ class SourceExtractor // start check foreach ($sources_extracted as $source => $item) { if (Config::getSource($source) === null) { - throw new WrongUsageException("Source [{$source}] not exists, please check name and correct it !"); + throw new WrongUsageException("Source [{$source}] does not exist, please check the name and correct it !"); } if (!isset($lock[$source])) { throw new WrongUsageException('Source [' . $source . '] not downloaded or not locked, you should download it first !'); From 30213da70a841508fa9f715cfb57e0ea1a36ca88 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Oct 2023 11:27:42 +0800 Subject: [PATCH 207/296] change default download php to 8.2 --- src/SPC/command/DownloadCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index b1977459..e6588a41 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -28,7 +28,7 @@ class DownloadCommand extends BaseCommand $this->addArgument('sources', InputArgument::REQUIRED, 'The sources will be compiled, comma separated'); $this->addOption('shallow-clone', null, null, 'Clone shallow'); $this->addOption('with-openssl11', null, null, 'Use openssl 1.1'); - $this->addOption('with-php', null, InputOption::VALUE_REQUIRED, 'version in major.minor format like 8.1', '8.1'); + $this->addOption('with-php', null, InputOption::VALUE_REQUIRED, 'version in major.minor format (default 8.2)', '8.2'); $this->addOption('clean', null, null, 'Clean old download cache and source before fetch'); $this->addOption('all', 'A', null, 'Fetch all sources that static-php-cli needed'); $this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"'); From c1e9cd2ea380a46f2e20ebcf4c5b3059feb40e91 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Oct 2023 11:33:17 +0800 Subject: [PATCH 208/296] fix `--with-clean` to make it work --- src/SPC/command/BuildCliCommand.php | 5 +++++ src/SPC/command/BuildCommand.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 00be7559..db08187f 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -7,6 +7,7 @@ namespace SPC\command; use SPC\builder\BuilderProvider; use SPC\exception\ExceptionHandler; use SPC\exception\WrongUsageException; +use SPC\store\FileSystem; use SPC\store\SourcePatcher; use SPC\util\DependencyUtil; use SPC\util\LicenseDumper; @@ -70,6 +71,10 @@ class BuildCliCommand extends BuildCommand logger()->warning('some extensions will be enabled due to dependencies: ' . implode(',', $not_included)); } sleep(2); + if ($this->input->getOption('with-clean')) { + logger()->info('Cleaning source dir...'); + FileSystem::removeDir(SOURCE_PATH); + } // compile libraries $builder->buildLibs($libraries); // check extensions diff --git a/src/SPC/command/BuildCommand.php b/src/SPC/command/BuildCommand.php index 8a721189..98bb77b3 100644 --- a/src/SPC/command/BuildCommand.php +++ b/src/SPC/command/BuildCommand.php @@ -28,7 +28,7 @@ abstract class BuildCommand extends BaseCommand break; } - $this->addOption('with-clean', null, null, 'fresh build, `make clean` before `make`'); + $this->addOption('with-clean', null, null, 'fresh build, remove `source` dir before `make`'); $this->addOption('bloat', null, null, 'add all libraries into binary'); } } From 5a13daee39a5b60165e9478c67bc16e693257868 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Oct 2023 13:54:23 +0800 Subject: [PATCH 209/296] remove redundant LinuxLibraryBase tryBuild --- .../linux/library/LinuxLibraryBase.php | 41 ------------------- 1 file changed, 41 deletions(-) diff --git a/src/SPC/builder/linux/library/LinuxLibraryBase.php b/src/SPC/builder/linux/library/LinuxLibraryBase.php index 5ec8c7c2..89dc46bd 100644 --- a/src/SPC/builder/linux/library/LinuxLibraryBase.php +++ b/src/SPC/builder/linux/library/LinuxLibraryBase.php @@ -8,9 +8,6 @@ use SPC\builder\BuilderBase; use SPC\builder\LibraryBase; use SPC\builder\linux\LinuxBuilder; use SPC\builder\traits\UnixLibraryTrait; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; abstract class LinuxLibraryBase extends LibraryBase { @@ -37,44 +34,6 @@ abstract class LinuxLibraryBase extends LibraryBase return $this->builder; } - /** - * @throws RuntimeException - * @throws FileSystemException - * @throws WrongUsageException - */ - public function tryBuild(bool $force_build = false): int - { - // 传入 true,表明直接编译 - if ($force_build) { - logger()->info('Building required library [' . static::NAME . ']'); - $this->patchBeforeBuild(); - $this->build(); - return BUILD_STATUS_OK; - } - - // 看看这些库是不是存在,如果不存在,则调用编译并返回结果状态 - foreach ($this->getStaticLibs() as $name) { - if (!file_exists(BUILD_LIB_PATH . "/{$name}")) { - $this->tryBuild(true); - return BUILD_STATUS_OK; - } - } - // 头文件同理 - foreach ($this->getHeaders() as $name) { - if (!file_exists(BUILD_INCLUDE_PATH . "/{$name}")) { - $this->tryBuild(true); - return BUILD_STATUS_OK; - } - } - // pkg-config 做特殊处理,如果是 pkg-config 就检查有没有 pkg-config 二进制 - if (static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) { - $this->tryBuild(true); - return BUILD_STATUS_OK; - } - // 到这里说明所有的文件都存在,就跳过编译 - return BUILD_STATUS_ALREADY; - } - protected function makeFakePkgconfs(): void { $workspace = BUILD_ROOT_PATH; From 8893d08ba9afdf714b30047a49b330afae5d7993 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Oct 2023 13:55:51 +0800 Subject: [PATCH 210/296] adjust linux distro detection --- src/SPC/builder/linux/SystemUtil.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/SPC/builder/linux/SystemUtil.php b/src/SPC/builder/linux/SystemUtil.php index bb3cb7d5..ddecc6e0 100644 --- a/src/SPC/builder/linux/SystemUtil.php +++ b/src/SPC/builder/linux/SystemUtil.php @@ -20,6 +20,19 @@ class SystemUtil 'ver' => 'unknown', ]; switch (true) { + case file_exists('/etc/centos-release'): + $lines = file('/etc/centos-release'); + goto rh; + case file_exists('/etc/redhat-release'): + $lines = file('/etc/redhat-release'); + rh: + foreach ($lines as $line) { + if (preg_match('/release\s+(\d*(\.\d+)*)/', $line, $matches)) { + $ret['dist'] = 'redhat'; + $ret['ver'] = $matches[1]; + } + } + break; case file_exists('/etc/os-release'): $lines = file('/etc/os-release'); foreach ($lines as $line) { @@ -36,19 +49,6 @@ class SystemUtil $ret['dist'] = 'redhat'; } break; - case file_exists('/etc/centos-release'): - $lines = file('/etc/centos-release'); - goto rh; - case file_exists('/etc/redhat-release'): - $lines = file('/etc/redhat-release'); - rh: - foreach ($lines as $line) { - if (preg_match('/release\s+(\d+(\.\d+)*)/', $line, $matches)) { - $ret['dist'] = 'redhat'; - $ret['ver'] = $matches[1]; - } - } - break; } return $ret; } From ed53394389e7903d15a8e76f056c036f0c782c29 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Oct 2023 14:05:33 +0800 Subject: [PATCH 211/296] add mark library patch function --- src/SPC/builder/LibraryBase.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index e9d7abd1..bd7752ac 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\builder; -use SPC\builder\macos\library\MacOSLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; @@ -19,6 +18,8 @@ abstract class LibraryBase protected array $dependencies = []; + protected bool $patched = false; + /** * @throws RuntimeException */ @@ -130,10 +131,15 @@ abstract class LibraryBase */ public function tryBuild(bool $force_build = false): int { + if (file_exists($this->source_dir . '/.spc.patched')) { + $this->patched = true; + } // force means just build if ($force_build) { logger()->info('Building required library [' . static::NAME . ']'); - $this->patchBeforeBuild(); + if (!$this->patched && $this->patchBeforeBuild()) { + file_put_contents($this->source_dir . '/.spc.patched', 'PATCHED!!!'); + } $this->build(); return BUILD_STATUS_OK; } @@ -153,7 +159,7 @@ abstract class LibraryBase } } // pkg-config is treated specially. If it is pkg-config, check if the pkg-config binary exists - if ($this instanceof MacOSLibraryBase && static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) { + if (static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) { $this->tryBuild(true); return BUILD_STATUS_OK; } From e9d3e48f903c23010fd8e995660259f7cf7837b1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Oct 2023 14:06:09 +0800 Subject: [PATCH 212/296] simplify `hasCppExtension()` method --- src/SPC/builder/BuilderBase.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 6ba6d9a8..8d8d46dd 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -148,14 +148,12 @@ abstract class BuilderBase { // judge cpp-extension $exts = array_keys($this->getExts()); - $cpp = false; foreach ($exts as $ext) { if (Config::getExt($ext, 'cpp-extension', false) === true) { - $cpp = true; - break; + return true; } } - return $cpp; + return false; } /** From 8d9cace469911ab2041c36d1898adf312b98cd1d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Oct 2023 15:09:37 +0800 Subject: [PATCH 213/296] fix mongodb release file match --- config/source.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index 9859cd33..84d16d16 100644 --- a/config/source.json +++ b/config/source.json @@ -323,7 +323,7 @@ "type": "ghrel", "repo": "mongodb/mongo-php-driver", "path": "php-src/ext/mongodb", - "match": "mongodb.+\\.zip", + "match": "mongodb.+\\.tgz", "license": { "type": "file", "path": "LICENSE" From a983667b90cda70212c6eac35dcd7feb9f1eb091 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 15 Oct 2023 09:40:04 +0800 Subject: [PATCH 214/296] fix docker alpine install package redundant link --- bin/spc-alpine-docker | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index e51b020b..e807a2df 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -59,6 +59,7 @@ RUN apk update; \ apk add --no-cache \ autoconf \ automake \ + gettext \ bash \ binutils \ bison \ @@ -89,8 +90,7 @@ RUN apk update; \ composer \ pkgconfig \ wget \ - xz ; \ - ln -s /usr/bin/php82 /usr/bin/php + xz WORKDIR /app ADD ./src /app/src From 84d1c789bd1899a30d317926898ad29cd5a5221f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 15 Oct 2023 13:07:13 +0800 Subject: [PATCH 215/296] add basic FreeBSD support for utils --- src/SPC/builder/BuilderProvider.php | 2 + src/SPC/builder/freebsd/BSDBuilder.php | 249 ++++++++++++++++++ src/SPC/builder/freebsd/SystemUtil.php | 46 ++++ .../freebsd/library/BSDLibraryBase.php | 27 ++ src/SPC/builder/freebsd/library/pkgconfig.php | 15 ++ src/SPC/builder/freebsd/library/zlib.php | 12 + src/SPC/doctor/item/BSDToolCheckList.php | 66 +++++ src/SPC/doctor/item/OSCheckList.php | 2 +- src/SPC/store/Config.php | 2 + src/SPC/store/FileSystem.php | 2 +- src/globals/functions.php | 1 + 11 files changed, 422 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/freebsd/BSDBuilder.php create mode 100644 src/SPC/builder/freebsd/SystemUtil.php create mode 100644 src/SPC/builder/freebsd/library/BSDLibraryBase.php create mode 100644 src/SPC/builder/freebsd/library/pkgconfig.php create mode 100644 src/SPC/builder/freebsd/library/zlib.php create mode 100644 src/SPC/doctor/item/BSDToolCheckList.php diff --git a/src/SPC/builder/BuilderProvider.php b/src/SPC/builder/BuilderProvider.php index b0578ac5..552af229 100644 --- a/src/SPC/builder/BuilderProvider.php +++ b/src/SPC/builder/BuilderProvider.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\builder; +use SPC\builder\freebsd\BSDBuilder; use SPC\builder\linux\LinuxBuilder; use SPC\builder\macos\MacOSBuilder; use SPC\exception\FileSystemException; @@ -31,6 +32,7 @@ class BuilderProvider // ), 'Darwin' => new MacOSBuilder($input->getOptions()), 'Linux' => new LinuxBuilder($input->getOptions()), + 'BSD' => new BSDBuilder($input->getOptions()), default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'), }; } diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php new file mode 100644 index 00000000..1ad00565 --- /dev/null +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -0,0 +1,249 @@ +options = $options; + + // ---------- set necessary options ---------- + // set C Compiler (default: clang) + $this->setOptionIfNotExist('cc', 'clang'); + // set C++ Composer (default: clang++) + $this->setOptionIfNotExist('cxx', 'clang++'); + // set arch (default: current) + $this->setOptionIfNotExist('arch', php_uname('m')); + $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); + + // ---------- set necessary compile environments ---------- + // concurrency + $this->concurrency = SystemUtil::getCpuCount(); + // cflags + $this->arch_c_flags = SystemUtil::getArchCFlags($this->getOption('arch')); + $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('arch')); + // cmake toolchain + $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('BSD', $this->getOption('arch'), $this->arch_c_flags); + // configure environment + $this->configure_env = SystemUtil::makeEnvVarString([ + 'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config', + 'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig/', + 'CC' => $this->getOption('cc'), + 'CXX' => $this->getOption('cxx'), + 'CFLAGS' => "{$this->arch_c_flags} -Wimplicit-function-declaration -Os", + 'LIBS' => '-ldl -lpthread', + 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), + ]); + + // create pkgconfig and include dir (some libs cannot create them automatically) + f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true); + f_mkdir(BUILD_INCLUDE_PATH, recursive: true); + } + + /** + * Just start to build statically linked php binary + * + * @param int $build_target build target + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + public function buildPHP(int $build_target = BUILD_TARGET_NONE): void + { + // ---------- Update extra-libs ---------- + $extra_libs = $this->getOption('extra-libs', ''); + // add libc++, some extensions or libraries need it (C++ cannot be linked statically) + $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lc++ ' : ''); + if (!$this->getOption('bloat', false)) { + $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); + } else { + logger()->info('bloat linking'); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Wl,-force_load,{$x}", array_filter($this->getAllStaticLibFiles()))); + } + $this->setOption('extra-libs', $extra_libs); + + SourcePatcher::patchBeforeBuildconf($this); + + shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force'); + + SourcePatcher::patchBeforeConfigure($this); + + $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; + $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : ''; + + $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; + $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; + $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; + $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + + shell()->cd(SOURCE_PATH . '/php-src') + ->exec( + './configure ' . + '--prefix= ' . + '--with-valgrind=no ' . // Not detect memory leak + '--enable-shared=no ' . + '--enable-static=yes ' . + "CFLAGS='{$this->arch_c_flags} -Werror=unknown-warning-option' " . + '--disable-all ' . + '--disable-cgi ' . + '--disable-phpdbg ' . + ($enableCli ? '--enable-cli ' : '--disable-cli ') . + ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . + ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') . + ($enableMicro ? '--enable-micro ' : '--disable-micro ') . + $json_74 . + $zts . + $this->makeExtensionArgs() . ' ' . + $this->configure_env + ); + + SourcePatcher::patchBeforeMake($this); + + $this->cleanMake(); + + if ($enableCli) { + logger()->info('building cli'); + $this->buildCli(); + } + if ($enableFpm) { + logger()->info('building fpm'); + $this->buildFpm(); + } + if ($enableMicro) { + logger()->info('building micro'); + $this->buildMicro(); + } + if ($enableEmbed) { + logger()->info('building embed'); + if ($enableMicro) { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la'); + } + $this->buildEmbed(); + } + + if (php_uname('m') === $this->getOption('arch')) { + $this->sanityCheck($build_target); + } + } + + /** + * Build cli sapi + * + * @throws RuntimeException + * @throws FileSystemException + */ + public function buildCli(): void + { + $vars = SystemUtil::makeEnvVarString([ + 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size + 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} /usr/lib/libm.a", + ]); + + $shell = shell()->cd(SOURCE_PATH . '/php-src'); + $shell->exec('sed -ie "s|//lib|/lib|g" Makefile'); + $shell->exec("make -j{$this->concurrency} {$vars} cli"); + if (!$this->getOption('no-strip', false)) { + $shell->exec('strip sapi/cli/php'); + } + $this->deployBinary(BUILD_TARGET_CLI); + } + + /** + * Build phpmicro sapi + * + * @throws FileSystemException|RuntimeException + */ + public function buildMicro(): void + { + if ($this->getPHPVersionID() < 80000) { + throw new RuntimeException('phpmicro only support PHP >= 8.0!'); + } + if ($this->getExt('phar')) { + $this->phar_patched = true; + SourcePatcher::patchMicro(['phar']); + } + + $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; + $vars = [ + // with debug information, optimize for size, remove identifiers, patch fake cli for micro + 'EXTRA_CFLAGS' => '-g -Os' . $enable_fake_cli, + // link resolv library (macOS needs it) + 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} /usr/lib/libm.a", + ]; + if (!$this->getOption('no-strip', false)) { + shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-all micro.sfx'); + } + $vars = SystemUtil::makeEnvVarString($vars); + + shell()->cd(SOURCE_PATH . '/php-src') + ->exec("make -j{$this->concurrency} {$vars} micro"); + $this->deployBinary(BUILD_TARGET_MICRO); + + if ($this->phar_patched) { + SourcePatcher::patchMicro(['phar'], true); + } + } + + /** + * Build fpm sapi + * + * @throws RuntimeException + * @throws FileSystemException + */ + public function buildFpm(): void + { + $vars = SystemUtil::makeEnvVarString([ + 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size + 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} /usr/lib/libm.a", // link resolv library (macOS needs it) + ]); + + $shell = shell()->cd(SOURCE_PATH . '/php-src'); + $shell->exec("make -j{$this->concurrency} {$vars} fpm"); + if (!$this->getOption('no-strip', false)) { + $shell->exec('strip sapi/fpm/php-fpm'); + } + $this->deployBinary(BUILD_TARGET_FPM); + } + + public function buildEmbed(): void + { + $vars = SystemUtil::makeEnvVarString([ + 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size + 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} /usr/lib/libm.a", // link resolv library (macOS needs it) + ]); + + shell() + ->cd(SOURCE_PATH . '/php-src') + ->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install") + // Workaround for https://github.com/php/php-src/issues/12082 + ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o') + ->exec('mkdir ' . BUILD_ROOT_PATH . '/lib/php-o') + ->cd(BUILD_ROOT_PATH . '/lib/php-o') + ->exec('ar x ' . BUILD_ROOT_PATH . '/lib/libphp.a') + ->exec('rm ' . BUILD_ROOT_PATH . '/lib/libphp.a') + ->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o') + ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o'); + } +} diff --git a/src/SPC/builder/freebsd/SystemUtil.php b/src/SPC/builder/freebsd/SystemUtil.php new file mode 100644 index 00000000..13aaafcc --- /dev/null +++ b/src/SPC/builder/freebsd/SystemUtil.php @@ -0,0 +1,46 @@ +execWithResult('sysctl -n hw.ncpu'); + if ($ret !== 0) { + throw new RuntimeException('Failed to get cpu count'); + } + + return (int) $output[0]; + } + + /** + * Get Target Arch CFlags + * + * @param string $arch Arch Name + * @return string return Arch CFlags string + * @throws WrongUsageException + */ + public static function getArchCFlags(string $arch): string + { + return match ($arch) { + 'amd64', 'x86_64' => '--target=x86_64-unknown-freebsd', + 'arm64','aarch64' => '--target=aarch-unknown-freebsd', + default => throw new WrongUsageException('unsupported arch: ' . $arch), + }; + } +} diff --git a/src/SPC/builder/freebsd/library/BSDLibraryBase.php b/src/SPC/builder/freebsd/library/BSDLibraryBase.php new file mode 100644 index 00000000..6267fbbe --- /dev/null +++ b/src/SPC/builder/freebsd/library/BSDLibraryBase.php @@ -0,0 +1,27 @@ +builder; + } +} diff --git a/src/SPC/builder/freebsd/library/pkgconfig.php b/src/SPC/builder/freebsd/library/pkgconfig.php new file mode 100644 index 00000000..62bd8ace --- /dev/null +++ b/src/SPC/builder/freebsd/library/pkgconfig.php @@ -0,0 +1,15 @@ +findCommand($cmd) === null) { + $missing[] = $cmd; + } + } + if (!empty($missing)) { + return CheckResult::fail('missing system commands: ' . implode(', ', $missing), 'build-tools-bsd', [$missing]); + } + return CheckResult::ok(); + } + + #[AsFixItem('build-tools-bsd')] + public function fixBuildTools(array $missing): bool + { + if (get_current_user() !== 'root') { + $prefix = 'sudo '; + logger()->warning('Current user is not root, using sudo for running command'); + } else { + $prefix = ''; + } + try { + shell(true)->exec("ASSUME_ALWAYS_YES=yes {$prefix} pkg install -y " . implode(' ', $missing)); + } catch (RuntimeException) { + return false; + } + return true; + } +} diff --git a/src/SPC/doctor/item/OSCheckList.php b/src/SPC/doctor/item/OSCheckList.php index 5d074793..7344ecda 100644 --- a/src/SPC/doctor/item/OSCheckList.php +++ b/src/SPC/doctor/item/OSCheckList.php @@ -15,7 +15,7 @@ class OSCheckList #[AsCheckItem('if current OS are supported', level: 999)] public function checkOS(): ?CheckResult { - if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux'])) { + if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) { return CheckResult::fail('Current OS is not supported'); } return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . ', supported'); diff --git a/src/SPC/store/Config.php b/src/SPC/store/Config.php index 3a449dfd..01328be2 100644 --- a/src/SPC/store/Config.php +++ b/src/SPC/store/Config.php @@ -54,6 +54,7 @@ class Config 'Windows' => ['-windows', '-win', ''], 'Darwin' => ['-macos', '-unix', ''], 'Linux' => ['-linux', '-unix', ''], + 'BSD' => ['-freebsd', '-bsd', '-unix', ''], default => throw new WrongUsageException('OS ' . PHP_OS_FAMILY . ' is not supported'), }; foreach ($m_key as $v) { @@ -98,6 +99,7 @@ class Config 'Windows' => ['-windows', '-win', ''], 'Darwin' => ['-macos', '-unix', ''], 'Linux' => ['-linux', '-unix', ''], + 'BSD' => ['-freebsd', '-bsd', '-unix', ''], default => throw new WrongUsageException('OS ' . PHP_OS_FAMILY . ' is not supported'), }; foreach ($m_key as $v) { diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 9cd32df1..192134da 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -163,7 +163,7 @@ class FileSystem self::emitSourceExtractHook($name); return; } - if (PHP_OS_FAMILY === 'Darwin' || PHP_OS_FAMILY === 'Linux') { + if (in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) { if (f_mkdir(directory: $target, recursive: true) !== true) { throw new FileSystemException('create ' . $name . 'source dir failed'); } diff --git a/src/globals/functions.php b/src/globals/functions.php index 7f411624..c9ef849a 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -60,6 +60,7 @@ function osfamily2dir(): string 'Windows', 'WINNT', 'Cygwin' => 'windows', 'Darwin' => 'macos', 'Linux' => 'linux', + 'BSD' => 'freebsd', default => throw new WrongUsageException('Not support os: ' . PHP_OS_FAMILY), }; } From 24c946d6872a834646f9004ca497bad62c344607 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 15 Oct 2023 13:25:26 +0800 Subject: [PATCH 216/296] fix phpunit --- tests/SPC/doctor/CheckListHandlerTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/SPC/doctor/CheckListHandlerTest.php b/tests/SPC/doctor/CheckListHandlerTest.php index 28b37cf5..03e00344 100644 --- a/tests/SPC/doctor/CheckListHandlerTest.php +++ b/tests/SPC/doctor/CheckListHandlerTest.php @@ -16,6 +16,7 @@ final class CheckListHandlerTest extends TestCase { $list = new CheckListHandler(); - $this->assertCount(6, $list->runChecks()); + $id = $list->runChecks(); + $this->assertCount(7, $id); } } From 243ee632834aa29fc9da00d01c7d518c71b3d03c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 15 Oct 2023 15:44:58 +0800 Subject: [PATCH 217/296] fix strip order for micro --- src/SPC/builder/freebsd/BSDBuilder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index 1ad00565..64587c76 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -192,13 +192,14 @@ class BSDBuilder extends BuilderBase // link resolv library (macOS needs it) 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} /usr/lib/libm.a", ]; - if (!$this->getOption('no-strip', false)) { - shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-all micro.sfx'); - } $vars = SystemUtil::makeEnvVarString($vars); shell()->cd(SOURCE_PATH . '/php-src') ->exec("make -j{$this->concurrency} {$vars} micro"); + + if (!$this->getOption('no-strip', false)) { + shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-all micro.sfx'); + } $this->deployBinary(BUILD_TARGET_MICRO); if ($this->phar_patched) { From 39fe6fa0811284d9111de66f55fd7588d9bdbd95 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 15 Oct 2023 15:45:34 +0800 Subject: [PATCH 218/296] fix copyDir for FreeBSD and add debug message --- src/SPC/store/FileSystem.php | 3 ++- src/SPC/store/SourceExtractor.php | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 192134da..9ae82889 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -132,6 +132,7 @@ class FileSystem break; case 'Linux': case 'Darwin': + case 'BSD': f_passthru('cp -r "' . $src_path . '" "' . $dst_path . '"'); break; } @@ -154,7 +155,7 @@ class FileSystem if ($move_path !== null) { $move_path = SOURCE_PATH . '/' . $move_path; } - logger()->info("extracting {$name} source"); + logger()->info("extracting {$name} source to " . ($move_path ?? SOURCE_PATH . "/{$name}") . ' ...'); try { $target = $move_path ?? (SOURCE_PATH . "/{$name}"); // Git source, just move diff --git a/src/SPC/store/SourceExtractor.php b/src/SPC/store/SourceExtractor.php index fd8f1e54..66a96c25 100644 --- a/src/SPC/store/SourceExtractor.php +++ b/src/SPC/store/SourceExtractor.php @@ -59,9 +59,12 @@ class SourceExtractor } // check source dir exist - $check = $lock[$source]['move_path'] === null ? SOURCE_PATH . '/' . $source : SOURCE_PATH . '/' . $lock[$source]['move_path']; + $check = $lock[$source]['move_path'] === null ? (SOURCE_PATH . '/' . $source) : (SOURCE_PATH . '/' . $lock[$source]['move_path']); if (!is_dir($check)) { + logger()->debug('Extracting source [' . $source . '] to ' . $check . ' ...'); FileSystem::extractSource($source, DOWNLOAD_PATH . '/' . ($lock[$source]['filename'] ?? $lock[$source]['dirname']), $lock[$source]['move_path']); + } else { + logger()->debug('Source [' . $source . '] already extracted in ' . $check . ', skip !'); } } } From b3cc360eeb3196a95b205ef26554a89d89031a5f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 15 Oct 2023 16:44:56 +0800 Subject: [PATCH 219/296] fix extension configure arg for BSD --- src/SPC/builder/Extension.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index d9edc6b5..922d4f3d 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -46,6 +46,7 @@ class Extension break; case 'Darwin': case 'Linux': + case 'BSD': $arg .= $this->getUnixConfigureArg(); break; } From 812c71f31fd0e4840bf1dea5596e2b224b4a1545 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 15 Oct 2023 16:45:44 +0800 Subject: [PATCH 220/296] update README --- README-en.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README-en.md b/README-en.md index f64d6552..3cc555db 100755 --- a/README-en.md +++ b/README-en.md @@ -34,6 +34,7 @@ Here is the architecture support status, where `CI` represents support for GitHu | macOS | CI, Local | Local | | Linux | CI, Local | CI, Local | | Windows | | | +| FreeBSD | Local | Local | > macOS-arm64 is not supported for GitHub Actions, if you are going to build on arm, you can build it manually on your own machine. diff --git a/README.md b/README.md index 19361dd4..eb3b2118 100755 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Build single static PHP binary, with PHP project together, with popular extensio | macOS | CI, Local | Local | | Linux | CI, Local | CI, Local | | Windows | | | +| FreeBSD | Local | Local | > macOS-arm64 因 GitHub 暂未提供 arm runner,如果要构建 arm 二进制,可以使用手动构建。 From 9520d68cdae7dbc29f1090f7d7dd7f75ced591ea Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 15 Oct 2023 16:47:00 +0800 Subject: [PATCH 221/296] add onig and openssl support for BSD --- src/SPC/builder/freebsd/library/onig.php | 12 ++++ src/SPC/builder/freebsd/library/openssl.php | 63 +++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/SPC/builder/freebsd/library/onig.php create mode 100644 src/SPC/builder/freebsd/library/openssl.php diff --git a/src/SPC/builder/freebsd/library/onig.php b/src/SPC/builder/freebsd/library/onig.php new file mode 100644 index 00000000..0ad9731a --- /dev/null +++ b/src/SPC/builder/freebsd/library/onig.php @@ -0,0 +1,12 @@ + + * + * lwmbs is licensed under Mulan PSL v2. You can use this + * software according to the terms and conditions of the + * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, + * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +declare(strict_types=1); + +namespace SPC\builder\freebsd\library; + +use SPC\builder\macos\library\MacOSLibraryBase; +use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; + +class openssl extends BSDLibraryBase +{ + public const NAME = 'openssl'; + + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + protected function build(): void + { + [$lib,,$destdir] = SEPARATED_PATH; + + // lib:zlib + $extra = ''; + $ex_lib = ''; + $zlib = $this->builder->getLib('zlib'); + if ($zlib instanceof MacOSLibraryBase) { + $extra = 'zlib'; + $ex_lib = trim($zlib->getStaticLibFiles() . ' ' . $ex_lib); + } + + shell()->cd($this->source_dir) + ->exec( + "{$this->builder->configure_env} ./Configure no-shared {$extra} " . + '--prefix=/ ' . // use prefix=/ + "--libdir={$lib} " . + '--openssldir=/etc/ssl ' . + 'BSD-' . arch2gnu($this->builder->getOption('arch')) + ) + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"") + ->exec("make install_sw DESTDIR={$destdir}"); + $this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']); + } +} From 6277539a7962d3b90afe75a2b487d8a4a7c1b3c2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 15 Oct 2023 17:01:36 +0800 Subject: [PATCH 222/296] change README micro repo description --- README-en.md | 6 ++++-- README.md | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README-en.md b/README-en.md index 3cc555db..a6ce40fd 100755 --- a/README-en.md +++ b/README-en.md @@ -8,11 +8,13 @@ Compile a purely static php-cli binary file with various extensions to make PHP 2023-05-02 15 53 13 -You can also use the micro binary file to combine php binary and php source code into one for distribution! -This feature is provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro). (micro SAPI) +You can also use the micro binary file to combine php binary and php source code into one for distribution! (micro SAPI) 2023-05-02 15 52 33 +> This SAPI feature is from the [Fork](https://github.com/crazywhalecc/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro). + + [![Version](https://img.shields.io/badge/Version-2.0--rc5-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) diff --git a/README.md b/README.md index eb3b2118..daab54c3 100755 --- a/README.md +++ b/README.md @@ -10,10 +10,12 @@ Build single static PHP binary, with PHP project together, with popular extensio 截屏2023-05-02 15 53 13 -同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发!(由 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 提供支持)(micro SAPI) +同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发!(micro SAPI) 截屏2023-05-02 15 52 33 +> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/dixyes/phpmicro)。 + [![Version](https://img.shields.io/badge/Version-2.0--rc5-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) From b6c0b998b32fcbc8a58f34748232b1dbba364fad Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 15 Oct 2023 17:17:42 +0800 Subject: [PATCH 223/296] add bz2,curl support --- src/SPC/builder/freebsd/library/bzip2.php | 12 ++++++++++++ src/SPC/builder/freebsd/library/curl.php | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/SPC/builder/freebsd/library/bzip2.php create mode 100644 src/SPC/builder/freebsd/library/curl.php diff --git a/src/SPC/builder/freebsd/library/bzip2.php b/src/SPC/builder/freebsd/library/bzip2.php new file mode 100644 index 00000000..8695adac --- /dev/null +++ b/src/SPC/builder/freebsd/library/bzip2.php @@ -0,0 +1,12 @@ +builder->getLib('openssl')) { + $this->builder->setOption('extra-libs', $this->builder->getOption('extra-libs') . ' /usr/lib/libpthread.a /usr/lib/libdl.a'); + } + return $libs; + } +} From ce60a9c804247551c2cd0e89850555d51608c929 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 15 Oct 2023 17:40:19 +0800 Subject: [PATCH 224/296] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index daab54c3..ca3d0f0f 100755 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Build single static PHP binary, with PHP project together, with popular extensio 截屏2023-05-02 15 52 33 -> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/dixyes/phpmicro)。 +> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/crazywhalecc/phpmicro)。 [![Version](https://img.shields.io/badge/Version-2.0--rc5-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() From 2e3544f296a33414a40307c8e1440fd26abba0d5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 16 Oct 2023 22:58:49 +0200 Subject: [PATCH 225/296] catch exception when license path key is not set, fix libxslt license --- config/source.json | 2 +- src/SPC/util/LicenseDumper.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config/source.json b/config/source.json index 84d16d16..a7af224f 100644 --- a/config/source.json +++ b/config/source.json @@ -270,7 +270,7 @@ "regex": "/href=\"(?libxslt-(?[^\"]+)\\.tar\\.xz)\"/", "license": { "type": "file", - "text": "COPYING" + "path": "COPYING" } }, "libyaml": { diff --git a/src/SPC/util/LicenseDumper.php b/src/SPC/util/LicenseDumper.php index d5f43909..196ca365 100644 --- a/src/SPC/util/LicenseDumper.php +++ b/src/SPC/util/LicenseDumper.php @@ -102,8 +102,11 @@ class LicenseDumper /** * @throws RuntimeException */ - private function loadSourceFile(string $source_name, string $in_path, ?string $custom_base_path = null): string + private function loadSourceFile(string $source_name, ?string $in_path, ?string $custom_base_path = null): string { + if (is_null($in_path)) { + throw new RuntimeException('source [' . $source_name . '] license file is not set, please check config/source.json'); + } if (!file_exists(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $in_path)) { throw new RuntimeException('source [' . $source_name . '] license file [' . $in_path . '] not exist'); } From c225aeffed9e49fd2cf3f17e042ec47525e4d2c8 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Oct 2023 00:55:25 +0200 Subject: [PATCH 226/296] introduce --rebuild option to BuildCliCommand.php (who even uses build:libs?) --- src/SPC/command/BuildCliCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index db08187f..42a3b5af 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -23,6 +23,7 @@ class BuildCliCommand extends BuildCommand { $this->addArgument('extensions', InputArgument::REQUIRED, 'The extensions will be compiled, comma separated'); $this->addOption('with-libs', null, InputOption::VALUE_REQUIRED, 'add additional libraries, comma separated', ''); + $this->addOption('rebuild', 'r', null, 'Delete old build and rebuild'); $this->addOption('build-micro', null, null, 'build micro'); $this->addOption('build-cli', null, null, 'build cli'); $this->addOption('build-fpm', null, null, 'build fpm'); From 37b9704fbbeffb63a7037f91bdbdf5121c7b4aa7 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 17 Oct 2023 18:34:23 +0800 Subject: [PATCH 227/296] move option `rebuild` add position --- src/SPC/command/BuildCliCommand.php | 1 - src/SPC/command/BuildCommand.php | 1 + src/SPC/command/BuildLibsCommand.php | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 42a3b5af..db08187f 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -23,7 +23,6 @@ class BuildCliCommand extends BuildCommand { $this->addArgument('extensions', InputArgument::REQUIRED, 'The extensions will be compiled, comma separated'); $this->addOption('with-libs', null, InputOption::VALUE_REQUIRED, 'add additional libraries, comma separated', ''); - $this->addOption('rebuild', 'r', null, 'Delete old build and rebuild'); $this->addOption('build-micro', null, null, 'build micro'); $this->addOption('build-cli', null, null, 'build cli'); $this->addOption('build-fpm', null, null, 'build fpm'); diff --git a/src/SPC/command/BuildCommand.php b/src/SPC/command/BuildCommand.php index 98bb77b3..0c985b13 100644 --- a/src/SPC/command/BuildCommand.php +++ b/src/SPC/command/BuildCommand.php @@ -30,5 +30,6 @@ abstract class BuildCommand extends BaseCommand $this->addOption('with-clean', null, null, 'fresh build, remove `source` dir before `make`'); $this->addOption('bloat', null, null, 'add all libraries into binary'); + $this->addOption('rebuild', 'r', null, 'Delete old build and rebuild'); } } diff --git a/src/SPC/command/BuildLibsCommand.php b/src/SPC/command/BuildLibsCommand.php index dc3989e6..be49f86a 100644 --- a/src/SPC/command/BuildLibsCommand.php +++ b/src/SPC/command/BuildLibsCommand.php @@ -20,7 +20,6 @@ class BuildLibsCommand extends BuildCommand $this->addArgument('libraries', InputArgument::REQUIRED, 'The libraries will be compiled, comma separated'); $this->addOption('clean', null, null, 'Clean old download cache and source before fetch'); $this->addOption('all', 'A', null, 'Build all libs that static-php-cli needed'); - $this->addOption('rebuild', 'r', null, 'Delete old build and rebuild'); } public function initialize(InputInterface $input, OutputInterface $output): void From dbb566ac7c1adeeed9eb254acb8595f7ba4e03f4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 17 Oct 2023 18:23:11 +0800 Subject: [PATCH 228/296] fix curl 7.4.0 CoreServices framework build bug for mac --- config/lib.json | 1 + src/SPC/builder/macos/library/curl.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/config/lib.json b/config/lib.json index 63aa44a4..73f280ab 100644 --- a/config/lib.json +++ b/config/lib.json @@ -63,6 +63,7 @@ ], "frameworks": [ "CoreFoundation", + "CoreServices", "SystemConfiguration" ] }, diff --git a/src/SPC/builder/macos/library/curl.php b/src/SPC/builder/macos/library/curl.php index c590c003..3a24f31a 100644 --- a/src/SPC/builder/macos/library/curl.php +++ b/src/SPC/builder/macos/library/curl.php @@ -44,6 +44,11 @@ class curl extends MacOSLibraryBase '/NOT SYSTEMCONFIGURATION_FRAMEWORK/m', 'FALSE' ); + FileSystem::replaceFileRegex( + SOURCE_PATH . '/curl/CMakeLists.txt', + '/NOT CORESERVICES_FRAMEWORK/m', + 'FALSE' + ); return true; } } From e0e3bc6d9755237a74d2df96baee2a5dcbfe8b19 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Oct 2023 10:55:57 +0800 Subject: [PATCH 229/296] add detection for ghrel prerelease --- src/SPC/store/Downloader.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index c8bdf179..b421acfb 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -99,12 +99,18 @@ class Downloader hooks: [[CurlHook::class, 'setupGithubToken']], ), true); $url = null; - foreach ($data[0]['assets'] as $asset) { - if (preg_match('|' . $source['match'] . '|', $asset['name'])) { - $url = $asset['browser_download_url']; - break; + foreach ($data as $release) { + if ($release['prerelease'] === true) { + continue; + } + foreach ($release['assets'] as $asset) { + if (preg_match('|' . $source['match'] . '|', $asset['name'])) { + $url = $asset['browser_download_url']; + break 2; + } } } + if (!$url) { throw new DownloaderException("failed to find {$name} source"); } From 8b188bd1b9e1ed1c2fe0ab5090b1bb1983ba07a9 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Oct 2023 10:56:14 +0800 Subject: [PATCH 230/296] change icu to ghrel --- config/source.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/source.json b/config/source.json index a7af224f..07298881 100644 --- a/config/source.json +++ b/config/source.json @@ -128,8 +128,9 @@ } }, "icu": { - "type": "url", - "url": "https://github.com/unicode-org/icu/releases/download/release-73-1/icu4c-73_1-src.tgz", + "type": "ghrel", + "repo": "unicode-org/icu", + "match": "icu4c.+-src\\.tgz", "license": { "type": "file", "path": "LICENSE" From 1e11559c4b0640ad64d486cc19eb364edff7f93c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Oct 2023 19:42:35 +0200 Subject: [PATCH 231/296] fix libpng license and libname --- config/lib.json | 2 +- config/source.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/lib.json b/config/lib.json index 73f280ab..62ea0100 100644 --- a/config/lib.json +++ b/config/lib.json @@ -223,7 +223,7 @@ "libpng": { "source": "libpng", "static-libs-unix": [ - "libpng.a" + "libpng16.a" ], "static-libs-windows": [ "libpng16_static.lib" diff --git a/config/source.json b/config/source.json index 07298881..c6813c03 100644 --- a/config/source.json +++ b/config/source.json @@ -228,8 +228,8 @@ "url": "https://git.code.sf.net/p/libpng/code", "rev": "libpng16", "license": { - "type": "text", - "text": "COPYRIGHT NOTICE, DISCLAIMER, and LICENSE\n=========================================\n\nPNG Reference Library License version 2\n---------------------------------------\n\n * Copyright (c) 1995-2019 The PNG Reference Library Authors.\n * Copyright (c) 2018-2019 Cosmin Truta.\n * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.\n * Copyright (c) 1996-1997 Andreas Dilger.\n * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n\nThe software is supplied \"as is\", without warranty of any kind,\nexpress or implied, including, without limitation, the warranties\nof merchantability, fitness for a particular purpose, title, and\nnon-infringement. In no event shall the Copyright owners, or\nanyone distributing the software, be liable for any damages or\nother liability, whether in contract, tort or otherwise, arising\nfrom, out of, or in connection with the software, or the use or\nother dealings in the software, even if advised of the possibility\nof such damage.\n\nPermission is hereby granted to use, copy, modify, and distribute\nthis software, or portions hereof, for any purpose, without fee,\nsubject to the following restrictions:\n\n 1. The origin of this software must not be misrepresented; you\n must not claim that you wrote the original software. If you\n use this software in a product, an acknowledgment in the product\n documentation would be appreciated, but is not required.\n\n 2. Altered source versions must be plainly marked as such, and must\n not be misrepresented as being the original software.\n\n 3. This Copyright notice may not be removed or altered from any\n source or altered source distribution.\n\n\nPNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)\n-----------------------------------------------------------------------\n\nlibpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are\nCopyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are\nderived from libpng-1.0.6, and are distributed according to the same\ndisclaimer and license as libpng-1.0.6 with the following individuals\nadded to the list of Contributing Authors:\n\n Simon-Pierre Cadieux\n Eric S. Raymond\n Mans Rullgard\n Cosmin Truta\n Gilles Vollant\n James Yu\n Mandar Sahastrabuddhe\n Google Inc.\n Vadim Barkov\n\nand with the following additions to the disclaimer:\n\n There is no warranty against interference with your enjoyment of\n the library or against infringement. There is no warranty that our\n efforts or the library will fulfill any of your particular purposes\n or needs. This library is provided with all faults, and the entire\n risk of satisfactory quality, performance, accuracy, and effort is\n with the user.\n\nSome files in the \"contrib\" directory and some configure-generated\nfiles that are distributed with libpng have other copyright owners, and\nare released under other open source licenses.\n\nlibpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are\nCopyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from\nlibpng-0.96, and are distributed according to the same disclaimer and\nlicense as libpng-0.96, with the following individuals added to the\nlist of Contributing Authors:\n\n Tom Lane\n Glenn Randers-Pehrson\n Willem van Schaik\n\nlibpng versions 0.89, June 1996, through 0.96, May 1997, are\nCopyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,\nand are distributed according to the same disclaimer and license as\nlibpng-0.88, with the following individuals added to the list of\nContributing Authors:\n\n John Bowler\n Kevin Bracey\n Sam Bushell\n Magnus Holmgren\n Greg Roelofs\n Tom Tanner\n\nSome files in the \"scripts\" directory have other copyright owners,\nbut are released under this license.\n\nlibpng versions 0.5, May 1995, through 0.88, January 1996, are\nCopyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n\nFor the purposes of this copyright and license, \"Contributing Authors\"\nis defined as the following set of individuals:\n\n Andreas Dilger\n Dave Martindale\n Guy Eric Schalnat\n Paul Schmidt\n Tim Wegner\n\nThe PNG Reference Library is supplied \"AS IS\". The Contributing\nAuthors and Group 42, Inc. disclaim all warranties, expressed or\nimplied, including, without limitation, the warranties of\nmerchantability and of fitness for any purpose. The Contributing\nAuthors and Group 42, Inc. assume no liability for direct, indirect,\nincidental, special, exemplary, or consequential damages, which may\nresult from the use of the PNG Reference Library, even if advised of\nthe possibility of such damage.\n\nPermission is hereby granted to use, copy, modify, and distribute this\nsource code, or portions hereof, for any purpose, without fee, subject\nto the following restrictions:\n\n 1. The origin of this source code must not be misrepresented.\n\n 2. Altered versions must be plainly marked as such and must not\n be misrepresented as being the original source.\n\n 3. This Copyright notice may not be removed or altered from any\n source or altered source distribution.\n\nThe Contributing Authors and Group 42, Inc. specifically permit,\nwithout fee, and encourage the use of this source code as a component\nto supporting the PNG file format in commercial products. If you use\nthis source code in a product, acknowledgment is not required but would\nbe appreciated.\n" + "type": "file", + "path": "LICENSE" } }, "libsodium": { From 11af370fe19093a2225b582f4013204036e45016 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Oct 2023 19:43:54 +0200 Subject: [PATCH 232/296] remove useless softlink libpng.a (pointing to libpng16.a), causes imagick build failure if freetype or png is enabled --- src/SPC/builder/linux/library/libpng.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index 81456389..d66b3282 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -67,7 +67,6 @@ class libpng extends LinuxLibraryBase ->exec('chmod +x ./install-sh') ->exec( "{$this->builder->configure_env} ./configure " . - "--host={$this->builder->getOption('gnu-arch')}-unknown-linux " . '--disable-shared ' . '--enable-static ' . '--enable-hardware-optimizations ' . @@ -77,9 +76,7 @@ class libpng extends LinuxLibraryBase ) ->exec('make clean') ->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I. -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la") - ->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH) - ->cd(BUILD_LIB_PATH) - ->exec('ln -sf libpng16.a libpng.a'); + ->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX); $this->cleanLaFiles(); } From c9b544f8c4bc429d04c5c25c98b39a919af36b01 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 19 Oct 2023 23:09:31 +0800 Subject: [PATCH 233/296] fix zlib detection in debian linux --- config/ext.json | 2 +- src/SPC/builder/extension/zlib.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/SPC/builder/extension/zlib.php diff --git a/config/ext.json b/config/ext.json index 359533a9..8fc641f9 100644 --- a/config/ext.json +++ b/config/ext.json @@ -498,7 +498,7 @@ }, "zlib": { "type": "builtin", - "arg-type": "with", + "arg-type": "custom", "arg-type-windows": "enable", "lib-depends": [ "zlib" diff --git a/src/SPC/builder/extension/zlib.php b/src/SPC/builder/extension/zlib.php new file mode 100644 index 00000000..916ee3a2 --- /dev/null +++ b/src/SPC/builder/extension/zlib.php @@ -0,0 +1,17 @@ + Date: Mon, 16 Oct 2023 14:05:07 +0200 Subject: [PATCH 234/296] add --disable-opcache-jit option for alpine --- src/SPC/builder/linux/LinuxBuilder.php | 21 ++++++--------------- src/SPC/command/BuildCliCommand.php | 1 + 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 4ea38a6b..7e2abd69 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -140,19 +140,8 @@ class LinuxBuilder extends BuilderBase $cflags = $this->arch_c_flags; $use_lld = ''; - - switch ($this->libc) { - case 'musl_wrapper': - case 'glibc': - $cflags .= ' -static-libgcc -I"' . BUILD_INCLUDE_PATH . '"'; - break; - case 'musl': - if (str_ends_with($this->getOption('cc'), 'clang') && SystemUtil::findCommand('lld')) { - $use_lld = '-Xcompiler -fuse-ld=lld'; - } - break; - default: - throw new WrongUsageException('libc ' . $this->libc . ' is not implemented yet'); + if (str_ends_with($this->getOption('cc'), 'clang') && SystemUtil::findCommand('lld')) { + $use_lld = '-Xcompiler -fuse-ld=lld'; } $envs = $this->pkgconf_env . ' ' . SystemUtil::makeEnvVarString([ @@ -179,6 +168,7 @@ class LinuxBuilder extends BuilderBase $maxExecutionTimers = ''; $zts = ''; } + $disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : ''; $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; @@ -197,11 +187,12 @@ class LinuxBuilder extends BuilderBase '--disable-phpdbg ' . ($enableCli ? '--enable-cli ' : '--disable-cli ') . ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . - ($enableEmbed ? '--enable-embed=static --disable-opcache-jit ' : '--disable-embed ') . + ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') . + ($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') . + $disable_jit . $json_74 . $zts . $maxExecutionTimers . - ($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') . $this->makeExtensionArgs() . ' ' . $envs ); diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index db08187f..72235847 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -30,6 +30,7 @@ class BuildCliCommand extends BuildCommand $this->addOption('build-all', null, null, 'build cli, micro, fpm, embed'); $this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions'); $this->addOption('enable-zts', null, null, 'enable ZTS support'); + $this->addOption('disable-opcache-jit', null, null, 'disable opcache jit'); $this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI'); $this->addOption('with-micro-fake-cli', null, null, 'Enable phpmicro fake cli'); } From 46b0ecf3fae17e5305f3436d6a80dbe09959ee7e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 16 Oct 2023 14:08:22 +0200 Subject: [PATCH 235/296] allow patching of extra_libs before make on linux too --- src/SPC/builder/linux/LinuxBuilder.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 7e2abd69..afc4f20c 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -203,22 +203,22 @@ class LinuxBuilder extends BuilderBase if ($enableCli) { logger()->info('building cli'); - $this->buildCli($extra_libs, $use_lld); + $this->buildCli($use_lld); } if ($enableFpm) { logger()->info('building fpm'); - $this->buildFpm($extra_libs, $use_lld); + $this->buildFpm($use_lld); } if ($enableMicro) { logger()->info('building micro'); - $this->buildMicro($extra_libs, $use_lld, $cflags); + $this->buildMicro($use_lld, $cflags); } if ($enableEmbed) { logger()->info('building embed'); if ($enableMicro) { FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la'); } - $this->buildEmbed($extra_libs, $use_lld); + $this->buildEmbed($use_lld); } if (php_uname('m') === $this->getOption('arch')) { @@ -232,11 +232,11 @@ class LinuxBuilder extends BuilderBase * @throws RuntimeException * @throws FileSystemException */ - public function buildCli(string $extra_libs, string $use_lld): void + public function buildCli(string $use_lld): void { $vars = SystemUtil::makeEnvVarString([ 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), - 'EXTRA_LIBS' => $extra_libs, + 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", ]); shell()->cd(SOURCE_PATH . '/php-src') @@ -256,7 +256,7 @@ class LinuxBuilder extends BuilderBase * @throws RuntimeException * @throws FileSystemException */ - public function buildMicro(string $extra_libs, string $use_lld, string $cflags): void + public function buildMicro(string $use_lld, string $cflags): void { if ($this->getPHPVersionID() < 80000) { throw new RuntimeException('phpmicro only support PHP >= 8.0!'); @@ -269,7 +269,7 @@ class LinuxBuilder extends BuilderBase $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; $vars = SystemUtil::makeEnvVarString([ 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $enable_fake_cli, - 'EXTRA_LIBS' => $extra_libs, + 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), 'EXTRA_LDFLAGS_PROGRAM' => "{$cflags} {$use_lld} -all-static", ]); shell()->cd(SOURCE_PATH . '/php-src') @@ -293,11 +293,11 @@ class LinuxBuilder extends BuilderBase * @throws FileSystemException * @throws RuntimeException */ - public function buildFpm(string $extra_libs, string $use_lld): void + public function buildFpm(string $use_lld): void { $vars = SystemUtil::makeEnvVarString([ 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), - 'EXTRA_LIBS' => $extra_libs, + 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", ]); @@ -312,11 +312,11 @@ class LinuxBuilder extends BuilderBase $this->deployBinary(BUILD_TARGET_FPM); } - public function buildEmbed(string $extra_libs, string $use_lld): void + public function buildEmbed(string $use_lld): void { $vars = SystemUtil::makeEnvVarString([ 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), - 'EXTRA_LIBS' => $extra_libs, + 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", ]); From 658e8e74bd8f8ce370952690cf6e7c7c0f09cd36 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 16 Oct 2023 14:09:49 +0200 Subject: [PATCH 236/296] use arch-linux-musl toolchains --- src/SPC/builder/linux/LinuxBuilder.php | 28 +++--- src/SPC/builder/linux/SystemUtil.php | 5 + src/SPC/doctor/item/LinuxMuslCheck.php | 129 +++++++++++++++++++------ 3 files changed, 115 insertions(+), 47 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index afc4f20c..5c077073 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -18,9 +18,6 @@ class LinuxBuilder extends BuilderBase /** Unix compatible builder methods */ use UnixBuilderTrait; - /** @var string Using libc [musl,glibc] */ - public string $libc; - /** @var array Tune cflags */ public array $tune_c_flags; @@ -40,20 +37,19 @@ class LinuxBuilder extends BuilderBase $this->options = $options; // ---------- set necessary options ---------- - // set C Compiler (default: alpine: gcc, others: musl-gcc) - $this->setOptionIfNotExist('cc', match (SystemUtil::getOSRelease()['dist']) { - 'alpine' => 'gcc', - default => 'musl-gcc' - }); - // set C++ Compiler (default: g++) - $this->setOptionIfNotExist('cxx', 'g++'); + // set C/C++ compilers (default: alpine: gcc, others: musl-cross-make) + if (SystemUtil::isMuslDist()) { + $this->setOptionIfNotExist('cc', 'gcc'); + $this->setOptionIfNotExist('cxx', 'g++'); + } else { + $arch = arch2gnu(php_uname('m')); + $this->setOptionIfNotExist('cc', "{$arch}-linux-musl-gcc"); + $this->setOptionIfNotExist('cxx', "{$arch}-linux-musl-g++"); + } // set arch (default: current) $this->setOptionIfNotExist('arch', php_uname('m')); $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); - // ---------- set necessary compile environments ---------- - // set libc - $this->libc = $this->getOption('cc', 'gcc') === 'musl-gcc' ? 'musl_wrapper' : 'musl'; // SystemUtil::selectLibc($this->cc); // concurrency $this->concurrency = SystemUtil::getCpuCount(); // cflags @@ -81,7 +77,7 @@ class LinuxBuilder extends BuilderBase 'CXX' => $this->getOption('cxx'), 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), ]); - // cross-compile does not support yet + // cross-compiling is not supported yet /*if (php_uname('m') !== $this->arch) { $this->cross_compile_prefix = SystemUtil::getCrossCompilePrefix($this->cc, $this->arch); logger()->info('using cross compile prefix: ' . $this->cross_compile_prefix); @@ -134,7 +130,7 @@ class LinuxBuilder extends BuilderBase } else { $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles()))); } - // add libstdc++, some extensions or libraries need it (C++ cannot be linked statically) + // add libstdc++, some extensions or libraries need it $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lstdc++ ' : ''); $this->setOption('extra-libs', $extra_libs); @@ -174,9 +170,11 @@ class LinuxBuilder extends BuilderBase $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + $arch = arch2gnu(php_uname('m')); shell()->cd(SOURCE_PATH . '/php-src') ->exec( + (!SystemUtil::isMuslDist() ? "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib " : '') . './configure ' . '--prefix= ' . '--with-valgrind=no ' . diff --git a/src/SPC/builder/linux/SystemUtil.php b/src/SPC/builder/linux/SystemUtil.php index ddecc6e0..34b9cdef 100644 --- a/src/SPC/builder/linux/SystemUtil.php +++ b/src/SPC/builder/linux/SystemUtil.php @@ -53,6 +53,11 @@ class SystemUtil return $ret; } + public static function isMuslDist(): bool + { + return static::getOSRelease()['dist'] === 'alpine'; + } + public static function getCpuCount(): int { $ncpu = 1; diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index 3e5cb75a..c65326ab 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -8,57 +8,122 @@ use SPC\builder\linux\SystemUtil; use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; use SPC\doctor\CheckResult; +use SPC\exception\DownloaderException; +use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; +use SPC\store\Downloader; +use SPC\store\FileSystem; class LinuxMuslCheck { /** @noinspection PhpUnused */ + /** + * @throws WrongUsageException + */ #[AsCheckItem('if musl-libc is installed', limit_os: 'Linux')] - public function checkMusl(): ?CheckResult + public function checkMusl(): CheckResult { - $file = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); - if (file_exists($file)) { + if (SystemUtil::isMuslDist()) { return CheckResult::ok(); } - - // non-exist, need to recognize distro - $distro = SystemUtil::getOSRelease(); - return match ($distro['dist']) { - 'ubuntu', 'alpine', 'debian', 'rhel', 'almalinux' => CheckResult::fail('musl-libc is not installed on your system', 'fix-musl', [$distro]), - default => CheckResult::fail('musl-libc is not installed on your system'), - }; + $arch = arch2gnu(php_uname('m')); + $cross_compile_lib = "/usr/local/musl/{$arch}-linux-musl/lib/libc.a"; + $cross_compile_gcc = "/usr/local/musl/bin/{$arch}-linux-musl-gcc"; + $musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); + if (file_exists($musl_wrapper_lib) && file_exists($cross_compile_lib) && file_exists($cross_compile_gcc)) { + return CheckResult::ok(); + } + return CheckResult::fail('musl-libc is not installed on your system', 'fix-musl'); } + /** @noinspection PhpUnused */ /** - * @throws RuntimeException - * @noinspection PhpUnused + * @throws DownloaderException + * @throws FileSystemException + * @throws WrongUsageException */ #[AsFixItem('fix-musl')] - public function fixMusl(array $distro): bool + public function fixMusl(): bool { - $rhel_install = 'wget https://musl.libc.org/releases/musl-1.2.4.tar.gz && tar -zxvf musl-1.2.4.tar.gz && \ - rm -f musl-1.2.4.tar.gz && cd musl-1.2.4 && - if [[ ! "$PATH" =~ (^|:)"/usr/local/musl/bin"(:|$) ]]; then echo "export PATH=/usr/local/musl/bin:$PATH" >> ~/.bash_profile - fi && \ - ./configure --enable-wrapper=gcc && \ - make -j && make install && cd .. && rm -rf musl-1.2.4'; - $install_cmd = match ($distro['dist']) { - 'ubuntu', 'debian' => 'apt-get install musl musl-tools -y', - 'alpine' => 'apk add musl musl-utils musl-dev', - 'rhel' => $rhel_install, - 'almalinux' => $rhel_install, - default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'), - }; - $prefix = ''; - if (get_current_user() !== 'root') { - $prefix = 'sudo '; - logger()->warning('Current user is not root, using sudo for running command'); - } + $arch = arch2gnu(php_uname('m')); + $musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); + $cross_compile_lib = "/usr/local/musl/{$arch}-linux-musl/lib/libc.a"; + $cross_compile_gcc = "/usr/local/musl/bin/{$arch}-linux-musl-gcc"; + try { - shell(true)->exec($prefix . $install_cmd); + if (!file_exists(DOWNLOAD_PATH)) { + FileSystem::createDir(DOWNLOAD_PATH); + } + if (!file_exists($musl_wrapper_lib)) { + $this->installMuslWrapper(); + } + if (!file_exists($cross_compile_lib) || !file_exists($cross_compile_gcc)) { + $this->installMuslCrossMake(); + } + + $prefix = ''; + if (get_current_user() !== 'root') { + $prefix = 'sudo '; + logger()->warning('Current user is not root, using sudo for running command'); + } + $profile = '/etc/profile'; + if (file_exists('~/.bash_profile')) { + $profile = '~/.bash_profile'; + } elseif (file_exists('~/.profile')) { + $profile = '~/.profile'; + } + if (!file_exists($profile)) { + shell(true)->exec($prefix . 'touch ' . $profile); + } + if (!getenv('PATH') || !str_contains(getenv('PATH'), '/usr/local/musl/bin')) { + $fix_path = 'echo "export PATH=/usr/local/musl/bin:$PATH" >> ' . $profile . ' && export PATH=/usr/local/musl/bin:$PATH'; + shell(true)->exec($prefix . $fix_path); + } return true; } catch (RuntimeException) { return false; } } + + /** + * @throws DownloaderException + * @throws RuntimeException + * @throws FileSystemException + */ + public function installMuslWrapper(): void + { + $prefix = ''; + if (get_current_user() !== 'root') { + $prefix = 'sudo '; + logger()->warning('Current user is not root, using sudo for running command'); + } + $musl_source = [ + 'type' => 'url', + 'url' => 'https://musl.libc.org/releases/musl-1.2.4.tar.gz', + ]; + Downloader::downloadSource('musl-1.2.4', $musl_source); + FileSystem::extractSource('musl-1.2.4', DOWNLOAD_PATH . '/musl-1.2.4.tar.gz'); + $musl_gcc_install_cmd = 'cd ' . SOURCE_PATH . '/musl-1.2.4 && \ + ./configure --enable-wrapper=gcc && \ + make -j && make install'; + shell(true)->exec($prefix . $musl_gcc_install_cmd); + } + + /** + * @throws DownloaderException + * @throws RuntimeException + * @throws FileSystemException + */ + public function installMuslCrossMake(): void + { + $arch = arch2gnu(php_uname('m')); + $musl_compile_source = [ + 'type' => 'url', + 'url' => "https://musl.cc/{$arch}-linux-musl-cross.tgz", + ]; + Downloader::downloadSource('musl-compile', $musl_compile_source); + FileSystem::extractSource('musl-compile', DOWNLOAD_PATH . "/{$arch}-linux-musl-cross.tgz"); + shell(true)->exec('cp -rf ' . SOURCE_PATH . '/musl-compile/* /usr/local/musl'); + } } From 64dfb57366891de26324344d319cf62d42b8cdba Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 16 Oct 2023 14:13:44 +0200 Subject: [PATCH 237/296] don't add -liconv on linux (cannot find library when specified that way in extra_libs) --- src/SPC/builder/extension/iconv.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SPC/builder/extension/iconv.php b/src/SPC/builder/extension/iconv.php index 6e2df2e5..e3178144 100644 --- a/src/SPC/builder/extension/iconv.php +++ b/src/SPC/builder/extension/iconv.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\builder\macos\MacOSBuilder; use SPC\util\CustomExt; #[CustomExt('iconv')] @@ -13,6 +14,9 @@ class iconv extends Extension public function patchBeforeConfigure(): bool { // macOS need to link iconv dynamically, we add it to extra-libs + if (!$this->builder instanceof MacOSBuilder) { + return false; + } $extra_libs = $this->builder->getOption('extra-libs', ''); if (!str_contains($extra_libs, '-liconv')) { $extra_libs .= ' -liconv'; From a7265bf624c0ddda9da308c4a9bc460c64db1837 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 16 Oct 2023 14:14:19 +0200 Subject: [PATCH 238/296] add -static linker flag to libicu compilation --- src/SPC/builder/linux/library/icu.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php index 39125675..5a5f69f9 100644 --- a/src/SPC/builder/linux/library/icu.php +++ b/src/SPC/builder/linux/library/icu.php @@ -10,11 +10,13 @@ class icu extends LinuxLibraryBase protected function build(): void { - $root = BUILD_ROOT_PATH; - $cppflag = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"'; + $cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"'; + $cxxflags = 'CXXFLAGS="-std=c++11"'; + $ldflags = 'LDFLAGS="-static"'; shell()->cd($this->source_dir . '/source') ->exec( - "{$this->builder->configure_env} {$cppflag} ./runConfigureICU Linux " . + "{$this->builder->configure_env} {$cppflags} {$cxxflags} {$ldflags} " . + './runConfigureICU Linux ' . '--enable-static ' . '--disable-shared ' . '--with-data-packaging=static ' . @@ -25,7 +27,7 @@ class icu extends LinuxLibraryBase '--enable-tools=yes ' . '--enable-tests=no ' . '--enable-samples=no ' . - "--prefix={$root}" + '--prefix=' . BUILD_ROOT_PATH ) ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") From a4dc177621734fb5b836dbca851c326affe3768d Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 16 Oct 2023 19:26:29 +0200 Subject: [PATCH 239/296] install libxml2 and snappy into /lib instead of /lib64 --- src/SPC/builder/linux/library/libxml2.php | 13 +++++-------- src/SPC/builder/macos/library/libxml2.php | 19 ++++--------------- src/SPC/builder/traits/UnixBuilderTrait.php | 9 +++++---- src/SPC/builder/unix/library/snappy.php | 5 ++--- src/globals/defines.php | 2 +- 5 files changed, 17 insertions(+), 31 deletions(-) diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php index 9856f527..0c3b5437 100644 --- a/src/SPC/builder/linux/library/libxml2.php +++ b/src/SPC/builder/linux/library/libxml2.php @@ -19,22 +19,19 @@ class libxml2 extends LinuxLibraryBase public function build(): void { $enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF'; - // $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF'; + $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF'; $enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF'; FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( "{$this->builder->configure_env} " . ' cmake ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DCMAKE_BUILD_TYPE=Release ' . - '-DCMAKE_INSTALL_PREFIX=' . escapeshellarg(BUILD_ROOT_PATH) . ' ' . + "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIBS=OFF ' . - '-DCMAKE_INSTALL_BINDIR=' . escapeshellarg(BUILD_ROOT_PATH . '/bin') . ' ' . - '-DLIBXML2_WITH_ICONV=ON ' . '-DIconv_IS_BUILT_IN=OFF ' . + '-DLIBXML2_WITH_ICONV=ON ' . "-DLIBXML2_WITH_ZLIB={$enable_zlib} " . - '-DLIBXML2_WITH_ICU=OFF ' . + "-DLIBXML2_WITH_ICU={$enable_icu} " . "-DLIBXML2_WITH_LZMA={$enable_xz} " . '-DLIBXML2_WITH_PYTHON=OFF ' . '-DLIBXML2_WITH_PROGRAMS=OFF ' . @@ -42,6 +39,6 @@ class libxml2 extends LinuxLibraryBase '..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec('make install'); + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); } } diff --git a/src/SPC/builder/macos/library/libxml2.php b/src/SPC/builder/macos/library/libxml2.php index 1ebf0aa9..36f960ea 100644 --- a/src/SPC/builder/macos/library/libxml2.php +++ b/src/SPC/builder/macos/library/libxml2.php @@ -18,38 +18,27 @@ class libxml2 extends MacOSLibraryBase */ protected function build(): void { - // macOS need to link iconv dynamically, we add it to extra-libs - $extra_libs = $this->builder->getOption('extra-libs', ''); - if (!str_contains($extra_libs, '-liconv')) { - $extra_libs .= ' -liconv'; - } - $this->builder->setOption('extra-libs', $extra_libs); - $enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF'; - // $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF'; + $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF'; $enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF'; - [, , $destdir] = SEPARATED_PATH; - FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( "{$this->builder->configure_env} " . ' cmake ' . // '--debug-find ' . - '-DCMAKE_BUILD_TYPE=Release ' . + "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIBS=OFF ' . '-DLIBXML2_WITH_ICONV=ON ' . "-DLIBXML2_WITH_ZLIB={$enable_zlib} " . - '-DLIBXML2_WITH_ICU=OFF ' . + "-DLIBXML2_WITH_ICU={$enable_icu} " . "-DLIBXML2_WITH_LZMA={$enable_xz} " . '-DLIBXML2_WITH_PYTHON=OFF ' . '-DLIBXML2_WITH_PROGRAMS=OFF ' . '-DLIBXML2_WITH_TESTS=OFF ' . - "-DCMAKE_INSTALL_PREFIX={$destdir} " . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec('make install'); + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); } } diff --git a/src/SPC/builder/traits/UnixBuilderTrait.php b/src/SPC/builder/traits/UnixBuilderTrait.php index ce3795be..3af58426 100644 --- a/src/SPC/builder/traits/UnixBuilderTrait.php +++ b/src/SPC/builder/traits/UnixBuilderTrait.php @@ -145,12 +145,13 @@ trait UnixBuilderTrait */ public function makeCmakeArgs(): string { - [$lib, $include] = SEPARATED_PATH; $extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . $this->getOption('cc') . ' ' : ''; - return $extra . '-DCMAKE_BUILD_TYPE=Release ' . + return $extra . + '-DCMAKE_BUILD_TYPE=Release ' . '-DCMAKE_INSTALL_PREFIX=/ ' . - "-DCMAKE_INSTALL_LIBDIR={$lib} " . - "-DCMAKE_INSTALL_INCLUDEDIR={$include} " . + '-DCMAKE_INSTALL_BINDIR=/bin ' . + '-DCMAKE_INSTALL_LIBDIR=/lib ' . + '-DCMAKE_INSTALL_INCLUDEDIR=/include ' . "-DCMAKE_TOOLCHAIN_FILE={$this->cmake_toolchain_file}"; } diff --git a/src/SPC/builder/unix/library/snappy.php b/src/SPC/builder/unix/library/snappy.php index 112cf5ed..18f5e78c 100644 --- a/src/SPC/builder/unix/library/snappy.php +++ b/src/SPC/builder/unix/library/snappy.php @@ -22,13 +22,12 @@ trait snappy ->exec( "{$this->builder->configure_env} cmake " . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DCMAKE_BUILD_TYPE=Release ' . - '-DCMAKE_INSTALL_PREFIX=' . escapeshellarg(BUILD_ROOT_PATH) . ' ' . + "{$this->builder->makeCmakeArgs()} " . '-DSNAPPY_BUILD_TESTS=OFF ' . '-DSNAPPY_BUILD_BENCHMARKS=OFF ' . '../..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec('make install'); + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); } } diff --git a/src/globals/defines.php b/src/globals/defines.php index 1e5aa085..3415f5c6 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -13,8 +13,8 @@ define('START_TIME', microtime(true)); define('BUILD_ROOT_PATH', is_string($a = getenv('BUILD_ROOT_PATH')) ? $a : (WORKING_DIR . '/buildroot')); define('SOURCE_PATH', is_string($a = getenv('SOURCE_PATH')) ? $a : (WORKING_DIR . '/source')); define('DOWNLOAD_PATH', is_string($a = getenv('DOWNLOAD_PATH')) ? $a : (WORKING_DIR . '/downloads')); +define('BUILD_BIN_PATH', is_string($a = getenv('INSTALL_BIN_PATH')) ? $a : (BUILD_ROOT_PATH . '/bin')); define('BUILD_LIB_PATH', is_string($a = getenv('INSTALL_LIB_PATH')) ? $a : (BUILD_ROOT_PATH . '/lib')); -const BUILD_DEPS_PATH = BUILD_ROOT_PATH; define('BUILD_INCLUDE_PATH', is_string($a = getenv('INSTALL_INCLUDE_PATH')) ? $a : (BUILD_ROOT_PATH . '/include')); define('SEPARATED_PATH', [ '/' . pathinfo(BUILD_LIB_PATH)['basename'], // lib From a83a457905fbb4a556007be8b7c7508dd769d24d Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 16 Oct 2023 21:03:26 +0200 Subject: [PATCH 240/296] fix pgsql build on non-alpine --- src/SPC/builder/linux/library/libxml2.php | 6 ++++++ src/SPC/builder/unix/library/postgresql.php | 17 +++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php index 0c3b5437..4095ee56 100644 --- a/src/SPC/builder/linux/library/libxml2.php +++ b/src/SPC/builder/linux/library/libxml2.php @@ -40,5 +40,11 @@ class libxml2 extends LinuxLibraryBase ) ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + + FileSystem::replaceFileStr( + BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc', + '-licudata -licui18n -licuuc', + '-licui18n -licuuc -licudata' + ); } } diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index b02f46a7..758e8a87 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -20,7 +20,12 @@ trait postgresql $builddir = BUILD_ROOT_PATH; $env = $this->builder->configure_env; $envs = $env; - $packages = 'openssl zlib readline libxml-2.0'; // icu-uc icu-io icu-i18n libzstd + $packages = 'openssl zlib readline libxml-2.0 zlib'; + foreach (['zstd', 'ldap', 'pam', 'libxslt'] as $lib) { + if ($this->getBuilder()->getLib($lib)) { + $packages .= ' ' . $lib; + } + } $pkgconfig_executable = $builddir . '/bin/pkg-config'; $output = shell()->execWithResult($env . " {$pkgconfig_executable} --cflags-only-I --static " . $packages); @@ -36,7 +41,7 @@ trait postgresql $output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-l --static " . $packages); if (!empty($output[1][0])) { $libs = $output[1][0]; - $envs .= " LIBS=\"{$libs}\" "; + $envs .= " LIBS=\"{$libs} -lstdc++\" "; } FileSystem::resetDir($this->source_dir . '/build'); @@ -44,7 +49,7 @@ trait postgresql # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile shell()->cd($this->source_dir . '/build') ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile') - ->exec(' sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib') + ->exec('sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib') ->exec('sed -i.backup "441 s/^/#$/" ../src/Makefile.shlib'); // configure @@ -59,12 +64,12 @@ trait postgresql '--with-libxml ' . ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . - '--without-libxslt ' . + ($this->builder->getLib('pam') ? '--with-pam ' : '--without-pam ') . + ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . + ($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') . '--without-lz4 ' . - '--without-zstd ' . '--without-perl ' . '--without-python ' . - '--without-pam ' . '--without-bonjour ' . '--without-tcl ' ); From da1cbeb79cf324626f4bff54fd32232ad8d866fa Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Oct 2023 00:52:49 +0200 Subject: [PATCH 241/296] introduce library_path and ld_library_path options to linuxbuilder (some libs require it to load -lstdc++) --- config/lib.json | 8 +++++--- src/SPC/builder/linux/LinuxBuilder.php | 6 +++++- src/SPC/builder/unix/library/libxslt.php | 17 ++++++++++++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/config/lib.json b/config/lib.json index 62ea0100..c4102323 100644 --- a/config/lib.json +++ b/config/lib.json @@ -434,7 +434,10 @@ "readline" ], "lib-suggests": [ - "icu" + "icu", + "libxslt", + "ldap", + "zstd" ] }, "pthreads4w": { @@ -464,10 +467,9 @@ "libsnappy.a" ], "headers-unix": [ + "snappy.h", "snappy-c.h", "snappy-sinksource.h", - "snappy.h", - "snappy-stubs-internal.h", "snappy-stubs-public.h" ], "lib-depends": [ diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 5c077073..d084d131 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -41,10 +41,14 @@ class LinuxBuilder extends BuilderBase if (SystemUtil::isMuslDist()) { $this->setOptionIfNotExist('cc', 'gcc'); $this->setOptionIfNotExist('cxx', 'g++'); + $this->setOptionIfNotExist('library_path', ''); + $this->setOptionIfNotExist('ld_library_path', ''); } else { $arch = arch2gnu(php_uname('m')); $this->setOptionIfNotExist('cc', "{$arch}-linux-musl-gcc"); $this->setOptionIfNotExist('cxx', "{$arch}-linux-musl-g++"); + $this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); + $this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); } // set arch (default: current) $this->setOptionIfNotExist('arch', php_uname('m')); @@ -174,7 +178,7 @@ class LinuxBuilder extends BuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec( - (!SystemUtil::isMuslDist() ? "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib " : '') . + "{$this->getOption('ld_library_path')} " . './configure ' . '--prefix= ' . '--with-valgrind=no ' . diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index d9e2d030..847c30e0 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -4,20 +4,35 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\builder\linux\library\LinuxLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; trait libxslt { /** * @throws FileSystemException * @throws RuntimeException + * @throws WrongUsageException */ protected function build(): void { + $required_libs = ''; + foreach ($this->getDependencies() as $dep) { + if ($dep instanceof LinuxLibraryBase) { + $required_libs .= ' ' . $dep->getStaticLibFiles(); + } + } shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + "{$this->builder->configure_env} " . + 'CFLAGS="-I' . BUILD_INCLUDE_PATH . '" ' . + "{$this->builder->getOption('library_path')} " . + "{$this->builder->getOption('ld_library_path')} " . + 'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' . + "LIBS='{$required_libs} -lstdc++' " . + './configure ' . '--enable-static --disable-shared ' . '--without-python ' . '--without-mem-debug ' . From 0007043f4a483a07ccb53e45e3c8e172e833ade2 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Oct 2023 19:37:13 +0200 Subject: [PATCH 242/296] fix imagemagick and postgresql builds with different libs --- src/SPC/builder/extension/imagick.php | 7 ++-- src/SPC/builder/unix/library/imagemagick.php | 36 ++++++++++++-------- src/SPC/builder/unix/library/postgresql.php | 17 ++++++--- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index 217b7aa9..41a1c20e 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -12,11 +12,10 @@ class imagick extends Extension { public function patchBeforeBuildconf(): bool { - // linux need to link library manually, we add it to extra-libs + // imagick may call omp_pause_all which requires -lgomp $extra_libs = $this->builder->getOption('extra-libs', ''); - if (!str_contains($extra_libs, 'libMagickCore')) { - $extra_libs .= ' /usr/lib/libMagick++-7.Q16HDRI.a /usr/lib/libMagickCore-7.Q16HDRI.a /usr/lib/libMagickWand-7.Q16HDRI.a'; - } + $libf = BUILD_LIB_PATH; + $extra_libs .= " {$libf}/libMagick++-7.Q16HDRI.a {$libf}/libMagickWand-7.Q16HDRI.a {$libf}/libMagickCore-7.Q16HDRI.a -lgomp "; $this->builder->setOption('extra-libs', $extra_libs); return true; } diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index f1530b76..f33aa87d 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -16,23 +16,31 @@ trait imagemagick */ protected function build(): void { - $extra = '--without-jxl --without-xml --without-zstd --without-x --disable-openmp '; - // libzip support - $extra .= $this->builder->getLib('libzip') ? '--with-zip ' : '--without-zip '; - // jpeg support - $extra .= $this->builder->getLib('libjpeg') ? '--with-jpeg ' : ''; - // png support - $extra .= $this->builder->getLib('libpng') ? '--with-png ' : ''; - // webp support - $extra .= $this->builder->getLib('libwebp') ? '--with-webp ' : ''; - // zstd support - // $extra .= $this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd '; - // freetype support - $extra .= $this->builder->getLib('freetype') ? '--with-freetype ' : '--without-freetype '; + $extra = '--without-jxl --without-x --disable-openmp '; + $required_libs = ''; + $optional_libs = [ + 'libzip' => 'zip', + 'libjpeg' => 'jpeg', + 'libpng' => 'png', + 'libwebp' => 'webp', + 'libxml2' => 'xml', + 'zlib' => 'zlib', + 'zstd' => 'zstd', + 'freetype' => 'freetype', + ]; + foreach ($optional_libs as $lib => $option) { + $extra .= $this->builder->getLib($lib) ? "--with-{$option} " : "--without-{$option} "; + if ($this->builder->getLib($lib)) { + $required_libs .= ' ' . $this->builder->getLib($lib)->getStaticLibFiles(); + } + } shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + "{$this->builder->configure_env} " . + 'LDFLAGS="-static" ' . + "LIBS='{$required_libs}' " . + './configure ' . '--enable-static --disable-shared ' . $extra . '--prefix=' diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 758e8a87..eaf6710e 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -21,9 +21,16 @@ trait postgresql $env = $this->builder->configure_env; $envs = $env; $packages = 'openssl zlib readline libxml-2.0 zlib'; - foreach (['zstd', 'ldap', 'pam', 'libxslt'] as $lib) { + $optional_packages = [ + 'zstd' => 'libzstd', + 'ldap' => 'ldap', + 'libpam' => 'libpam', + 'libxslt' => 'libxslt', + 'icu' => 'icu-i18n', + ]; + foreach ($optional_packages as $lib => $pkg) { if ($this->getBuilder()->getLib($lib)) { - $packages .= ' ' . $lib; + $packages .= ' ' . $pkg; } } @@ -62,11 +69,11 @@ trait postgresql '--with-ssl=openssl ' . '--with-readline ' . '--with-libxml ' . - ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . - ($this->builder->getLib('pam') ? '--with-pam ' : '--without-pam ') . - ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . + ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . + ($this->builder->getLib('libpam') ? '--with-pam ' : '--without-pam ') . ($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') . + ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . '--without-lz4 ' . '--without-perl ' . '--without-python ' . From 6dfd35348f03fa3e9c4c60c7bf89a9c3b38c2a64 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Oct 2023 20:16:41 +0200 Subject: [PATCH 243/296] fix order of imagick libs --- config/lib.json | 4 ++-- src/SPC/builder/extension/imagick.php | 5 ++--- src/SPC/builder/unix/library/imagemagick.php | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/lib.json b/config/lib.json index c4102323..0dd26ed5 100644 --- a/config/lib.json +++ b/config/lib.json @@ -122,8 +122,8 @@ "source": "imagemagick", "static-libs-unix": [ "libMagick++-7.Q16HDRI.a", - "libMagickCore-7.Q16HDRI.a", - "libMagickWand-7.Q16HDRI.a" + "libMagickWand-7.Q16HDRI.a", + "libMagickCore-7.Q16HDRI.a" ], "lib-depends": [ "zlib", diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index 41a1c20e..ef965d58 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -10,12 +10,11 @@ use SPC\util\CustomExt; #[CustomExt('imagick')] class imagick extends Extension { - public function patchBeforeBuildconf(): bool + public function patchBeforeMake(): bool { // imagick may call omp_pause_all which requires -lgomp $extra_libs = $this->builder->getOption('extra-libs', ''); - $libf = BUILD_LIB_PATH; - $extra_libs .= " {$libf}/libMagick++-7.Q16HDRI.a {$libf}/libMagickWand-7.Q16HDRI.a {$libf}/libMagickCore-7.Q16HDRI.a -lgomp "; + $extra_libs .= ' -lgomp '; $this->builder->setOption('extra-libs', $extra_libs); return true; } diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index f33aa87d..7e291e8c 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\builder\linux\library\LinuxLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; @@ -30,7 +31,7 @@ trait imagemagick ]; foreach ($optional_libs as $lib => $option) { $extra .= $this->builder->getLib($lib) ? "--with-{$option} " : "--without-{$option} "; - if ($this->builder->getLib($lib)) { + if ($this->builder->getLib($lib) instanceof LinuxLibraryBase) { $required_libs .= ' ' . $this->builder->getLib($lib)->getStaticLibFiles(); } } From 75b9d66698cd07fec005c76048fe51a43a556413 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Oct 2023 20:18:02 +0200 Subject: [PATCH 244/296] use ar and ld from musl-tools (uses gold-ld and can handle wrong lib order) --- src/SPC/builder/linux/LinuxBuilder.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index d084d131..00a8ff29 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -41,12 +41,16 @@ class LinuxBuilder extends BuilderBase if (SystemUtil::isMuslDist()) { $this->setOptionIfNotExist('cc', 'gcc'); $this->setOptionIfNotExist('cxx', 'g++'); + $this->setOptionIfNotExist('ar', 'ar'); + $this->setOptionIfNotExist('ld', 'ld'); $this->setOptionIfNotExist('library_path', ''); $this->setOptionIfNotExist('ld_library_path', ''); } else { $arch = arch2gnu(php_uname('m')); $this->setOptionIfNotExist('cc', "{$arch}-linux-musl-gcc"); $this->setOptionIfNotExist('cxx', "{$arch}-linux-musl-g++"); + $this->setOptionIfNotExist('ar', "{$arch}-linux-musl-ar"); + $this->setOptionIfNotExist('ld', "{$arch}-linux-musl-ld"); $this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); $this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); } @@ -79,6 +83,8 @@ class LinuxBuilder extends BuilderBase ...$vars, 'CC' => $this->getOption('cc'), 'CXX' => $this->getOption('cxx'), + 'AR' => $this->getOption('ar'), + 'LD' => $this->getOption('ld'), 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), ]); // cross-compiling is not supported yet @@ -147,6 +153,8 @@ class LinuxBuilder extends BuilderBase $envs = $this->pkgconf_env . ' ' . SystemUtil::makeEnvVarString([ 'CC' => $this->getOption('cc'), 'CXX' => $this->getOption('cxx'), + 'AR' => $this->getOption('ar'), + 'LD' => $this->getOption('ld'), 'CFLAGS' => $cflags, 'LIBS' => '-ldl -lpthread', 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), @@ -174,7 +182,6 @@ class LinuxBuilder extends BuilderBase $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; - $arch = arch2gnu(php_uname('m')); shell()->cd(SOURCE_PATH . '/php-src') ->exec( @@ -237,7 +244,7 @@ class LinuxBuilder extends BuilderBase public function buildCli(string $use_lld): void { $vars = SystemUtil::makeEnvVarString([ - 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), + 'EXTRA_CFLAGS' => '-g -Os -fno-ident -fPIE ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", ]); @@ -270,7 +277,7 @@ class LinuxBuilder extends BuilderBase $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; $vars = SystemUtil::makeEnvVarString([ - 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $enable_fake_cli, + 'EXTRA_CFLAGS' => '-g -Os -fno-ident -fPIE ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $enable_fake_cli, 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), 'EXTRA_LDFLAGS_PROGRAM' => "{$cflags} {$use_lld} -all-static", ]); @@ -298,7 +305,7 @@ class LinuxBuilder extends BuilderBase public function buildFpm(string $use_lld): void { $vars = SystemUtil::makeEnvVarString([ - 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), + 'EXTRA_CFLAGS' => '-g -Os -fno-ident -fPIE ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", ]); @@ -317,7 +324,7 @@ class LinuxBuilder extends BuilderBase public function buildEmbed(string $use_lld): void { $vars = SystemUtil::makeEnvVarString([ - 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), + 'EXTRA_CFLAGS' => '-g -Os -fno-ident -fPIE ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", ]); From ca1189b6cab71f117f35c3991d80f4fc27f87b28 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Oct 2023 18:28:36 +0200 Subject: [PATCH 245/296] use ld.gold (revert this if you think this doesn't add benefit) --- src/SPC/builder/linux/LinuxBuilder.php | 4 ++-- src/SPC/doctor/item/LinuxToolCheckList.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 00a8ff29..92c760ed 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -42,7 +42,7 @@ class LinuxBuilder extends BuilderBase $this->setOptionIfNotExist('cc', 'gcc'); $this->setOptionIfNotExist('cxx', 'g++'); $this->setOptionIfNotExist('ar', 'ar'); - $this->setOptionIfNotExist('ld', 'ld'); + $this->setOptionIfNotExist('ld', 'ld.gold'); $this->setOptionIfNotExist('library_path', ''); $this->setOptionIfNotExist('ld_library_path', ''); } else { @@ -50,7 +50,7 @@ class LinuxBuilder extends BuilderBase $this->setOptionIfNotExist('cc', "{$arch}-linux-musl-gcc"); $this->setOptionIfNotExist('cxx', "{$arch}-linux-musl-g++"); $this->setOptionIfNotExist('ar', "{$arch}-linux-musl-ar"); - $this->setOptionIfNotExist('ld', "{$arch}-linux-musl-ld"); + $this->setOptionIfNotExist('ld', "/usr/local/musl/{$arch}-linux-musl/bin/ld.gold"); $this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); $this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); } diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 897d4ef4..ee9394f3 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -20,7 +20,7 @@ class LinuxToolCheckList 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'gcc', - 'g++', 'patch', + 'g++', 'patch', 'binutils-gold', ]; public const TOOLS_DEBIAN = [ From b6409bded448d6c906ee5b198210d7d0e603e7b5 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 22 Oct 2023 16:55:02 +0800 Subject: [PATCH 246/296] optimize install musl wrapper and cross make function --- src/SPC/doctor/item/LinuxMuslCheck.php | 44 +++++++++----------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index c65326ab..249d992c 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -61,25 +61,7 @@ class LinuxMuslCheck if (!file_exists($cross_compile_lib) || !file_exists($cross_compile_gcc)) { $this->installMuslCrossMake(); } - - $prefix = ''; - if (get_current_user() !== 'root') { - $prefix = 'sudo '; - logger()->warning('Current user is not root, using sudo for running command'); - } - $profile = '/etc/profile'; - if (file_exists('~/.bash_profile')) { - $profile = '~/.bash_profile'; - } elseif (file_exists('~/.profile')) { - $profile = '~/.profile'; - } - if (!file_exists($profile)) { - shell(true)->exec($prefix . 'touch ' . $profile); - } - if (!getenv('PATH') || !str_contains(getenv('PATH'), '/usr/local/musl/bin')) { - $fix_path = 'echo "export PATH=/usr/local/musl/bin:$PATH" >> ' . $profile . ' && export PATH=/usr/local/musl/bin:$PATH'; - shell(true)->exec($prefix . $fix_path); - } + // TODO: add path using putenv instead of editing /etc/profile return true; } catch (RuntimeException) { return false; @@ -98,32 +80,36 @@ class LinuxMuslCheck $prefix = 'sudo '; logger()->warning('Current user is not root, using sudo for running command'); } + $musl_version_name = 'musl-1.2.4'; $musl_source = [ 'type' => 'url', - 'url' => 'https://musl.libc.org/releases/musl-1.2.4.tar.gz', + 'url' => "https://musl.libc.org/releases/{$musl_version_name}.tar.gz", ]; - Downloader::downloadSource('musl-1.2.4', $musl_source); - FileSystem::extractSource('musl-1.2.4', DOWNLOAD_PATH . '/musl-1.2.4.tar.gz'); - $musl_gcc_install_cmd = 'cd ' . SOURCE_PATH . '/musl-1.2.4 && \ - ./configure --enable-wrapper=gcc && \ - make -j && make install'; - shell(true)->exec($prefix . $musl_gcc_install_cmd); + Downloader::downloadSource($musl_version_name, $musl_source); + FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); + shell(true)->cd(SOURCE_PATH . "/{$musl_version_name}") + ->exec('./configure --enable-wrapper=gcc') + ->exec('make -j') + ->exec("{$prefix}make install"); } /** * @throws DownloaderException - * @throws RuntimeException * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ public function installMuslCrossMake(): void { $arch = arch2gnu(php_uname('m')); $musl_compile_source = [ 'type' => 'url', - 'url' => "https://musl.cc/{$arch}-linux-musl-cross.tgz", + 'url' => "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/{$arch}-musl-toolchain.tgz", ]; + logger()->info('Downloading ' . $musl_compile_source['url']); Downloader::downloadSource('musl-compile', $musl_compile_source); - FileSystem::extractSource('musl-compile', DOWNLOAD_PATH . "/{$arch}-linux-musl-cross.tgz"); + logger()->info('Extracting musl-cross'); + FileSystem::extractSource('musl-compile', DOWNLOAD_PATH . "/{$arch}-musl-toolchain.tgz"); shell(true)->exec('cp -rf ' . SOURCE_PATH . '/musl-compile/* /usr/local/musl'); } } From d56c0608632e68f34167277862529e773f7b648b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 22 Oct 2023 17:15:12 +0800 Subject: [PATCH 247/296] remove `--enable-wrapper=gcc` for fix-musl --- src/SPC/doctor/item/LinuxMuslCheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index 249d992c..cbc27f0f 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -88,7 +88,7 @@ class LinuxMuslCheck Downloader::downloadSource($musl_version_name, $musl_source); FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); shell(true)->cd(SOURCE_PATH . "/{$musl_version_name}") - ->exec('./configure --enable-wrapper=gcc') + ->exec('./configure') ->exec('make -j') ->exec("{$prefix}make install"); } From 6cc7e6cff6d3a2e9c93eae9616027ab8a4c7459c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 22 Oct 2023 17:24:01 +0800 Subject: [PATCH 248/296] add comment for hard-coded musl version --- src/SPC/doctor/item/LinuxMuslCheck.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index cbc27f0f..80276ea1 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -80,6 +80,7 @@ class LinuxMuslCheck $prefix = 'sudo '; logger()->warning('Current user is not root, using sudo for running command'); } + // The hardcoded version here is to be consistent with the version compiled by `musl-cross-toolchain`. $musl_version_name = 'musl-1.2.4'; $musl_source = [ 'type' => 'url', From c800a53f77e1f2ec29263ce3a1065dda7779a3c1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 22 Oct 2023 12:37:13 +0800 Subject: [PATCH 249/296] separate `--from-zip` in download command --- src/SPC/command/DownloadCommand.php | 82 ++++++++++++++++------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index e6588a41..011a5373 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -33,12 +33,17 @@ class DownloadCommand extends BaseCommand $this->addOption('all', 'A', null, 'Fetch all sources that static-php-cli needed'); $this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"'); $this->addOption('from-zip', 'Z', InputOption::VALUE_REQUIRED, 'Fetch from zip archive'); + $this->addOption('by-extensions', 'e', InputOption::VALUE_REQUIRED, 'Fetch by extensions, e.g "openssl,mbstring"'); } public function initialize(InputInterface $input, OutputInterface $output): void { - // --all 等于 "" "",也就是所有东西都要下载 - if ($input->getOption('all') || $input->getOption('clean') || $input->getOption('from-zip')) { + if ( + $input->getOption('all') + || $input->getOption('clean') + || $input->getOption('from-zip') + || $input->getOption('by-extensions') + ) { $input->setArgument('sources', ''); } parent::initialize($input, $output); @@ -73,40 +78,7 @@ class DownloadCommand extends BaseCommand // --from-zip if ($path = $this->getOption('from-zip')) { - if (!file_exists($path)) { - logger()->critical('File ' . $path . ' not exist or not a zip archive.'); - return static::FAILURE; - } - // remove old download files first - if (is_dir(DOWNLOAD_PATH)) { - logger()->warning('You are doing some operations that not recoverable: removing directories below'); - logger()->warning(DOWNLOAD_PATH); - logger()->alert('I will remove these dir after 5 seconds !'); - sleep(5); - f_passthru((PHP_OS_FAMILY === 'Windows' ? 'rmdir /s /q ' : 'rm -rf ') . DOWNLOAD_PATH); - } - // unzip command check - if (PHP_OS_FAMILY !== 'Windows' && !$this->findCommand('unzip')) { - logger()->critical('Missing unzip command, you need to install it first !'); - logger()->critical('You can use "bin/spc doctor" command to check and install required tools'); - return static::FAILURE; - } - // create downloads - try { - if (PHP_OS_FAMILY !== 'Windows') { - f_passthru('mkdir ' . DOWNLOAD_PATH . ' && cd ' . DOWNLOAD_PATH . ' && unzip ' . escapeshellarg($path)); - } - // Windows TODO - - if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { - throw new RuntimeException('.lock.json not exist in "downloads/"'); - } - } catch (RuntimeException $e) { - logger()->critical('Extract failed: ' . $e->getMessage()); - return static::FAILURE; - } - logger()->info('Extract success'); - return static::SUCCESS; + return $this->downloadFromZip($path); } // Define PHP major version @@ -177,4 +149,42 @@ class DownloadCommand extends BaseCommand logger()->info('Download complete, used ' . $time . ' s !'); return static::SUCCESS; } + + private function downloadFromZip(string $path): int + { + if (!file_exists($path)) { + logger()->critical('File ' . $path . ' not exist or not a zip archive.'); + return static::FAILURE; + } + // remove old download files first + if (is_dir(DOWNLOAD_PATH)) { + logger()->warning('You are doing some operations that not recoverable: removing directories below'); + logger()->warning(DOWNLOAD_PATH); + logger()->alert('I will remove these dir after 5 seconds !'); + sleep(5); + f_passthru((PHP_OS_FAMILY === 'Windows' ? 'rmdir /s /q ' : 'rm -rf ') . DOWNLOAD_PATH); + } + // unzip command check + if (PHP_OS_FAMILY !== 'Windows' && !$this->findCommand('unzip')) { + logger()->critical('Missing unzip command, you need to install it first !'); + logger()->critical('You can use "bin/spc doctor" command to check and install required tools'); + return static::FAILURE; + } + // create downloads + try { + if (PHP_OS_FAMILY !== 'Windows') { + f_passthru('mkdir ' . DOWNLOAD_PATH . ' && cd ' . DOWNLOAD_PATH . ' && unzip ' . escapeshellarg($path)); + } + // Windows TODO + + if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { + throw new RuntimeException('.lock.json not exist in "downloads/"'); + } + } catch (RuntimeException $e) { + logger()->critical('Extract failed: ' . $e->getMessage()); + return static::FAILURE; + } + logger()->info('Extract success'); + return static::SUCCESS; + } } From 4e9b8980d060f57a9b67d5d426af788428476955 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 22 Oct 2023 16:35:15 +0800 Subject: [PATCH 250/296] add `--by-extensions` and `--without-suggests` options for download command --- src/SPC/command/DownloadCommand.php | 40 ++++++++++++++++++++++++++--- src/SPC/util/DependencyUtil.php | 37 ++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 011a5373..dfad36fe 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -8,8 +8,10 @@ use SPC\builder\traits\UnixSystemUtilTrait; use SPC\exception\DownloaderException; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\Downloader; +use SPC\util\DependencyUtil; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -34,6 +36,7 @@ class DownloadCommand extends BaseCommand $this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"'); $this->addOption('from-zip', 'Z', InputOption::VALUE_REQUIRED, 'Fetch from zip archive'); $this->addOption('by-extensions', 'e', InputOption::VALUE_REQUIRED, 'Fetch by extensions, e.g "openssl,mbstring"'); + $this->addOption('without-suggests', null, null, 'Do not fetch suggested sources when using --by-extensions'); } public function initialize(InputInterface $input, OutputInterface $output): void @@ -105,10 +108,17 @@ class DownloadCommand extends BaseCommand Config::$source['openssl']['regex'] = '/href="(?openssl-(?1.[^"]+)\.tar\.gz)\"/'; } - // get source list that will be downloaded - $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); - if (empty($sources)) { - $sources = array_keys(Config::getSources()); + // --by-extensions + if ($by_ext = $this->getOption('by-extensions')) { + $ext = array_map('trim', array_filter(explode(',', $by_ext))); + $sources = $this->calculateSourcesByExt($ext, !$this->getOption('without-suggests')); + array_unshift($sources, 'php-src', 'micro', 'pkg-config'); + } else { + // get source list that will be downloaded + $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); + if (empty($sources)) { + $sources = array_keys(Config::getSources()); + } } $chosen_sources = $sources; @@ -187,4 +197,26 @@ class DownloadCommand extends BaseCommand logger()->info('Extract success'); return static::SUCCESS; } + + /** + * Calculate the sources by extensions + * + * @param array $extensions extension list + * @throws FileSystemException + * @throws WrongUsageException + */ + private function calculateSourcesByExt(array $extensions, bool $include_suggests = true): array + { + [$extensions, $libraries] = $include_suggests ? DependencyUtil::getAllExtLibsByDeps($extensions) : DependencyUtil::getExtLibsByDeps($extensions); + $sources = []; + foreach ($extensions as $extension) { + if (Config::getExt($extension, 'type') === 'external') { + $sources[] = Config::getExt($extension, 'source'); + } + } + foreach ($libraries as $library) { + $sources[] = Config::getLib($library, 'source'); + } + return array_values(array_unique($sources)); + } } diff --git a/src/SPC/util/DependencyUtil.php b/src/SPC/util/DependencyUtil.php index ba0d839c..4e0b74b1 100644 --- a/src/SPC/util/DependencyUtil.php +++ b/src/SPC/util/DependencyUtil.php @@ -99,6 +99,43 @@ class DependencyUtil return $final; } + public static function getAllExtLibsByDeps(array $exts): array + { + $sorted = []; + $visited = []; + $not_included_exts = []; + foreach ($exts as $ext) { + if (!isset($visited[$ext])) { + self::visitExtAllDeps($ext, $visited, $sorted); + } + } + $libs = []; + foreach ($sorted as $ext) { + if (!in_array($ext, $exts)) { + $not_included_exts[] = $ext; + } + foreach (array_merge(Config::getExt($ext, 'lib-depends', []), Config::getExt($ext, 'lib-suggests', [])) as $dep) { + if (!in_array($dep, $libs)) { + $libs[] = $dep; + } + } + } + return [$sorted, self::getAllLibsByDeps($libs), $not_included_exts]; + } + + public static function getAllLibsByDeps(array $libs): array + { + $sorted = []; + $visited = []; + + foreach ($libs as $lib) { + if (!isset($visited[$lib])) { + self::visitLibAllDeps($lib, $visited, $sorted); + } + } + return $sorted; + } + /** * @throws FileSystemException * @throws RuntimeException From 8191444fe9b2a557ff9e12815ebffed862fcf328 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 22 Oct 2023 21:33:09 +0800 Subject: [PATCH 251/296] refactor musl tool doctor --- src/SPC/doctor/item/LinuxMuslCheck.php | 137 ++++++++++++------------- src/SPC/store/Downloader.php | 5 +- src/SPC/store/FileSystem.php | 3 + 3 files changed, 75 insertions(+), 70 deletions(-) diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index 80276ea1..d4bc2c8f 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -18,23 +18,68 @@ use SPC\store\FileSystem; class LinuxMuslCheck { /** @noinspection PhpUnused */ - /** - * @throws WrongUsageException - */ - #[AsCheckItem('if musl-libc is installed', limit_os: 'Linux')] + #[AsCheckItem('if musl-wrapper is installed', limit_os: 'Linux', level: 800)] public function checkMusl(): CheckResult { if (SystemUtil::isMuslDist()) { + return CheckResult::ok('musl-based distro, skipped'); + } + + $musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); + if (file_exists($musl_wrapper_lib)) { return CheckResult::ok(); } + return CheckResult::fail('musl-wrapper is not installed on your system', 'fix-musl-wrapper'); + } + + #[AsCheckItem('if musl-cross-make is installed', limit_os: 'Linux', level: 799)] + public function checkMuslCrossMake(): CheckResult + { + if (SystemUtil::isMuslDist()) { + return CheckResult::ok('musl-based distro, skipped'); + } $arch = arch2gnu(php_uname('m')); $cross_compile_lib = "/usr/local/musl/{$arch}-linux-musl/lib/libc.a"; $cross_compile_gcc = "/usr/local/musl/bin/{$arch}-linux-musl-gcc"; - $musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); - if (file_exists($musl_wrapper_lib) && file_exists($cross_compile_lib) && file_exists($cross_compile_gcc)) { + if (file_exists($cross_compile_lib) && file_exists($cross_compile_gcc)) { return CheckResult::ok(); } - return CheckResult::fail('musl-libc is not installed on your system', 'fix-musl'); + return CheckResult::fail('musl-cross-make is not installed on your system', 'fix-musl-cross-make'); + } + + /** @noinspection PhpUnused */ + /** + * @throws DownloaderException + * @throws FileSystemException + */ + #[AsFixItem('fix-musl-wrapper')] + public function fixMusl(): bool + { + try { + $prefix = ''; + if (get_current_user() !== 'root') { + $prefix = 'sudo '; + logger()->warning('Current user is not root, using sudo for running command'); + } + // The hardcoded version here is to be consistent with the version compiled by `musl-cross-toolchain`. + $musl_version_name = 'musl-1.2.4'; + $musl_source = [ + 'type' => 'url', + 'url' => "https://musl.libc.org/releases/{$musl_version_name}.tar.gz", + ]; + logger()->info('Downloading ' . $musl_source['url']); + Downloader::downloadSource($musl_version_name, $musl_source); + FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); + logger()->info('Installing musl wrapper'); + shell(true)->cd(SOURCE_PATH . "/{$musl_version_name}") + ->exec('./configure') + ->exec('make -j') + ->exec("{$prefix}make install"); + // TODO: add path using putenv instead of editing /etc/profile + return true; + } catch (RuntimeException) { + return false; + } } /** @noinspection PhpUnused */ @@ -43,74 +88,28 @@ class LinuxMuslCheck * @throws FileSystemException * @throws WrongUsageException */ - #[AsFixItem('fix-musl')] - public function fixMusl(): bool + #[AsFixItem('fix-musl-cross-make')] + public function fixMuslCrossMake(): bool { - $arch = arch2gnu(php_uname('m')); - $musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); - $cross_compile_lib = "/usr/local/musl/{$arch}-linux-musl/lib/libc.a"; - $cross_compile_gcc = "/usr/local/musl/bin/{$arch}-linux-musl-gcc"; - try { - if (!file_exists(DOWNLOAD_PATH)) { - FileSystem::createDir(DOWNLOAD_PATH); + $prefix = ''; + if (get_current_user() !== 'root') { + $prefix = 'sudo '; + logger()->warning('Current user is not root, using sudo for running command'); } - if (!file_exists($musl_wrapper_lib)) { - $this->installMuslWrapper(); - } - if (!file_exists($cross_compile_lib) || !file_exists($cross_compile_gcc)) { - $this->installMuslCrossMake(); - } - // TODO: add path using putenv instead of editing /etc/profile + $arch = arch2gnu(php_uname('m')); + $musl_compile_source = [ + 'type' => 'url', + 'url' => "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/{$arch}-musl-toolchain.tgz", + ]; + logger()->info('Downloading ' . $musl_compile_source['url']); + Downloader::downloadSource('musl-compile', $musl_compile_source); + logger()->info('Extracting musl-cross'); + FileSystem::extractSource('musl-compile', DOWNLOAD_PATH . "/{$arch}-musl-toolchain.tgz"); + shell(true)->exec($prefix . 'cp -rf ' . SOURCE_PATH . '/musl-compile/* /usr/local/musl'); return true; } catch (RuntimeException) { return false; } } - - /** - * @throws DownloaderException - * @throws RuntimeException - * @throws FileSystemException - */ - public function installMuslWrapper(): void - { - $prefix = ''; - if (get_current_user() !== 'root') { - $prefix = 'sudo '; - logger()->warning('Current user is not root, using sudo for running command'); - } - // The hardcoded version here is to be consistent with the version compiled by `musl-cross-toolchain`. - $musl_version_name = 'musl-1.2.4'; - $musl_source = [ - 'type' => 'url', - 'url' => "https://musl.libc.org/releases/{$musl_version_name}.tar.gz", - ]; - Downloader::downloadSource($musl_version_name, $musl_source); - FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); - shell(true)->cd(SOURCE_PATH . "/{$musl_version_name}") - ->exec('./configure') - ->exec('make -j') - ->exec("{$prefix}make install"); - } - - /** - * @throws DownloaderException - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ - public function installMuslCrossMake(): void - { - $arch = arch2gnu(php_uname('m')); - $musl_compile_source = [ - 'type' => 'url', - 'url' => "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/{$arch}-musl-toolchain.tgz", - ]; - logger()->info('Downloading ' . $musl_compile_source['url']); - Downloader::downloadSource('musl-compile', $musl_compile_source); - logger()->info('Extracting musl-cross'); - FileSystem::extractSource('musl-compile', DOWNLOAD_PATH . "/{$arch}-musl-toolchain.tgz"); - shell(true)->exec('cp -rf ' . SOURCE_PATH . '/musl-compile/* /usr/local/musl'); - } } diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index b421acfb..2a2dd522 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -261,10 +261,13 @@ class Downloader if ($source === null) { logger()->warning('Source {name} unknown. Skipping.', ['name' => $name]); - return; } + if (!is_dir(DOWNLOAD_PATH)) { + FileSystem::createDir(DOWNLOAD_PATH); + } + // load lock file if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { $lock = []; diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 9ae82889..0480ff14 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -152,6 +152,9 @@ class FileSystem if (self::$_extract_hook === []) { SourcePatcher::init(); } + if (!is_dir(SOURCE_PATH)) { + self::createDir(SOURCE_PATH); + } if ($move_path !== null) { $move_path = SOURCE_PATH . '/' . $move_path; } From 99150e2cefbfc2ce3cde4e7487aef0c03f7ab236 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 22 Oct 2023 22:14:11 +0800 Subject: [PATCH 252/296] add putenv wrapper --- src/globals/functions.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/globals/functions.php b/src/globals/functions.php index c9ef849a..d63f3350 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -110,6 +110,12 @@ function f_mkdir(string $directory, int $permissions = 0777, bool $recursive = f return mkdir($directory, $permissions, $recursive); } +function f_putenv(string $env): bool +{ + logger()->debug('Setting env: ' . $env); + return putenv($env); +} + function shell(?bool $debug = null): UnixShell { return new UnixShell($debug); From 5934e5e8814c278230010692a21ea4d0fac91f51 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 22 Oct 2023 22:16:20 +0800 Subject: [PATCH 253/296] fix doctor phpunit test --- tests/SPC/doctor/CheckListHandlerTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/SPC/doctor/CheckListHandlerTest.php b/tests/SPC/doctor/CheckListHandlerTest.php index 03e00344..364d78ce 100644 --- a/tests/SPC/doctor/CheckListHandlerTest.php +++ b/tests/SPC/doctor/CheckListHandlerTest.php @@ -17,6 +17,8 @@ final class CheckListHandlerTest extends TestCase $list = new CheckListHandler(); $id = $list->runChecks(); - $this->assertCount(7, $id); + foreach ($id as $item) { + $this->assertInstanceOf('SPC\doctor\AsCheckItem', $item); + } } } From c84eb723ecbf0ed39088e344c3f66dae388fcb59 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 23 Oct 2023 00:37:28 +0800 Subject: [PATCH 254/296] [mixed] refactor with putenv, fix imagemagick and c++ build --- config/ext.json | 1 - config/lib.json | 3 +- src/SPC/builder/BuilderBase.php | 20 ++++- src/SPC/builder/extension/imagick.php | 1 - src/SPC/builder/freebsd/BSDBuilder.php | 37 ++++---- src/SPC/builder/freebsd/library/openssl.php | 2 +- src/SPC/builder/linux/LinuxBuilder.php | 86 +++++++++---------- .../linux/library/LinuxLibraryBase.php | 11 --- src/SPC/builder/linux/library/icu.php | 2 +- src/SPC/builder/linux/library/libffi.php | 50 +++++++++++ src/SPC/builder/linux/library/libpng.php | 2 +- src/SPC/builder/linux/library/libxml2.php | 2 +- src/SPC/builder/linux/library/nghttp2.php | 2 +- src/SPC/builder/linux/library/openssl.php | 8 +- src/SPC/builder/macos/MacOSBuilder.php | 36 ++++---- src/SPC/builder/macos/library/glfw.php | 2 +- src/SPC/builder/macos/library/icu.php | 2 +- src/SPC/builder/macos/library/libffi.php | 2 +- .../builder/macos/library/libmemcached.php | 2 +- src/SPC/builder/macos/library/libpng.php | 2 +- src/SPC/builder/macos/library/libxml2.php | 2 +- src/SPC/builder/macos/library/nghttp2.php | 2 +- src/SPC/builder/macos/library/openssl.php | 2 +- src/SPC/builder/traits/UnixBuilderTrait.php | 5 +- src/SPC/builder/unix/library/brotli.php | 2 +- src/SPC/builder/unix/library/bzip2.php | 4 +- src/SPC/builder/unix/library/curl.php | 2 +- src/SPC/builder/unix/library/freetype.php | 2 +- src/SPC/builder/unix/library/gmp.php | 2 +- src/SPC/builder/unix/library/imagemagick.php | 8 +- src/SPC/builder/unix/library/ldap.php | 1 - src/SPC/builder/unix/library/libavif.php | 7 +- src/SPC/builder/unix/library/libevent.php | 2 +- src/SPC/builder/unix/library/libiconv.php | 2 +- src/SPC/builder/unix/library/libjpeg.php | 2 +- src/SPC/builder/unix/library/libsodium.php | 2 +- src/SPC/builder/unix/library/libssh2.php | 2 +- src/SPC/builder/unix/library/libwebp.php | 2 +- src/SPC/builder/unix/library/libxslt.php | 1 - src/SPC/builder/unix/library/libyaml.php | 2 +- src/SPC/builder/unix/library/libzip.php | 2 +- src/SPC/builder/unix/library/ncurses.php | 2 +- src/SPC/builder/unix/library/onig.php | 7 +- src/SPC/builder/unix/library/pkgconfig.php | 9 +- src/SPC/builder/unix/library/postgresql.php | 10 +-- src/SPC/builder/unix/library/readline.php | 2 +- src/SPC/builder/unix/library/snappy.php | 2 +- src/SPC/builder/unix/library/sqlite.php | 2 +- src/SPC/builder/unix/library/xz.php | 2 +- src/SPC/builder/unix/library/zlib.php | 2 +- src/SPC/builder/unix/library/zstd.php | 2 +- src/SPC/command/BuildCommand.php | 4 +- 52 files changed, 205 insertions(+), 168 deletions(-) create mode 100644 src/SPC/builder/linux/library/libffi.php diff --git a/config/ext.json b/config/ext.json index 8fc641f9..f2698d5e 100644 --- a/config/ext.json +++ b/config/ext.json @@ -146,7 +146,6 @@ }, "intl": { "type": "builtin", - "cpp-extension": true, "lib-depends": [ "icu" ] diff --git a/config/lib.json b/config/lib.json index 0dd26ed5..6a602d16 100644 --- a/config/lib.json +++ b/config/lib.json @@ -111,6 +111,7 @@ }, "icu": { "source": "icu", + "cpp-library": true, "static-libs-unix": [ "libicui18n.a", "libicuio.a", @@ -129,13 +130,13 @@ "zlib", "libpng", "libjpeg", - "bzip2", "libwebp", "freetype" ], "lib-suggests": [ "zstd", "xz", + "bzip2", "libzip", "libxml2" ] diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 8d8d46dd..eb18f485 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -112,6 +112,16 @@ abstract class BuilderBase return $this->libs[$name] ?? null; } + /** + * Get all library objects. + * + * @return LibraryBase[] + */ + public function getLibs(): array + { + return $this->libs; + } + /** * Add extension to build. */ @@ -139,12 +149,12 @@ abstract class BuilderBase } /** - * Check if there is a cpp extension. + * Check if there is a cpp extensions or libraries. * * @throws FileSystemException * @throws WrongUsageException */ - public function hasCppExtension(): bool + public function hasCpp(): bool { // judge cpp-extension $exts = array_keys($this->getExts()); @@ -153,6 +163,12 @@ abstract class BuilderBase return true; } } + $libs = array_keys($this->getLibs()); + foreach ($libs as $lib) { + if (Config::getLib($lib, 'cpp-library', false) === true) { + return true; + } + } return false; } diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index ef965d58..3c225471 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -14,7 +14,6 @@ class imagick extends Extension { // imagick may call omp_pause_all which requires -lgomp $extra_libs = $this->builder->getOption('extra-libs', ''); - $extra_libs .= ' -lgomp '; $this->builder->setOption('extra-libs', $extra_libs); return true; } diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index 64587c76..469c7534 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -31,9 +31,16 @@ class BSDBuilder extends BuilderBase // ---------- set necessary options ---------- // set C Compiler (default: clang) - $this->setOptionIfNotExist('cc', 'clang'); + f_putenv('CC=' . $this->getOption('cc', 'clang')); // set C++ Composer (default: clang++) - $this->setOptionIfNotExist('cxx', 'clang++'); + f_putenv('CXX=' . $this->getOption('cxx', 'clang++')); + // set PATH + f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); + // set PKG_CONFIG + f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); + // set PKG_CONFIG_PATH + f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/'); + // set arch (default: current) $this->setOptionIfNotExist('arch', php_uname('m')); $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); @@ -46,16 +53,6 @@ class BSDBuilder extends BuilderBase $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('arch')); // cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('BSD', $this->getOption('arch'), $this->arch_c_flags); - // configure environment - $this->configure_env = SystemUtil::makeEnvVarString([ - 'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config', - 'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig/', - 'CC' => $this->getOption('cc'), - 'CXX' => $this->getOption('cxx'), - 'CFLAGS' => "{$this->arch_c_flags} -Wimplicit-function-declaration -Os", - 'LIBS' => '-ldl -lpthread', - 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), - ]); // create pkgconfig and include dir (some libs cannot create them automatically) f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true); @@ -75,7 +72,7 @@ class BSDBuilder extends BuilderBase // ---------- Update extra-libs ---------- $extra_libs = $this->getOption('extra-libs', ''); // add libc++, some extensions or libraries need it (C++ cannot be linked statically) - $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lc++ ' : ''); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lc++ ' : ''); if (!$this->getOption('bloat', false)) { $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); } else { @@ -115,8 +112,7 @@ class BSDBuilder extends BuilderBase ($enableMicro ? '--enable-micro ' : '--disable-micro ') . $json_74 . $zts . - $this->makeExtensionArgs() . ' ' . - $this->configure_env + $this->makeExtensionArgs() ); SourcePatcher::patchBeforeMake($this); @@ -173,12 +169,14 @@ class BSDBuilder extends BuilderBase /** * Build phpmicro sapi * - * @throws FileSystemException|RuntimeException + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ public function buildMicro(): void { if ($this->getPHPVersionID() < 80000) { - throw new RuntimeException('phpmicro only support PHP >= 8.0!'); + throw new WrongUsageException('phpmicro only support PHP >= 8.0!'); } if ($this->getExt('phar')) { $this->phar_patched = true; @@ -228,6 +226,11 @@ class BSDBuilder extends BuilderBase $this->deployBinary(BUILD_TARGET_FPM); } + /** + * Build embed sapi + * + * @throws RuntimeException + */ public function buildEmbed(): void { $vars = SystemUtil::makeEnvVarString([ diff --git a/src/SPC/builder/freebsd/library/openssl.php b/src/SPC/builder/freebsd/library/openssl.php index ea521f47..e525745a 100644 --- a/src/SPC/builder/freebsd/library/openssl.php +++ b/src/SPC/builder/freebsd/library/openssl.php @@ -49,7 +49,7 @@ class openssl extends BSDLibraryBase shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./Configure no-shared {$extra} " . + "./Configure no-shared {$extra} " . '--prefix=/ ' . // use prefix=/ "--libdir={$lib} " . '--openssldir=/etc/ssl ' . diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 92c760ed..1aa6cdc9 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -21,9 +21,6 @@ class LinuxBuilder extends BuilderBase /** @var array Tune cflags */ public array $tune_c_flags; - /** @var string pkg-config env, including PKG_CONFIG_PATH, PKG_CONFIG */ - public string $pkgconf_env; - /** @var bool Micro patch phar flag */ private bool $phar_patched = false; @@ -39,21 +36,33 @@ class LinuxBuilder extends BuilderBase // ---------- set necessary options ---------- // set C/C++ compilers (default: alpine: gcc, others: musl-cross-make) if (SystemUtil::isMuslDist()) { - $this->setOptionIfNotExist('cc', 'gcc'); - $this->setOptionIfNotExist('cxx', 'g++'); - $this->setOptionIfNotExist('ar', 'ar'); - $this->setOptionIfNotExist('ld', 'ld.gold'); - $this->setOptionIfNotExist('library_path', ''); - $this->setOptionIfNotExist('ld_library_path', ''); + f_putenv("CC={$this->getOption('cc', 'gcc')}"); + f_putenv("CXX={$this->getOption('cxx', 'g++')}"); + f_putenv("AR={$this->getOption('ar', 'ar')}"); + f_putenv("LD={$this->getOption('ld', 'ld.gold')}"); } else { $arch = arch2gnu(php_uname('m')); - $this->setOptionIfNotExist('cc', "{$arch}-linux-musl-gcc"); - $this->setOptionIfNotExist('cxx', "{$arch}-linux-musl-g++"); - $this->setOptionIfNotExist('ar', "{$arch}-linux-musl-ar"); - $this->setOptionIfNotExist('ld', "/usr/local/musl/{$arch}-linux-musl/bin/ld.gold"); + f_putenv("CC={$this->getOption('cc', "{$arch}-linux-musl-gcc")}"); + f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}"); + f_putenv("AR={$this->getOption('ar', "{$arch}-linux-musl-ar")}"); + f_putenv("LD={$this->getOption('ld', "/usr/local/musl/{$arch}-linux-musl/bin/ld.gold")}"); + f_putenv('PATH=/usr/local/musl/bin:/usr/local/musl/' . $arch . '-linux-musl/bin:' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); + + // set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused) $this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); $this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); + + // check musl-cross make installed if we use musl-cross-make + if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) { + throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)'); + } } + + // set PKG_CONFIG + f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); + // set PKG_CONFIG_PATH + f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig'); + // set arch (default: current) $this->setOptionIfNotExist('arch', php_uname('m')); $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); @@ -61,32 +70,18 @@ class LinuxBuilder extends BuilderBase // concurrency $this->concurrency = SystemUtil::getCpuCount(); // cflags - $this->arch_c_flags = SystemUtil::getArchCFlags($this->getOption('cc'), $this->getOption('arch')); - $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('cxx'), $this->getOption('arch')); - $this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), $this->getOption('cc')); + $this->arch_c_flags = SystemUtil::getArchCFlags(getenv('CC'), $this->getOption('arch')); + $this->arch_cxx_flags = SystemUtil::getArchCFlags(getenv('CXX'), $this->getOption('arch')); + $this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), getenv('CC')); // cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile( 'Linux', $this->getOption('arch'), $this->arch_c_flags, - $this->getOption('cc'), - $this->getOption('cxx'), + getenv('CC'), + getenv('CXX'), ); - // pkg-config - $vars = [ - 'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config', - 'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig', - ]; - $this->pkgconf_env = SystemUtil::makeEnvVarString($vars); - // configure environment - $this->configure_env = SystemUtil::makeEnvVarString([ - ...$vars, - 'CC' => $this->getOption('cc'), - 'CXX' => $this->getOption('cxx'), - 'AR' => $this->getOption('ar'), - 'LD' => $this->getOption('ld'), - 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), - ]); + // cross-compiling is not supported yet /*if (php_uname('m') !== $this->arch) { $this->cross_compile_prefix = SystemUtil::getCrossCompilePrefix($this->cc, $this->arch); @@ -141,23 +136,19 @@ class LinuxBuilder extends BuilderBase $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles()))); } // add libstdc++, some extensions or libraries need it - $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lstdc++ ' : ''); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : ''); $this->setOption('extra-libs', $extra_libs); $cflags = $this->arch_c_flags; $use_lld = ''; - if (str_ends_with($this->getOption('cc'), 'clang') && SystemUtil::findCommand('lld')) { + if (str_ends_with(getenv('CC'), 'clang') && SystemUtil::findCommand('lld')) { $use_lld = '-Xcompiler -fuse-ld=lld'; } - $envs = $this->pkgconf_env . ' ' . SystemUtil::makeEnvVarString([ - 'CC' => $this->getOption('cc'), - 'CXX' => $this->getOption('cxx'), - 'AR' => $this->getOption('ar'), - 'LD' => $this->getOption('ld'), + // prepare build php envs + $envs_build_php = SystemUtil::makeEnvVarString([ 'CFLAGS' => $cflags, 'LIBS' => '-ldl -lpthread', - 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), ]); SourcePatcher::patchBeforeBuildconf($this); @@ -185,7 +176,6 @@ class LinuxBuilder extends BuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec( - "{$this->getOption('ld_library_path')} " . './configure ' . '--prefix= ' . '--with-valgrind=no ' . @@ -203,7 +193,7 @@ class LinuxBuilder extends BuilderBase $zts . $maxExecutionTimers . $this->makeExtensionArgs() . ' ' . - $envs + $envs_build_php ); SourcePatcher::patchBeforeMake($this); @@ -262,13 +252,14 @@ class LinuxBuilder extends BuilderBase /** * Build phpmicro sapi * - * @throws RuntimeException * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ public function buildMicro(string $use_lld, string $cflags): void { if ($this->getPHPVersionID() < 80000) { - throw new RuntimeException('phpmicro only support PHP >= 8.0!'); + throw new WrongUsageException('phpmicro only support PHP >= 8.0!'); } if ($this->getExt('phar')) { $this->phar_patched = true; @@ -321,6 +312,11 @@ class LinuxBuilder extends BuilderBase $this->deployBinary(BUILD_TARGET_FPM); } + /** + * Build embed sapi + * + * @throws RuntimeException + */ public function buildEmbed(string $use_lld): void { $vars = SystemUtil::makeEnvVarString([ diff --git a/src/SPC/builder/linux/library/LinuxLibraryBase.php b/src/SPC/builder/linux/library/LinuxLibraryBase.php index 89dc46bd..2a496590 100644 --- a/src/SPC/builder/linux/library/LinuxLibraryBase.php +++ b/src/SPC/builder/linux/library/LinuxLibraryBase.php @@ -33,15 +33,4 @@ abstract class LinuxLibraryBase extends LibraryBase { return $this->builder; } - - protected function makeFakePkgconfs(): void - { - $workspace = BUILD_ROOT_PATH; - if ($workspace === '/') { - $workspace = ''; - } - foreach ($this->pkgconfs as $name => $content) { - file_put_contents(BUILD_LIB_PATH . "/pkgconfig/{$name}", "prefix={$workspace}\n" . $content); - } - } } diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php index 5a5f69f9..c2d579f5 100644 --- a/src/SPC/builder/linux/library/icu.php +++ b/src/SPC/builder/linux/library/icu.php @@ -15,7 +15,7 @@ class icu extends LinuxLibraryBase $ldflags = 'LDFLAGS="-static"'; shell()->cd($this->source_dir . '/source') ->exec( - "{$this->builder->configure_env} {$cppflags} {$cxxflags} {$ldflags} " . + "{$cppflags} {$cxxflags} {$ldflags} " . './runConfigureICU Linux ' . '--enable-static ' . '--disable-shared ' . diff --git a/src/SPC/builder/linux/library/libffi.php b/src/SPC/builder/linux/library/libffi.php new file mode 100644 index 00000000..df85ef3e --- /dev/null +++ b/src/SPC/builder/linux/library/libffi.php @@ -0,0 +1,50 @@ +builder->pkgconf_env . ' CFLAGS="' . $this->builder->arch_c_flags . '"'; + + $env .= match ($this->builder->libc) { + 'musl_wrapper' => " CC='{$this->builder->getOption('cc')} --static -idirafter " . BUILD_INCLUDE_PATH . + ($this->builder->getOption('arch') === php_uname('m') ? '-idirafter /usr/include/ ' : '') . + "-idirafter /usr/include/{$this->builder->getOption('arch')}-linux-gnu/'", + 'musl', 'glibc' => " CC='{$this->builder->getOption('cc')}'", + default => throw new RuntimeException('unsupported libc: ' . $this->builder->libc), + };*/ + + shell()->cd($this->source_dir) + ->exec( + './configure ' . + '--enable-static ' . + '--disable-shared ' . + "--host={$this->builder->getOption('arch')}-unknown-linux " . + "--target={$this->builder->getOption('arch')}-unknown-linux " . + '--prefix= ' . // use prefix=/ + "--libdir={$lib}" + ) + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec("make install DESTDIR={$destdir}"); + + if (is_file(BUILD_ROOT_PATH . '/lib64/libffi.a')) { + copy(BUILD_ROOT_PATH . '/lib64/libffi.a', BUILD_ROOT_PATH . '/lib/libffi.a'); + unlink(BUILD_ROOT_PATH . '/lib64/libffi.a'); + } + $this->patchPkgconfPrefix(['libffi.pc']); + } +} diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index d66b3282..3b6b2b6a 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -66,7 +66,7 @@ class libpng extends LinuxLibraryBase ->exec('chmod +x ./configure') ->exec('chmod +x ./install-sh') ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--disable-shared ' . '--enable-static ' . '--enable-hardware-optimizations ' . diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php index 4095ee56..82327c58 100644 --- a/src/SPC/builder/linux/library/libxml2.php +++ b/src/SPC/builder/linux/library/libxml2.php @@ -25,7 +25,7 @@ class libxml2 extends LinuxLibraryBase FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} " . ' cmake ' . + 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIBS=OFF ' . '-DIconv_IS_BUILT_IN=OFF ' . diff --git a/src/SPC/builder/linux/library/nghttp2.php b/src/SPC/builder/linux/library/nghttp2.php index 8246a2eb..86337874 100644 --- a/src/SPC/builder/linux/library/nghttp2.php +++ b/src/SPC/builder/linux/library/nghttp2.php @@ -55,7 +55,7 @@ class nghttp2 extends LinuxLibraryBase shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static ' . '--disable-shared ' . "--host={$this->builder->getOption('gnu-arch')}-unknown-linux " . diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index af3400b6..5a9c5bfd 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -41,8 +41,8 @@ class openssl extends LinuxLibraryBase $extra = ''; $ex_lib = '-ldl -pthread'; - $env = $this->builder->pkgconf_env . " CFLAGS='{$this->builder->arch_c_flags}'"; - $env .= " CC='{$this->builder->getOption('cc')} -static -idirafter " . BUILD_INCLUDE_PATH . + $env = "CFLAGS='{$this->builder->arch_c_flags}'"; + $env .= " CC='" . getenv('CC') . ' -static -idirafter ' . BUILD_INCLUDE_PATH . ' -idirafter /usr/include/ ' . ' -idirafter /usr/include/' . $this->builder->getOption('arch') . '-linux-gnu/ ' . "' "; @@ -60,11 +60,11 @@ class openssl extends LinuxLibraryBase $ex_lib = trim($ex_lib); - $clang_postfix = SystemUtil::getCCType($this->builder->getOption('cc')) === 'clang' ? '-clang' : ''; + $clang_postfix = SystemUtil::getCCType(getenv('CC')) === 'clang' ? '-clang' : ''; shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} {$env} ./Configure no-shared {$extra} " . + "{$env} ./Configure no-shared {$extra} " . '--prefix=/ ' . '--libdir=lib ' . '-static ' . diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 49643678..774a9172 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -32,9 +32,16 @@ class MacOSBuilder extends BuilderBase // ---------- set necessary options ---------- // set C Compiler (default: clang) - $this->setOptionIfNotExist('cc', 'clang'); + f_putenv('CC=' . $this->getOption('cc', 'clang')); // set C++ Composer (default: clang++) - $this->setOptionIfNotExist('cxx', 'clang++'); + f_putenv('CXX=' . $this->getOption('cxx', 'clang++')); + // set PATH + f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); + // set PKG_CONFIG + f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); + // set PKG_CONFIG_PATH + f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/'); + // set arch (default: current) $this->setOptionIfNotExist('arch', php_uname('m')); $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); @@ -47,15 +54,6 @@ class MacOSBuilder extends BuilderBase $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('arch')); // cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('Darwin', $this->getOption('arch'), $this->arch_c_flags); - // configure environment - $this->configure_env = SystemUtil::makeEnvVarString([ - 'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config', - 'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig/', - 'CC' => $this->getOption('cc'), - 'CXX' => $this->getOption('cxx'), - 'CFLAGS' => "{$this->arch_c_flags} -Wimplicit-function-declaration -Os", - 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), - ]); // create pkgconfig and include dir (some libs cannot create them automatically) f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true); @@ -134,7 +132,7 @@ class MacOSBuilder extends BuilderBase // add macOS frameworks $extra_libs .= (empty($extra_libs) ? '' : ' ') . $this->getFrameworks(true); // add libc++, some extensions or libraries need it (C++ cannot be linked statically) - $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lc++ ' : ''); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lc++ ' : ''); if (!$this->getOption('bloat', false)) { $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); } else { @@ -174,8 +172,7 @@ class MacOSBuilder extends BuilderBase ($enableMicro ? '--enable-micro ' : '--disable-micro ') . $json_74 . $zts . - $this->makeExtensionArgs() . ' ' . - $this->configure_env + $this->makeExtensionArgs() ); SourcePatcher::patchBeforeMake($this); @@ -231,12 +228,14 @@ class MacOSBuilder extends BuilderBase /** * Build phpmicro sapi * - * @throws FileSystemException|RuntimeException + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ public function buildMicro(): void { if ($this->getPHPVersionID() < 80000) { - throw new RuntimeException('phpmicro only support PHP >= 8.0!'); + throw new WrongUsageException('phpmicro only support PHP >= 8.0!'); } if ($this->getExt('phar')) { $this->phar_patched = true; @@ -285,6 +284,11 @@ class MacOSBuilder extends BuilderBase $this->deployBinary(BUILD_TARGET_FPM); } + /** + * Build embed sapi + * + * @throws RuntimeException + */ public function buildEmbed(): void { $vars = SystemUtil::makeEnvVarString([ diff --git a/src/SPC/builder/macos/library/glfw.php b/src/SPC/builder/macos/library/glfw.php index c2ca2e74..91e8cb70 100644 --- a/src/SPC/builder/macos/library/glfw.php +++ b/src/SPC/builder/macos/library/glfw.php @@ -19,7 +19,7 @@ class glfw extends MacOSLibraryBase { // compile! shell()->cd(SOURCE_PATH . '/ext-glfw/vendor/glfw') - ->exec("{$this->builder->configure_env} cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF") + ->exec("cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF") ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); // patch pkgconf diff --git a/src/SPC/builder/macos/library/icu.php b/src/SPC/builder/macos/library/icu.php index 11a5663e..14a0ae94 100644 --- a/src/SPC/builder/macos/library/icu.php +++ b/src/SPC/builder/macos/library/icu.php @@ -12,7 +12,7 @@ class icu extends MacOSLibraryBase { $root = BUILD_ROOT_PATH; shell()->cd($this->source_dir . '/source') - ->exec("{$this->builder->configure_env} ./runConfigureICU MacOSX --enable-static --disable-shared --prefix={$root}") + ->exec("./runConfigureICU MacOSX --enable-static --disable-shared --prefix={$root}") ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec('make install'); diff --git a/src/SPC/builder/macos/library/libffi.php b/src/SPC/builder/macos/library/libffi.php index 74bc9ce6..94903f67 100644 --- a/src/SPC/builder/macos/library/libffi.php +++ b/src/SPC/builder/macos/library/libffi.php @@ -20,7 +20,7 @@ class libffi extends MacOSLibraryBase [, , $destdir] = SEPARATED_PATH; shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static ' . '--disable-shared ' . "--host={$this->builder->getOption('arch')}-apple-darwin " . diff --git a/src/SPC/builder/macos/library/libmemcached.php b/src/SPC/builder/macos/library/libmemcached.php index 6eb906f9..09a600a2 100644 --- a/src/SPC/builder/macos/library/libmemcached.php +++ b/src/SPC/builder/macos/library/libmemcached.php @@ -18,7 +18,7 @@ class libmemcached extends MacOSLibraryBase shell()->cd($this->source_dir) ->exec('chmod +x configure') ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static --disable-shared ' . '--disable-sasl ' . "--prefix={$rootdir}" diff --git a/src/SPC/builder/macos/library/libpng.php b/src/SPC/builder/macos/library/libpng.php index 868270d3..b41f8510 100644 --- a/src/SPC/builder/macos/library/libpng.php +++ b/src/SPC/builder/macos/library/libpng.php @@ -44,7 +44,7 @@ class libpng extends MacOSLibraryBase ->exec('chmod +x ./configure') ->exec('chmod +x ./install-sh') ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . "--host={$this->builder->getOption('gnu-arch')}-apple-darwin " . '--disable-shared ' . '--enable-static ' . diff --git a/src/SPC/builder/macos/library/libxml2.php b/src/SPC/builder/macos/library/libxml2.php index 36f960ea..50cb3a5a 100644 --- a/src/SPC/builder/macos/library/libxml2.php +++ b/src/SPC/builder/macos/library/libxml2.php @@ -25,7 +25,7 @@ class libxml2 extends MacOSLibraryBase FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} " . ' cmake ' . + 'cmake ' . // '--debug-find ' . "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIBS=OFF ' . diff --git a/src/SPC/builder/macos/library/nghttp2.php b/src/SPC/builder/macos/library/nghttp2.php index c1943840..b48cbe72 100644 --- a/src/SPC/builder/macos/library/nghttp2.php +++ b/src/SPC/builder/macos/library/nghttp2.php @@ -53,7 +53,7 @@ class nghttp2 extends MacOSLibraryBase shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} " . ' ./configure ' . + './configure ' . '--enable-static ' . '--disable-shared ' . "--host={$this->builder->getOption('gnu-arch')}-apple-darwin " . diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index 8ac99b7f..c768512d 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -48,7 +48,7 @@ class openssl extends MacOSLibraryBase shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./Configure no-shared {$extra} " . + "./Configure no-shared {$extra} " . '--prefix=/ ' . // use prefix=/ "--libdir={$lib} " . '--openssldir=/System/Library/OpenSSL ' . diff --git a/src/SPC/builder/traits/UnixBuilderTrait.php b/src/SPC/builder/traits/UnixBuilderTrait.php index 3af58426..2d0d43d2 100644 --- a/src/SPC/builder/traits/UnixBuilderTrait.php +++ b/src/SPC/builder/traits/UnixBuilderTrait.php @@ -21,9 +21,6 @@ trait UnixBuilderTrait /** @var string cmake toolchain file */ public string $cmake_toolchain_file; - /** @var string configure environments */ - public string $configure_env; - /** * @throws WrongUsageException * @throws FileSystemException @@ -145,7 +142,7 @@ trait UnixBuilderTrait */ public function makeCmakeArgs(): string { - $extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . $this->getOption('cc') . ' ' : ''; + $extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . getenv('CC') . ' ' : ''; return $extra . '-DCMAKE_BUILD_TYPE=Release ' . '-DCMAKE_INSTALL_PREFIX=/ ' . diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index b84fc7ed..92c04de4 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -19,7 +19,7 @@ trait brotli FileSystem::resetDir($this->source_dir . '/build-dir'); shell()->cd($this->source_dir . '/build-dir') ->exec( - $this->builder->configure_env . ' cmake ' . + 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIBS=OFF ' . '..' diff --git a/src/SPC/builder/unix/library/bzip2.php b/src/SPC/builder/unix/library/bzip2.php index bb4f0d9e..8de623d4 100644 --- a/src/SPC/builder/unix/library/bzip2.php +++ b/src/SPC/builder/unix/library/bzip2.php @@ -9,8 +9,8 @@ trait bzip2 protected function build(): void { shell()->cd($this->source_dir) - ->exec("make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean") - ->exec("make -j{$this->builder->concurrency} {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a") + ->exec("make PREFIX='" . BUILD_ROOT_PATH . "' clean") + ->exec("make -j{$this->builder->concurrency} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a") ->exec('cp libbz2.a ' . BUILD_LIB_PATH) ->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH); } diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index c7bbc275..216f42b5 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -52,7 +52,7 @@ trait curl // compile! shell()->cd($this->source_dir . '/build') ->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt') - ->exec("{$this->builder->configure_env} cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF {$extra} ..") + ->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF {$extra} ..") ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); // patch pkgconf diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index ee7bc9aa..8ef3368f 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -27,7 +27,7 @@ trait freetype shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static --disable-shared --without-harfbuzz --prefix= ' . $suggested ) diff --git a/src/SPC/builder/unix/library/gmp.php b/src/SPC/builder/unix/library/gmp.php index bc95a3eb..f1902dde 100644 --- a/src/SPC/builder/unix/library/gmp.php +++ b/src/SPC/builder/unix/library/gmp.php @@ -17,7 +17,7 @@ trait gmp { shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static --disable-shared ' . '--prefix=' ) diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index 7e291e8c..40a46992 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\builder\linux\library\LinuxLibraryBase; +use SPC\builder\linux\LinuxBuilder; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; @@ -17,7 +18,8 @@ trait imagemagick */ protected function build(): void { - $extra = '--without-jxl --without-x --disable-openmp '; + // TODO: imagemagick build with bzip2 failed with bugs, we need to fix it in the future + $extra = '--without-jxl --without-x --disable-openmp --without-bzlib '; $required_libs = ''; $optional_libs = [ 'libzip' => 'zip', @@ -26,6 +28,7 @@ trait imagemagick 'libwebp' => 'webp', 'libxml2' => 'xml', 'zlib' => 'zlib', + 'xz' => 'lzma', 'zstd' => 'zstd', 'freetype' => 'freetype', ]; @@ -38,8 +41,7 @@ trait imagemagick shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} " . - 'LDFLAGS="-static" ' . + ($this->builder instanceof LinuxBuilder ? ('LDFLAGS="-static -L' . BUILD_LIB_PATH . '" ') : '') . "LIBS='{$required_libs}' " . './configure ' . '--enable-static --disable-shared ' . diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index d1ffcbd7..9b4080df 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -17,7 +17,6 @@ trait ldap $alt .= $this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : ''; shell()->cd($this->source_dir) ->exec( - $this->builder->configure_env . ' ' . $this->builder->makeAutoconfFlags(AUTOCONF_LDFLAGS | AUTOCONF_CPPFLAGS) . ' ./configure ' . '--enable-static ' . diff --git a/src/SPC/builder/unix/library/libavif.php b/src/SPC/builder/unix/library/libavif.php index 56b17bdb..592899b2 100644 --- a/src/SPC/builder/unix/library/libavif.php +++ b/src/SPC/builder/unix/library/libavif.php @@ -22,12 +22,7 @@ trait libavif FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->exec( - "{$this->builder->configure_env} cmake " . - $this->builder->makeCmakeArgs() . ' ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '..' - ) + ->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF ..") ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); // patch pkgconfig diff --git a/src/SPC/builder/unix/library/libevent.php b/src/SPC/builder/unix/library/libevent.php index 59e59f53..d9b2d81b 100644 --- a/src/SPC/builder/unix/library/libevent.php +++ b/src/SPC/builder/unix/library/libevent.php @@ -21,7 +21,7 @@ trait libevent // Start build shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} cmake " . + 'cmake ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '-DCMAKE_BUILD_TYPE=Release ' . diff --git a/src/SPC/builder/unix/library/libiconv.php b/src/SPC/builder/unix/library/libiconv.php index dacfab1e..5096e724 100644 --- a/src/SPC/builder/unix/library/libiconv.php +++ b/src/SPC/builder/unix/library/libiconv.php @@ -12,7 +12,7 @@ trait libiconv shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static ' . '--disable-shared ' . '--prefix=' diff --git a/src/SPC/builder/unix/library/libjpeg.php b/src/SPC/builder/unix/library/libjpeg.php index 88845c49..df02bd13 100644 --- a/src/SPC/builder/unix/library/libjpeg.php +++ b/src/SPC/builder/unix/library/libjpeg.php @@ -23,7 +23,7 @@ trait libjpeg // Start build shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} cmake {$this->builder->makeCmakeArgs()} " . + "cmake {$this->builder->makeCmakeArgs()} " . '-DENABLE_STATIC=ON ' . '-DENABLE_SHARED=OFF ' . '..' diff --git a/src/SPC/builder/unix/library/libsodium.php b/src/SPC/builder/unix/library/libsodium.php index f12727d7..555b48d6 100644 --- a/src/SPC/builder/unix/library/libsodium.php +++ b/src/SPC/builder/unix/library/libsodium.php @@ -10,7 +10,7 @@ trait libsodium { $root = BUILD_ROOT_PATH; shell()->cd($this->source_dir) - ->exec("{$this->builder->configure_env} ./configure --enable-static --disable-shared --prefix={$root}") + ->exec("./configure --enable-static --disable-shared --prefix={$root}") ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec('make install'); diff --git a/src/SPC/builder/unix/library/libssh2.php b/src/SPC/builder/unix/library/libssh2.php index a207f27b..32d96b9a 100644 --- a/src/SPC/builder/unix/library/libssh2.php +++ b/src/SPC/builder/unix/library/libssh2.php @@ -21,7 +21,7 @@ trait libssh2 FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} " . ' cmake ' . + 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIBS=OFF ' . '-DBUILD_EXAMPLES=OFF ' . diff --git a/src/SPC/builder/unix/library/libwebp.php b/src/SPC/builder/unix/library/libwebp.php index 32aa7201..eef6d039 100644 --- a/src/SPC/builder/unix/library/libwebp.php +++ b/src/SPC/builder/unix/library/libwebp.php @@ -23,7 +23,7 @@ trait libwebp // Start build shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} cmake " . + 'cmake ' . $this->builder->makeCmakeArgs() . ' ' . '-DBUILD_SHARED_LIBS=OFF ' . '-DWEBP_BUILD_EXTRAS=ON ' . diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index 847c30e0..17fb2f1e 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -26,7 +26,6 @@ trait libxslt } shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} " . 'CFLAGS="-I' . BUILD_INCLUDE_PATH . '" ' . "{$this->builder->getOption('library_path')} " . "{$this->builder->getOption('ld_library_path')} " . diff --git a/src/SPC/builder/unix/library/libyaml.php b/src/SPC/builder/unix/library/libyaml.php index b35cd25f..b1b545cf 100644 --- a/src/SPC/builder/unix/library/libyaml.php +++ b/src/SPC/builder/unix/library/libyaml.php @@ -60,7 +60,7 @@ EOF FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} cmake " . + 'cmake ' . // '--debug-find ' . '-DCMAKE_BUILD_TYPE=Release ' . '-DBUILD_TESTING=OFF ' . diff --git a/src/SPC/builder/unix/library/libzip.php b/src/SPC/builder/unix/library/libzip.php index f21678ae..83e0600c 100644 --- a/src/SPC/builder/unix/library/libzip.php +++ b/src/SPC/builder/unix/library/libzip.php @@ -29,7 +29,7 @@ trait libzip FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} " . ' cmake ' . + 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DENABLE_GNUTLS=OFF ' . '-DENABLE_MBEDTLS=OFF ' . diff --git a/src/SPC/builder/unix/library/ncurses.php b/src/SPC/builder/unix/library/ncurses.php index f3ec2636..790c77b6 100644 --- a/src/SPC/builder/unix/library/ncurses.php +++ b/src/SPC/builder/unix/library/ncurses.php @@ -10,7 +10,7 @@ trait ncurses { shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static ' . '--disable-shared ' . '--enable-overwrite ' . diff --git a/src/SPC/builder/unix/library/onig.php b/src/SPC/builder/unix/library/onig.php index e9414ab2..b43d14b3 100644 --- a/src/SPC/builder/unix/library/onig.php +++ b/src/SPC/builder/unix/library/onig.php @@ -18,12 +18,7 @@ trait onig [,,$destdir] = SEPARATED_PATH; shell()->cd($this->source_dir) - ->exec( - "{$this->builder->configure_env} " . ' ./configure ' . - '--enable-static ' . - '--disable-shared ' . - '--prefix=' - ) + ->exec('./configure --enable-static --disable-shared --prefix=') ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec("make install DESTDIR={$destdir}"); diff --git a/src/SPC/builder/unix/library/pkgconfig.php b/src/SPC/builder/unix/library/pkgconfig.php index 822371a8..52ec5e4d 100644 --- a/src/SPC/builder/unix/library/pkgconfig.php +++ b/src/SPC/builder/unix/library/pkgconfig.php @@ -8,13 +8,8 @@ trait pkgconfig { protected function build(): void { - $macos_env = 'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig/" ' . - "CC='{$this->builder->getOption('cc')}' " . - "CXX='{$this->builder->getOption('cxx')}' " . - "CFLAGS='{$this->builder->arch_c_flags} -Wimplicit-function-declaration' "; - $linux_env = 'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig" ' . - "CC='{$this->builder->getOption('cc')}' " . - "CXX='{$this->builder->getOption('cxx')}' "; + $macos_env = "CFLAGS='{$this->builder->arch_c_flags} -Wimplicit-function-declaration' "; + $linux_env = 'LDFLAGS=--static '; shell()->cd($this->source_dir) ->exec( diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index eaf6710e..235e40f0 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -18,8 +18,7 @@ trait postgresql protected function build(): void { $builddir = BUILD_ROOT_PATH; - $env = $this->builder->configure_env; - $envs = $env; + $envs = ''; $packages = 'openssl zlib readline libxml-2.0 zlib'; $optional_packages = [ 'zstd' => 'libzstd', @@ -34,18 +33,17 @@ trait postgresql } } - $pkgconfig_executable = $builddir . '/bin/pkg-config'; - $output = shell()->execWithResult($env . " {$pkgconfig_executable} --cflags-only-I --static " . $packages); + $output = shell()->execWithResult("pkg-config --cflags-only-I --static {$packages}"); if (!empty($output[1][0])) { $cppflags = $output[1][0]; $envs .= " CPPFLAGS=\"{$cppflags}\""; } - $output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-L --static " . $packages); + $output = shell()->execWithResult("pkg-config --libs-only-L --static {$packages}"); if (!empty($output[1][0])) { $ldflags = $output[1][0]; $envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" "; } - $output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-l --static " . $packages); + $output = shell()->execWithResult("pkg-config --libs-only-l --static {$packages}"); if (!empty($output[1][0])) { $libs = $output[1][0]; $envs .= " LIBS=\"{$libs} -lstdc++\" "; diff --git a/src/SPC/builder/unix/library/readline.php b/src/SPC/builder/unix/library/readline.php index fc865238..4f725129 100644 --- a/src/SPC/builder/unix/library/readline.php +++ b/src/SPC/builder/unix/library/readline.php @@ -17,7 +17,7 @@ trait readline { shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static=yes ' . '--enable-shared=no ' . '--prefix= ' . diff --git a/src/SPC/builder/unix/library/snappy.php b/src/SPC/builder/unix/library/snappy.php index 18f5e78c..d7a5ade0 100644 --- a/src/SPC/builder/unix/library/snappy.php +++ b/src/SPC/builder/unix/library/snappy.php @@ -20,7 +20,7 @@ trait snappy shell()->cd($this->source_dir . '/cmake/build') ->exec( - "{$this->builder->configure_env} cmake " . + 'cmake ' . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . "{$this->builder->makeCmakeArgs()} " . '-DSNAPPY_BUILD_TESTS=OFF ' . diff --git a/src/SPC/builder/unix/library/sqlite.php b/src/SPC/builder/unix/library/sqlite.php index f9947df7..b706a39f 100644 --- a/src/SPC/builder/unix/library/sqlite.php +++ b/src/SPC/builder/unix/library/sqlite.php @@ -9,7 +9,7 @@ trait sqlite protected function build(): void { shell()->cd($this->source_dir) - ->exec("{$this->builder->configure_env} ./configure --enable-static --disable-shared --prefix=") + ->exec('./configure --enable-static --disable-shared --prefix=') ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index 1f214b3a..7cd7e74b 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -17,7 +17,7 @@ trait xz { shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static ' . '--disable-shared ' . "--host={$this->builder->getOption('gnu-arch')}-unknown-linux " . diff --git a/src/SPC/builder/unix/library/zlib.php b/src/SPC/builder/unix/library/zlib.php index 5dd0ee10..b380f8b0 100644 --- a/src/SPC/builder/unix/library/zlib.php +++ b/src/SPC/builder/unix/library/zlib.php @@ -18,7 +18,7 @@ trait zlib [,,$destdir] = SEPARATED_PATH; shell()->cd($this->source_dir) - ->exec("{$this->builder->configure_env} ./configure --static --prefix=") + ->exec('./configure --static --prefix=') ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec("make install DESTDIR={$destdir}"); diff --git a/src/SPC/builder/unix/library/zstd.php b/src/SPC/builder/unix/library/zstd.php index de375b25..399eeedc 100644 --- a/src/SPC/builder/unix/library/zstd.php +++ b/src/SPC/builder/unix/library/zstd.php @@ -19,7 +19,7 @@ trait zstd FileSystem::resetDir($this->source_dir . '/build/cmake/build'); shell()->cd($this->source_dir . '/build/cmake/build') ->exec( - "{$this->builder->configure_env} cmake " . + 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DZSTD_BUILD_STATIC=ON ' . '-DZSTD_BUILD_SHARED=OFF ' . diff --git a/src/SPC/command/BuildCommand.php b/src/SPC/command/BuildCommand.php index 0c985b13..4d3f7d06 100644 --- a/src/SPC/command/BuildCommand.php +++ b/src/SPC/command/BuildCommand.php @@ -19,11 +19,11 @@ abstract class BuildCommand extends BaseCommand $this->addOption('arch', null, InputOption::VALUE_REQUIRED, 'architecture, "x64" or "arm64"', 'x64'); break; case 'Linux': - $this->addOption('no-system-static', null, null, 'do not use system static libraries'); - // no break case 'Darwin': $this->addOption('cc', null, InputOption::VALUE_REQUIRED, 'C compiler'); $this->addOption('cxx', null, InputOption::VALUE_REQUIRED, 'C++ compiler'); + $this->addOption('ar', null, InputOption::VALUE_REQUIRED, 'ar'); + $this->addOption('ld', null, InputOption::VALUE_REQUIRED, 'ld'); $this->addOption('arch', null, InputOption::VALUE_REQUIRED, 'architecture', php_uname('m')); break; } From 8a70da6291fb9c87e3f394f38a730c8effe18523 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 23 Oct 2023 00:41:43 +0800 Subject: [PATCH 255/296] change instanceof check --- src/SPC/builder/unix/library/imagemagick.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index 40a46992..bd4d0424 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\builder\linux\library\LinuxLibraryBase; -use SPC\builder\linux\LinuxBuilder; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; @@ -39,9 +38,10 @@ trait imagemagick } } + $ldflags = $this instanceof LinuxLibraryBase ? ('LDFLAGS="-static" ') : ''; shell()->cd($this->source_dir) ->exec( - ($this->builder instanceof LinuxBuilder ? ('LDFLAGS="-static -L' . BUILD_LIB_PATH . '" ') : '') . + $ldflags . "LIBS='{$required_libs}' " . './configure ' . '--enable-static --disable-shared ' . From 9b9644fe63dbea3944cb515f0ff1fbb360b73e86 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 23 Oct 2023 20:12:47 +0800 Subject: [PATCH 256/296] simplify download error message --- src/SPC/command/DownloadCommand.php | 197 ++++++++++++++-------------- src/SPC/store/Downloader.php | 2 +- 2 files changed, 102 insertions(+), 97 deletions(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index dfad36fe..9db2adbc 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -59,105 +59,110 @@ class DownloadCommand extends BaseCommand */ public function handle(): int { - // 删除旧资源 - if ($this->getOption('clean')) { - logger()->warning('You are doing some operations that not recoverable: removing directories below'); - logger()->warning(SOURCE_PATH); - logger()->warning(DOWNLOAD_PATH); - logger()->warning(BUILD_ROOT_PATH); - logger()->alert('I will remove these dir after 5 seconds !'); - sleep(5); - if (PHP_OS_FAMILY === 'Windows') { - f_passthru('rmdir /s /q ' . SOURCE_PATH); - f_passthru('rmdir /s /q ' . DOWNLOAD_PATH); - f_passthru('rmdir /s /q ' . BUILD_ROOT_PATH); - } else { - f_passthru('rm -rf ' . SOURCE_PATH . '/*'); - f_passthru('rm -rf ' . DOWNLOAD_PATH . '/*'); - f_passthru('rm -rf ' . BUILD_ROOT_PATH . '/*'); + try { + if ($this->getOption('clean')) { + logger()->warning('You are doing some operations that not recoverable: removing directories below'); + logger()->warning(SOURCE_PATH); + logger()->warning(DOWNLOAD_PATH); + logger()->warning(BUILD_ROOT_PATH); + logger()->alert('I will remove these dir after 5 seconds !'); + sleep(5); + if (PHP_OS_FAMILY === 'Windows') { + f_passthru('rmdir /s /q ' . SOURCE_PATH); + f_passthru('rmdir /s /q ' . DOWNLOAD_PATH); + f_passthru('rmdir /s /q ' . BUILD_ROOT_PATH); + } else { + f_passthru('rm -rf ' . SOURCE_PATH . '/*'); + f_passthru('rm -rf ' . DOWNLOAD_PATH . '/*'); + f_passthru('rm -rf ' . BUILD_ROOT_PATH . '/*'); + } + return static::FAILURE; } + + // --from-zip + if ($path = $this->getOption('from-zip')) { + return $this->downloadFromZip($path); + } + + // Define PHP major version + $ver = $this->php_major_ver = $this->getOption('with-php') ?? '8.1'; + define('SPC_BUILD_PHP_VERSION', $ver); + preg_match('/^\d+\.\d+$/', $ver, $matches); + if (!$matches) { + logger()->error("bad version arg: {$ver}, x.y required!"); + return static::FAILURE; + } + + // Use shallow-clone can reduce git resource download + if ($this->getOption('shallow-clone')) { + define('GIT_SHALLOW_CLONE', true); + } + + // To read config + Config::getSource('openssl'); + + // use openssl 1.1 + if ($this->getOption('with-openssl11')) { + logger()->debug('Using openssl 1.1'); + Config::$source['openssl']['regex'] = '/href="(?openssl-(?1.[^"]+)\.tar\.gz)\"/'; + } + + // --by-extensions + if ($by_ext = $this->getOption('by-extensions')) { + $ext = array_map('trim', array_filter(explode(',', $by_ext))); + $sources = $this->calculateSourcesByExt($ext, !$this->getOption('without-suggests')); + array_unshift($sources, 'php-src', 'micro', 'pkg-config'); + } else { + // get source list that will be downloaded + $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); + if (empty($sources)) { + $sources = array_keys(Config::getSources()); + } + } + $chosen_sources = $sources; + + // Process -U options + $custom_urls = []; + foreach ($this->input->getOption('custom-url') as $value) { + [$source_name, $url] = explode(':', $value, 2); + $custom_urls[$source_name] = $url; + } + + // Download them + f_mkdir(DOWNLOAD_PATH); + $cnt = count($chosen_sources); + $ni = 0; + foreach ($chosen_sources as $source) { + ++$ni; + if (isset($custom_urls[$source])) { + $config = Config::getSource($source); + $new_config = [ + 'type' => 'url', + 'url' => $custom_urls[$source], + ]; + if (isset($config['path'])) { + $new_config['path'] = $config['path']; + } + if (isset($config['filename'])) { + $new_config['filename'] = $config['filename']; + } + logger()->info("Fetching source {$source} from custom url [{$ni}/{$cnt}]"); + Downloader::downloadSource($source, $new_config, true); + } else { + logger()->info("Fetching source {$source} [{$ni}/{$cnt}]"); + Downloader::downloadSource($source, Config::getSource($source)); + } + } + $time = round(microtime(true) - START_TIME, 3); + logger()->info('Download complete, used ' . $time . ' s !'); + return static::SUCCESS; + } catch (DownloaderException $e) { + logger()->error($e->getMessage()); + return static::FAILURE; + } catch (WrongUsageException $e) { + logger()->critical($e->getMessage()); return static::FAILURE; } - - // --from-zip - if ($path = $this->getOption('from-zip')) { - return $this->downloadFromZip($path); - } - - // Define PHP major version - $ver = $this->php_major_ver = $this->getOption('with-php') ?? '8.1'; - define('SPC_BUILD_PHP_VERSION', $ver); - preg_match('/^\d+\.\d+$/', $ver, $matches); - if (!$matches) { - logger()->error("bad version arg: {$ver}, x.y required!"); - return static::FAILURE; - } - - // Use shallow-clone can reduce git resource download - if ($this->getOption('shallow-clone')) { - define('GIT_SHALLOW_CLONE', true); - } - - // To read config - Config::getSource('openssl'); - - // use openssl 1.1 - if ($this->getOption('with-openssl11')) { - logger()->debug('Using openssl 1.1'); - // 手动修改配置 - Config::$source['openssl']['regex'] = '/href="(?openssl-(?1.[^"]+)\.tar\.gz)\"/'; - } - - // --by-extensions - if ($by_ext = $this->getOption('by-extensions')) { - $ext = array_map('trim', array_filter(explode(',', $by_ext))); - $sources = $this->calculateSourcesByExt($ext, !$this->getOption('without-suggests')); - array_unshift($sources, 'php-src', 'micro', 'pkg-config'); - } else { - // get source list that will be downloaded - $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); - if (empty($sources)) { - $sources = array_keys(Config::getSources()); - } - } - $chosen_sources = $sources; - - // Process -U options - $custom_urls = []; - foreach ($this->input->getOption('custom-url') as $value) { - [$source_name, $url] = explode(':', $value, 2); - $custom_urls[$source_name] = $url; - } - - // Download them - f_mkdir(DOWNLOAD_PATH); - $cnt = count($chosen_sources); - $ni = 0; - foreach ($chosen_sources as $source) { - ++$ni; - if (isset($custom_urls[$source])) { - $config = Config::getSource($source); - $new_config = [ - 'type' => 'url', - 'url' => $custom_urls[$source], - ]; - if (isset($config['path'])) { - $new_config['path'] = $config['path']; - } - if (isset($config['filename'])) { - $new_config['filename'] = $config['filename']; - } - logger()->info("Fetching source {$source} from custom url [{$ni}/{$cnt}]"); - Downloader::downloadSource($source, $new_config, true); - } else { - logger()->info("Fetching source {$source} [{$ni}/{$cnt}]"); - Downloader::downloadSource($source, Config::getSource($source)); - } - } - // 打印拉取资源用时 - $time = round(microtime(true) - START_TIME, 3); - logger()->info('Download complete, used ' . $time . ' s !'); - return static::SUCCESS; } private function downloadFromZip(string $path): int diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 2a2dd522..affeac88 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -335,7 +335,7 @@ class Downloader logger()->warning('Deleting download file: ' . $filename); unlink(DOWNLOAD_PATH . '/' . $filename); } - throw $e; + throw new DownloaderException('Download failed! ' . $e->getMessage()); } } From 8dcec73929e07ca71af94424fae20b6ee2892b02 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 23 Oct 2023 22:27:19 +0800 Subject: [PATCH 257/296] let bzip2 use correct CC and AR --- src/SPC/builder/unix/library/bzip2.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/bzip2.php b/src/SPC/builder/unix/library/bzip2.php index 8de623d4..1ff87bb2 100644 --- a/src/SPC/builder/unix/library/bzip2.php +++ b/src/SPC/builder/unix/library/bzip2.php @@ -8,9 +8,14 @@ trait bzip2 { protected function build(): void { + $cc = getenv('CC'); + $ar = getenv('AR'); + if ($ar === false) { + $ar = 'ar'; + } shell()->cd($this->source_dir) ->exec("make PREFIX='" . BUILD_ROOT_PATH . "' clean") - ->exec("make -j{$this->builder->concurrency} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a") + ->exec("make -j{$this->builder->concurrency} PREFIX='" . BUILD_ROOT_PATH . "' CC={$cc} AR={$ar} libbz2.a") ->exec('cp libbz2.a ' . BUILD_LIB_PATH) ->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH); } From d381e486057e85325401662e19c90b2f5aa4404c Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 23 Oct 2023 22:44:42 +0800 Subject: [PATCH 258/296] Update README-en.md --- README-en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-en.md b/README-en.md index a6ce40fd..2ee87dac 100755 --- a/README-en.md +++ b/README-en.md @@ -2,7 +2,7 @@ Build single static PHP binary, with PHP project together, with popular extensions included. -The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎 +The project name is static-php-cli, but it actually supports **cli**, **fpm**, **micro** and **embed** SAPI 😎 Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI) From c24dc8f5186fbe9687874939ee8f6793cbc29488 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 24 Oct 2023 12:21:36 +0200 Subject: [PATCH 259/296] create helper method to pass environment variables to 'make' --- src/SPC/builder/BuilderBase.php | 12 ++++++++++++ src/SPC/builder/linux/LinuxBuilder.php | 5 +++-- src/SPC/builder/unix/library/bzip2.php | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index eb18f485..6e46886f 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -319,6 +319,18 @@ abstract class BuilderBase $this->options[$key] = $value; } + public function getEnvString(array $vars = ['cc', 'cxx', 'ar', 'ld']): string + { + $env = []; + foreach ($vars as $var) { + $var = strtoupper($var); + if (getenv($var) !== false) { + $env[] = "{$var}=" . getenv($var); + } + } + return implode(' ', $env); + } + /** * Check if all libs are downloaded. * If not, throw exception. diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 1aa6cdc9..73d47acc 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -45,8 +45,8 @@ class LinuxBuilder extends BuilderBase f_putenv("CC={$this->getOption('cc', "{$arch}-linux-musl-gcc")}"); f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}"); f_putenv("AR={$this->getOption('ar', "{$arch}-linux-musl-ar")}"); - f_putenv("LD={$this->getOption('ld', "/usr/local/musl/{$arch}-linux-musl/bin/ld.gold")}"); - f_putenv('PATH=/usr/local/musl/bin:/usr/local/musl/' . $arch . '-linux-musl/bin:' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); + f_putenv("LD={$this->getOption('ld', 'ld.gold')}"); + f_putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); // set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused) $this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); @@ -176,6 +176,7 @@ class LinuxBuilder extends BuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec( + "{$this->getOption('ld_library_path')} " . './configure ' . '--prefix= ' . '--with-valgrind=no ' . diff --git a/src/SPC/builder/unix/library/bzip2.php b/src/SPC/builder/unix/library/bzip2.php index 8de623d4..71990125 100644 --- a/src/SPC/builder/unix/library/bzip2.php +++ b/src/SPC/builder/unix/library/bzip2.php @@ -10,7 +10,7 @@ trait bzip2 { shell()->cd($this->source_dir) ->exec("make PREFIX='" . BUILD_ROOT_PATH . "' clean") - ->exec("make -j{$this->builder->concurrency} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a") + ->exec("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a") ->exec('cp libbz2.a ' . BUILD_LIB_PATH) ->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH); } From f25d2d5db46f4fb4bd70f5fc5f21c446aa5d058c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 26 Oct 2023 20:17:17 +0800 Subject: [PATCH 260/296] Decided to change README default language to English --- README-en.md | 259 +------------------------------------------------ README-zh.md | 248 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 265 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 408 insertions(+), 364 deletions(-) create mode 100755 README-zh.md diff --git a/README-en.md b/README-en.md index a6ce40fd..505fd70a 100755 --- a/README-en.md +++ b/README-en.md @@ -1,260 +1,3 @@ # static-php-cli -Build single static PHP binary, with PHP project together, with popular extensions included. - -The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎 - -Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI) - -2023-05-02 15 53 13 - -You can also use the micro binary file to combine php binary and php source code into one for distribution! (micro SAPI) - -2023-05-02 15 52 33 - -> This SAPI feature is from the [Fork](https://github.com/crazywhalecc/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro). - - -[![Version](https://img.shields.io/badge/Version-2.0--rc5-pink.svg?style=flat-square)]() -[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) - -[![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() -[![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() - -## Compilation Requirements - -Yes, this project is written in PHP, pretty funny. -But static-php-cli runtime only requires an environment above PHP 8.1 and `mbstring`, `pcntl` extension. - -Here is the architecture support status, where `CI` represents support for GitHub Action builds, -`Local` represents support for local builds, and blank represents not currently supported. - -| | x86_64 | aarch64 | -|---------|-----------|-----------| -| macOS | CI, Local | Local | -| Linux | CI, Local | CI, Local | -| Windows | | | -| FreeBSD | Local | Local | - -> macOS-arm64 is not supported for GitHub Actions, if you are going to build on arm, you can build it manually on your own machine. - -Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`. - -## Docs - -docs here: . - -## Simple Usage - -Please first select the extension you want to compile based on the extension list below. - -### Direct Download - -If you don't compile yourself, you can download pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.static-php.dev/static-php-cli/common/) - -> self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` - -### Supported Extensions - -[Supported Extension List](https://static-php.dev/en/guide/extensions.html) - -> If there is no extension you need here, you can submit an issue. - -### GitHub Actions Build - -Use GitHub Action to easily build a statically compiled PHP and phpmicro, -and at the same time define the extensions to be compiled by yourself. - -1. Fork me. -2. Go to the Actions of the project and select `CI`. -3. Select `Run workflow`, fill in the PHP version you want to compile, the target type, and the list of extensions. (extensions comma separated, e.g. `bcmath,curl,mbstring`) -4. After waiting for about a period of time, enter the corresponding task and get `Artifacts`. - -If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting. - -- When using ubuntu-latest, it will build linux-x86_64 binary. -- When using macos-latest, it will build macOS-x86_64 binary. - -### Manual Build - -Clone repo first: - -```bash -git clone https://github.com/crazywhalecc/static-php-cli.git -``` - -If you have not installed php on your system, you can use package management to install PHP (such as brew, apt, yum, apk etc.). - -And you can also download single-file php binary and composer using command `bin/setup-runtime`. -The PHP runtime for static-php-cli itself will be downloaded at `bin/php`, and composer is at `bin/composer`. - -```bash -cd static-php-cli -chmod +x bin/setup-runtime -# It will download php-cli from self-hosted server and composer from getcomposer.org -./bin/setup-runtime - -# Use this php runtime to run static-php-cli compiler -./bin/php bin/spc - -# Use composer -./bin/php bin/composer -``` - -Basic usage for building php and micro with some extensions: - -```bash -cd static-php-cli -composer update -chmod +x bin/spc -# Check system tool dependencies, fix them automatically -./bin/spc doctor -# fetch all libraries -./bin/spc fetch --all -# with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI -./bin/spc build bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl --build-cli --build-micro -``` - -You can also use the parameter `--with-php=x.y` to specify the downloaded PHP version, currently supports 7.4 ~ 8.2: - -```bash -# Using PHP >= 8.0 is recommended, because PHP7 cannot use phpmicro -./bin/spc fetch --with-php=8.2 --all -``` - -Now we support `cli`, `micro`, `fpm`, you can use one or more of the following parameters to specify the compiled SAPI: - -- `--build-cli`: build static cli executable -- `--build-micro`: build static phpmicro self-extracted executable -- `--build-fpm`: build static fpm binary -- `--build-embed`: build embed (libphp) -- `--build-all`: build all - -If anything goes wrong, use `--debug` option to display full terminal output: - -```bash -./bin/spc build openssl,pcntl,mbstring --debug --build-all -./bin/spc fetch --all --debug -``` - -In addition, we build NTS by default. If you are going to build ZTS version, just add `--enable-zts` option. - -```bash -./bin/spc build openssl,pcntl --build-all --enable-zts -``` - -Adding option `--no-strip` can produce binaries with debug symbols, in order to debug (using gdb). Disabling strip will increase the size of static binary. - -### php-cli Usage - -> php-cli is a single static binary, you can use it like normal php installed on your system. - -When using the parameter `--build-cli` or `--build-all`, -the final compilation result will output a binary file named `./php`, -which can be distributed and used directly. -This file will be located in the directory `buildroot/bin/`, copy it out for use. - -```bash -cd buildroot/bin/ -./php -v # check version -./php -m # check extensions -./php your_code.php # run your php code -./php your_project.phar # run your phar (project archive) -``` - -### micro.sfx Usage - -> phpmicro is a SelF-extracted eXecutable SAPI module, -> provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro). -> It can put php runtime and your source code together. - -When using the parameter `--build-all` or `--build-micro`, -the final compilation result will output a file named `./micro.sfx`, -which needs to be used with your PHP source code like `code.php`. -This file will be located in the path `buildroot/bin/micro.sfx`, simply copy it out for use. - -Prepare your project source code, which can be a single PHP file or a Phar file, for use. - -```bash -echo " code.php -cat micro.sfx code.php > single-app && chmod +x single-app -./single-app - -# If packing a PHAR file, replace code.php with the Phar file path. -``` - -> In some cases, PHAR files may not run in a micro environment. - -### php-fpm Usage - -When using the parameter `--build-all` or `--build-fpm`, -the final compilation result will output a file named `./php-fpm`, -This file will be located in the path `buildroot/bin/`, simply copy it out for use. - -In normal Linux distributions and macOS systems, the package manager will automatically generate a default fpm configuration file after installing php-fpm. -Because php-fpm must specify a configuration file before running, the php-fpm compiled by this project will not have any configuration files, so you need to write `php-fpm.conf` and `pool.conf` configuration files yourself. - -Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`. - -### Embed Usage - -When using the project parameters `--build-embed` or `--build-all`, -the final compilation result will output a `libphp.a`, `php-config` and a series of header files, -stored in `buildroot/`. You can introduce them in your other projects. - -If you know [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed), you should know how to use it. -You may require the introduction of other libraries during compilation, -you can use `buildroot/bin/php-config` to obtain the compile-time configuration. - -For an advanced example of how to use this feature, take a look at [how to use it to build a static version of FrankenPHP](https://github.com/dunglas/frankenphp/blob/main/docs/static.md). - -## Contribution - -If the extension you need is missing, you can create an issue. -If you are familiar with this project, you are also welcome to initiate a pull request. - -The basic principles for contributing are as follows: - -- This project uses php-cs-fixer and phpstan as code formatting tools. Before contributing, please run `composer analyse` and `composer cs-fix` on the updated code. -- If other open source libraries are involved, the corresponding licenses should be provided. - Also, configuration files should be sorted using the command `sort-config` after modification. - For more information about sorting commands, see the documentation. -- Naming conventions should be followed, such as using the extension name registered in PHP for the extension name itself, - and external library names should follow the project's own naming conventions. For internal logic functions, class names, variables, etc., - camelCase and underscore formats should be followed, and mixing within the same module is prohibited. -- When compiling external libraries and creating patches, compatibility with different operating systems should be considered. - -If you want to contribute document content, please go to [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs). - -Part of the English document is written by me, and part is translated by Google, -and there may be inaccurate descriptions, strange or offensive expressions. -If you are a native English speaker, some corrections to the documentation are welcome. - - -## Sponsor this project - -You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). - -## Open-Source License - -This project itself is based on MIT License, -some newly added extensions and dependencies may originate from the following projects (including but not limited to), -and the headers of these code files will also be given additional instructions LICENSE and AUTHOR: - -- [dixyes/lwmbs](https://github.com/dixyes/lwmbs) (Mulun Permissive License) -- [swoole/swoole-cli](https://github.com/swoole/swoole-cli) (Apache 2.0 LICENSE+SWOOLE-CLI LICENSE) - -Due to the special nature of this project, -many other open source projects such as curl and protobuf will be used during the project compilation process, -and they all have their own open source licenses. - -Please use the `bin/spc dump-license` command to export the open source licenses used in the project after compilation, -and comply with the corresponding project's LICENSE. - -## Advanced - -The refactoring branch of this project is written modularly. -If you are interested in this project and want to join the development, -you can refer to the [Contribution Guide](https://static-php.dev) of the documentation to contribute code or documentation. +English README has been moved to [README.md](README.md). diff --git a/README-zh.md b/README-zh.md new file mode 100755 index 00000000..a03053d1 --- /dev/null +++ b/README-zh.md @@ -0,0 +1,248 @@ +# static-php-cli + +Build single static PHP binary, with PHP project together, with popular extensions included. + +🌐 **[中文](README-zh.md)** | **[English](README.md)** + +编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携!(cli SAPI) + +截屏2023-05-02 15 53 13 + +同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发!(micro SAPI) + +截屏2023-05-02 15 52 33 + +> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/crazywhalecc/phpmicro)。 + +[![Version](https://img.shields.io/badge/Version-2.0--rc5-pink.svg?style=flat-square)]() +[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() +[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) +[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) +[![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() +[![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() + +> 项目名称是 static-php-cli,但其实支持 cli、fpm、micro 和 embed SAPI 😎 + +## 编译环境需求 + +是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。 +但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 mbstring、pcntl 扩展和 PHP 版本大于等于 8.1 即可。 + +下面是架构支持情况,`CI` 代表支持 GitHub Action 构建,`Local` 代表支持本地构建,空 代表暂不支持。 + +| | x86_64 | aarch64 | +|---------|-----------|-----------| +| macOS | CI, Local | Local | +| Linux | CI, Local | CI, Local | +| Windows | | | +| FreeBSD | Local | Local | + +> macOS-arm64 因 GitHub 暂未提供 arm runner,如果要构建 arm 二进制,可以使用手动构建。 + +目前支持编译的 PHP 版本为:`7.3`,`7.4`,`8.0`,`8.1`,`8.2`,`8.3`。 + +## 文档 + +点击这里查看文档:。 + +## 使用 + +请先根据下方扩展列表选择你要编译的扩展。 + +### 自托管直接下载 + +如果你不想自行编译,可以从本项目现有的 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.static-php.dev/static-php-cli/common/) + +> 自托管的服务器默认包含的扩展有:`bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` + +### 支持的扩展情况 + +[扩展支持列表](https://static-php.dev/zh/guide/extensions.html) + +> 如果这里没有你需要的扩展,可以提交 Issue。 + +### 使用 Actions 构建 + +使用 GitHub Action 可以方便地构建一个静态编译的 PHP 和 phpmicro,同时可以自行定义要编译的扩展。 + +1. Fork 本项目。 +2. 进入项目的 Actions,选择 CI。 +3. 选择 `Run workflow`,填入你要编译的 PHP 版本、目标类型、扩展列表。(扩展列表使用英文逗号分割,例如 `bcmath,curl,mbstring`) +4. 等待大约一段时间后,进入对应的任务中,获取 `Artifacts`。 + +如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。 + +### 手动构建(使用 SPC 二进制) + +本项目提供了一个 static-php-cli 的二进制文件,你可以直接下载对应平台的二进制文件,然后使用它来构建静态的 PHP。目前 `spc` 二进制支持的平台有 Linux 和 macOS。 + +下面是从 GitHub Action 下载的方法: + +1. 进入 [GitHub Action](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml)。 +2. 选择一个最新的构建任务,进入后选择 `Artifacts`,下载对应平台的二进制文件。 +3. 解压 `.zip` 文件。解压后,为其添加执行权限:`chmod +x ./spc`。 + +你也可以从自托管的服务器下载二进制文件:[进入](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/)。 + +### 手动构建(使用源码) + +先克隆本项目: + +```bash +git clone https://github.com/crazywhalecc/static-php-cli.git +``` + +如果你本机没有安装 PHP,你需要先使用包管理(例如 brew、apt、yum、apk 等)安装 php。 + +你也可以通过 `bin/setup-runtime` 命令下载静态编译好的 php-cli 和 Composer。下载的 php 和 Composer 将保存为 `bin/php` 和 `bin/composer`。 + +```bash +cd static-php-cli +chmod +x bin/setup-runtime +./bin/setup-runtime + +# 使用独立的 php 运行 static-php-cli +./bin/php bin/spc + +# 使用 composer +./bin/php bin/composer + +# 初始化本项目 +cd static-php-cli +composer update +chmod +x bin/spc +``` + +### 使用 static-php-cli 命令行程序 + +下面是使用 static-php-cli 编译静态 php 和 micro 的基础用法: + +> 如果你使用的是打包好的 `spc` 二进制,你需要将下列命令的 `bin/spc` 替换为 `./spc`。 + +```bash +# 检查环境依赖,并根据提示的命令安装缺失的编译工具 +./bin/spc doctor +# 拉取所有依赖库 +./bin/spc fetch --all +# 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx +./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro +``` + +你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.3 ~ 8.2: + +```bash +# 优先考虑使用 >= 8.0 的 PHP 版本,因为 phpmicro 不支持在 PHP7 中构建 +./bin/spc download --with-php=8.2 --all +``` + +其中,目前支持构建 cli,micro,fpm 三种静态二进制,使用以下参数的一个或多个来指定编译的 SAPI: + +- `--build-cli`:构建 cli 二进制 +- `--build-micro`:构建 phpmicro 自执行二进制 +- `--build-fpm`:构建 fpm +- `--build-embed`:构建 embed(libphp) +- `--build-all`:构建所有 + +如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误: + +```bash +./bin/spc build openssl,pcntl,mbstring --debug --build-all +./bin/spc fetch --all --debug +``` + +此外,默认编译的 PHP 为 NTS 版本。如需编译线程安全版本(ZTS),只需添加参数 `--enable-zts` 即可。 + +```bash +./bin/spc build openssl,pcntl --build-all --enable-zts +``` + +同时,你也可以使用参数 `--no-strip` 来关闭裁剪,关闭裁剪后可以使用 gdb 等工具调试,但这样会让静态二进制体积变大。 + +### 使用 php-cli + +> php-cli 是一个静态的二进制文件,类似 Go、Rust 语言编译后的单个可移植的二进制文件。 + +采用参数 `--build-cli` 或`--build-all` 参数时,最后编译结果会输出一个 `./php` 的二进制文件,此文件可分发、可直接使用。 +该文件编译后会存放在 `buildroot/bin/` 目录中,名称为 `php`,拷贝出来即可。 + +```bash +cd buildroot/bin/ +./php -v # 检查版本 +./php -m # 检查编译的扩展 +./php your_code.php # 运行代码 +./php your_project.phar # 运行打包为 phar 单文件的项目 +``` + +### 使用 micro.sfx + +> phpmicro 是一个提供自执行二进制 PHP 的项目,本项目依赖 phpmicro 进行编译自执行二进制。详见 [dixyes/phpmicro](https://github.com/dixyes/phpmicro)。 + +采用项目参数 `--build-micro` 或 `--build-all` 时,最后编译结果会输出一个 `./micro.sfx` 的文件,此文件需要配合你的 PHP 源码使用。 +该文件编译后会存放在 `buildroot/bin/` 目录中,拷贝出来即可。 + +使用时应准备好你的项目源码文件,可以是单个 PHP 文件,也可以是 Phar 文件。 + +```bash +echo " code.php +cat micro.sfx code.php > single-app && chmod +x single-app +./single-app +``` + +如果打包 PHAR 文件,仅需把 code.php 更换为 phar 文件路径即可。 +你可以使用 [box-project/box](https://github.com/box-project/box) 将你的 CLI 项目打包为 Phar, +然后将它与 phpmicro 结合,生成独立可执行的二进制文件。 + +```bash +# 使用 static-php-cli 生成的 micro.sfx 结合,也可以直接使用 cat 命令结合它们 +bin/spc micro:combine my-app.phar +cat buildroot/bin/micro.sfx my-app.phar > my-app && chmod +x my-app + +# 使用 micro:combine 结合可以将 INI 选项注入到二进制中 +bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=system" --output my-app-2 +``` + +> 有些情况下的 phar 文件或 PHP 项目可能无法在 micro 环境下运行。 + +### 使用 php-fpm + +采用项目参数 `--build-fpm` 或 `--build-all` 时,最后编译结果会输出一个 `./php-fpm` 的文件。 +该文件存放在 `buildroot/bin/` 目录,拷贝出来即可使用。 + +在正常的 Linux 发行版和 macOS 系统中,安装 php-fpm 后包管理会自动生成默认的 fpm 配置文件。 +因为 php-fpm 必须指定配置文件才可启动,本项目编译的 php-fpm 不会带任何配置文件,所以需自行编写 `php-fpm.conf` 和 `pool.conf` 配置文件。 + +指定 `php-fpm.conf` 可以使用命令参数 `-y`,例如:`./php-fpm -y php-fpm.conf`。 + +### 使用 php-embed + +采用项目参数 `--build-embed` 或 `--build-all` 时,最后编译结果会输出一个 `libphp.a`、`php-config` 以及一系列头文件,存放在 `buildroot/`,你可以在你的其他代码中引入它们。 + +如果你知道 [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed),你应该知道如何使用它。对于有可能编译用到引入其他库的问题,你可以使用 `buildroot/bin/php-config` 来获取编译时的配置。 + +另外,有关如何使用此功能的高级示例,请查看[如何使用它构建 FrankenPHP 的静态版本](https://github.com/dunglas/frankenphp/blob/main/docs/static.md)。 + +## 贡献 + +如果缺少你需要的扩展,可发起 Issue。如果你对本项目较熟悉,也欢迎为本项目发起 Pull Request。 + +另外,添加新扩展的贡献方式,可以参考下方 `进阶`。 + +如果你想贡献文档内容,请到项目仓库 [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs) 贡献。 + +## 赞助本项目 + +你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。 + +## 开源协议 + +本项目依据旧版本惯例采用 MIT License 开源,部分扩展的集成编译命令参考或修改自以下项目: + +- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)(木兰宽松许可证) +- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)(Apache 2.0 LICENSE、SWOOLE-CLI LICENSE) + +因本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。 +请在编译完成后,使用命令 `bin/spc dump-license` 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。 + +## 进阶 + +本项目重构分支为模块化编写。如果你对本项目感兴趣,想加入开发,可以参照文档的 [贡献指南](https://static-php.dev) 贡献代码或文档。 diff --git a/README.md b/README.md index ca3d0f0f..3bd471fc 100755 --- a/README.md +++ b/README.md @@ -2,35 +2,35 @@ Build single static PHP binary, with PHP project together, with popular extensions included. -**If you are using English, see [English README](README-en.md).** +🌐 **[中文](README-zh.md)** | **[English](README.md)** -> 项目别名:standalone-php-compiler +The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎 -编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携!(cli SAPI) +Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI) -截屏2023-05-02 15 53 13 +2023-05-02 15 53 13 -同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发!(micro SAPI) +You can also use the micro binary file to combine php binary and php source code into one for distribution! (micro SAPI) -截屏2023-05-02 15 52 33 +2023-05-02 15 52 33 -> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/crazywhalecc/phpmicro)。 +> This SAPI feature is from the [Fork](https://github.com/crazywhalecc/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro). -[![Version](https://img.shields.io/badge/Version-2.0--rc5-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc7-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) + [![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() -> 项目名称是 static-php-cli,但其实支持 cli、fpm、micro 和 embed SAPI 😎 +## Compilation Requirements -## 编译环境需求 +Yes, this project is written in PHP, pretty funny. +But static-php-cli runtime only requires an environment above PHP 8.1 and `mbstring`, `pcntl` extension. -是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。 -但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 mbstring、pcntl 扩展和 PHP 版本大于等于 8.1 即可。 - -下面是架构支持情况,`CI` 代表支持 GitHub Action 构建,`Local` 代表支持本地构建,空 代表暂不支持。 +Here is the architecture support status, where `CI` represents support for GitHub Action builds, +`Local` represents support for local builds, and blank represents not currently supported. | | x86_64 | aarch64 | |---------|-----------|-----------| @@ -39,191 +39,244 @@ Build single static PHP binary, with PHP project together, with popular extensio | Windows | | | | FreeBSD | Local | Local | -> macOS-arm64 因 GitHub 暂未提供 arm runner,如果要构建 arm 二进制,可以使用手动构建。 +> macOS-arm64 is not supported for GitHub Actions, if you are going to build on arm, you can build it manually on your own machine. -目前支持编译的 PHP 版本为:`7.3`,`7.4`,`8.0`,`8.1`,`8.2`,`8.3`。 +Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`. -## 文档 +## Docs -点击这里查看文档:。 +docs here: . -## 使用 +## Simple Usage -请先根据下方扩展列表选择你要编译的扩展。 +Please first select the extension you want to compile based on the extension list below. -### 自托管直接下载 +### Direct Download -如果你不想自行编译,可以从本项目现有的 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.static-php.dev/static-php-cli/common/) +If you don't compile yourself, you can download example pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.static-php.dev/static-php-cli/common/) -> 自托管的服务器默认包含的扩展有:`bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` +> self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` -### 支持的扩展情况 +### Supported Extensions -[扩展支持列表](https://static-php.dev/zh/guide/extensions.html) +[Supported Extension List](https://static-php.dev/en/guide/extensions.html) -> 如果这里没有你需要的扩展,可以提交 Issue。 +> If an extension you need is missing, you can submit an issue. -### 使用 Actions 构建 +### GitHub Actions Build -使用 GitHub Action 可以方便地构建一个静态编译的 PHP 和 phpmicro,同时可以自行定义要编译的扩展。 +Use GitHub Action to easily build a statically compiled PHP and phpmicro, +and at the same time define the extensions to be compiled by yourself. -1. Fork 本项目。 -2. 进入项目的 Actions,选择 CI。 -3. 选择 `Run workflow`,填入你要编译的 PHP 版本、目标类型、扩展列表。(扩展列表使用英文逗号分割,例如 `bcmath,curl,mbstring`) -4. 等待大约一段时间后,进入对应的任务中,获取 `Artifacts`。 +1. Fork me. +2. Go to the Actions of the project and select `CI`. +3. Select `Run workflow`, fill in the PHP version you want to compile, the target type, and the list of extensions. (extensions comma separated, e.g. `bcmath,curl,mbstring`) +4. After waiting for about a period of time, enter the corresponding task and get `Artifacts`. -如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。 +If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting. -### 手动构建 +- When using ubuntu-latest, it will build linux-x86_64 binary. +- When using macos-latest, it will build macOS-x86_64 binary. -先克隆本项目: +### Manual build (using SPC binary) + +This project provides a binary file of static-php-cli. +You can directly download the binary file of the corresponding platform and then use it to build static PHP. +Currently, the platforms supported by `spc` binary are Linux and macOS. + +Here's how to download from GitHub Actions: + +1. Enter [GitHub Actions](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml). +2. Select the latest build task, select `Artifacts`, and download the binary file of the corresponding platform. +3. Unzip the `.zip` file. After decompressing, add execution permissions to it: `chmod +x ./spc`. + +You can also download binaries from a self-hosted server: [enter](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/). + +### Manual build (using source code) + +Clone repo first: ```bash git clone https://github.com/crazywhalecc/static-php-cli.git ``` -如果你本机没有安装 PHP,你需要先使用包管理(例如 brew、apt、yum、apk 等)安装 php。 +If you have not installed php on your system, you can use package management to install PHP (such as brew, apt, yum, apk etc.). -你也可以通过 `bin/setup-runtime` 命令下载静态编译好的 php-cli 和 Composer。下载的 php 和 Composer 将保存为 `bin/php` 和 `bin/composer`。 +And you can also download single-file php binary and composer using command `bin/setup-runtime`. +The PHP runtime for static-php-cli itself will be downloaded at `bin/php`, and composer is at `bin/composer`. ```bash cd static-php-cli chmod +x bin/setup-runtime +# It will download php-cli from self-hosted server and composer from getcomposer.org ./bin/setup-runtime -# 使用独立的 php 运行 static-php-cli +# Use this php runtime to run static-php-cli compiler ./bin/php bin/spc -# 使用 composer +# Use composer ./bin/php bin/composer -``` -下面是使用 static-php-cli 编译静态 php 和 micro 的基础用法: - -```bash -# 克隆本项目 +# Initialize this project cd static-php-cli composer update chmod +x bin/spc -# 检查环境依赖,并根据提示的命令安装缺失的编译工具 -./bin/spc doctor -# 拉取所有依赖库 -./bin/spc fetch --all -# 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx -./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro ``` -你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.3 ~ 8.3: +### Use static-php-cli + +Basic usage for building php and micro with some extensions: + +> If you are using the packaged `spc` binary, you need to replace `bin/spc` with `./spc` in the following commands. ```bash -# 优先考虑使用 >= 8.0 的 PHP 版本,因为 phpmicro 不支持在 PHP7 中构建 +# Check system tool dependencies, fix them automatically +./bin/spc doctor +# fetch all libraries +./bin/spc fetch --all +# with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI +./bin/spc build bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl --build-cli --build-micro +``` + +You can also use the parameter `--with-php=x.y` to specify the downloaded PHP version, currently supports 7.4 ~ 8.2: + +```bash +# Using PHP >= 8.0 is recommended, because PHP7 cannot use phpmicro ./bin/spc fetch --with-php=8.2 --all ``` -其中,目前支持构建 cli,micro,fpm 三种静态二进制,使用以下参数的一个或多个来指定编译的 SAPI: +Now we support `cli`, `micro`, `fpm`, you can use one or more of the following parameters to specify the compiled SAPI: -- `--build-cli`:构建 cli 二进制 -- `--build-micro`:构建 phpmicro 自执行二进制 -- `--build-fpm`:构建 fpm -- `--build-embed`:构建 embed(libphp) -- `--build-all`:构建所有 +- `--build-cli`: build static cli executable +- `--build-micro`: build static phpmicro self-extracted executable +- `--build-fpm`: build static fpm binary +- `--build-embed`: build embed (libphp) +- `--build-all`: build all -如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误: +If anything goes wrong, use `--debug` option to display full terminal output: ```bash ./bin/spc build openssl,pcntl,mbstring --debug --build-all ./bin/spc fetch --all --debug ``` -此外,默认编译的 PHP 为 NTS 版本。如需编译线程安全版本(ZTS),只需添加参数 `--enable-zts` 即可。 +In addition, we build NTS by default. If you are going to build ZTS version, just add `--enable-zts` option. ```bash ./bin/spc build openssl,pcntl --build-all --enable-zts ``` -同时,你也可以使用参数 `--no-strip` 来关闭裁剪,关闭裁剪后可以使用 gdb 等工具调试,但这样会让静态二进制体积变大。 +Adding option `--no-strip` can produce binaries with debug symbols, in order to debug (using gdb). Disabling strip will increase the size of static binary. -### 使用 php-cli +### php-cli Usage -> php-cli 是一个静态的二进制文件,类似 Go、Rust 语言编译后的单个可移植的二进制文件。 +> php-cli is a single static binary, you can use it like normal php installed on your system. -采用参数 `--build-cli` 或`--build-all` 参数时,最后编译结果会输出一个 `./php` 的二进制文件,此文件可分发、可直接使用。 -该文件编译后会存放在 `buildroot/bin/` 目录中,名称为 `php`,拷贝出来即可。 +When using the parameter `--build-cli` or `--build-all`, +the final compilation result will output a binary file named `./php`, +which can be distributed and used directly. +This file will be located in the directory `buildroot/bin/`, copy it out for use. ```bash cd buildroot/bin/ -./php -v # 检查版本 -./php -m # 检查编译的扩展 -./php your_code.php # 运行代码 -./php your_project.phar # 运行打包为 phar 单文件的项目 +./php -v # check version +./php -m # check extensions +./php your_code.php # run your php code +./php your_project.phar # run your phar (project archive) ``` -### 使用 micro.sfx +### micro.sfx Usage -> phpmicro 是一个提供自执行二进制 PHP 的项目,本项目依赖 phpmicro 进行编译自执行二进制。详见 [dixyes/phpmicro](https://github.com/dixyes/phpmicro)。 +> phpmicro is a SelF-extracted eXecutable SAPI module, +> provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro). +> It can put php runtime and your source code together. -采用项目参数 `--build-micro` 或 `--build-all` 时,最后编译结果会输出一个 `./micro.sfx` 的文件,此文件需要配合你的 PHP 源码使用。 -该文件编译后会存放在 `buildroot/bin/` 目录中,拷贝出来即可。 +When using the parameter `--build-all` or `--build-micro`, +the final compilation result will output a file named `./micro.sfx`, +which needs to be used with your PHP source code like `code.php`. +This file will be located in the path `buildroot/bin/micro.sfx`, simply copy it out for use. -使用时应准备好你的项目源码文件,可以是单个 PHP 文件,也可以是 Phar 文件。 +Prepare your project source code, which can be a single PHP file or a Phar file, for use. ```bash echo " code.php cat micro.sfx code.php > single-app && chmod +x single-app ./single-app - -# 如果打包 PHAR 文件,仅需把 code.php 更换为 phar 文件路径即可 ``` -> 有些情况下的 phar 文件可能无法在 micro 环境下运行。 +If you package a PHAR file, just replace `code.php` with the phar file path. +You can use [box-project/box](https://github.com/box-project/box) to package your CLI project as Phar, +It is then combined with phpmicro to produce a standalone executable binary. -### 使用 php-fpm +```bash +# Use the micro.sfx generated by static-php-cli to combine, +bin/spc micro:combine my-app.phar +# or you can directly use the cat command to combine them. +cat buildroot/bin/micro.sfx my-app.phar > my-app && chmod +x my-app -采用项目参数 `--build-fpm` 或 `--build-all` 时,最后编译结果会输出一个 `./php-fpm` 的文件。 -该文件存放在 `buildroot/bin/` 目录,拷贝出来即可使用。 +# Use micro:combine combination to inject INI options into the binary. +bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=system" --output my-app-2 +``` -在正常的 Linux 发行版和 macOS 系统中,安装 php-fpm 后包管理会自动生成默认的 fpm 配置文件。 -因为 php-fpm 必须指定配置文件才可启动,本项目编译的 php-fpm 不会带任何配置文件,所以需自行编写 `php-fpm.conf` 和 `pool.conf` 配置文件。 +> In some cases, PHAR files may not run in a micro environment. -指定 `php-fpm.conf` 可以使用命令参数 `-y`,例如:`./php-fpm -y php-fpm.conf`。 +### php-fpm Usage -### 使用 php-embed +When using the parameter `--build-all` or `--build-fpm`, +the final compilation result will output a file named `./php-fpm`, +This file will be located in the path `buildroot/bin/`, simply copy it out for use. -采用项目参数 `--build-embed` 或 `--build-all` 时,最后编译结果会输出一个 `libphp.a`、`php-config` 以及一系列头文件,存放在 `buildroot/`,你可以在你的其他代码中引入它们。 +In normal Linux distributions and macOS systems, the package manager will automatically generate a default fpm configuration file after installing php-fpm. +Because php-fpm must specify a configuration file before running, the php-fpm compiled by this project will not have any configuration files, so you need to write `php-fpm.conf` and `pool.conf` configuration files yourself. -如果你知道 [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed),你应该知道如何使用它。对于有可能编译用到引入其他库的问题,你可以使用 `buildroot/bin/php-config` 来获取编译时的配置。 +Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`. -另外,有关如何使用此功能的高级示例,请查看[如何使用它构建 FrankenPHP 的静态版本](https://github.com/dunglas/frankenphp/blob/main/docs/static.md)。 +### Embed Usage -## 贡献 +When using the project parameters `--build-embed` or `--build-all`, +the final compilation result will output a `libphp.a`, `php-config` and a series of header files, +stored in `buildroot/`. You can introduce them in your other projects. -如果缺少你需要的扩展,可发起 Issue。如果你对本项目较熟悉,也欢迎为本项目发起 Pull Request。 +If you know [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed), you should know how to use it. +You may require the introduction of other libraries during compilation, +you can use `buildroot/bin/php-config` to obtain the compile-time configuration. -贡献基本原则如下: +For an advanced example of how to use this feature, take a look at [how to use it to build a static version of FrankenPHP](https://github.com/dunglas/frankenphp/blob/main/docs/static.md). -- 项目采用了 php-cs-fixer、phpstan 作为代码规范工具,贡献前请对更新的代码执行 `composer analyze` 和 `composer cs-fix`。 -- 涉及到其他开源库的部分应提供对应库的协议,同时对配置文件在修改后采用命令 `sort-config` 排序。有关排序的命令,见文档。 -- 应遵循命名规范,例如扩展名称应采取 PHP 内注册的扩展名本身,外部库名应遵循项目本身的名称,内部逻辑的函数、类名、变量等应遵循驼峰、下划线等格式,禁止同一模块混用。 -- 涉及编译外部库的命令和 Patch 时应注意兼容不同操作系统。 +## Contribution -另外,添加新扩展的贡献方式,可以参考下方 `进阶`。 +If the extension you need is missing, you can create an issue. +If you are familiar with this project, you are also welcome to initiate a pull request. -如果你想贡献文档内容,请到项目仓库 [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs) 贡献。 +If you want to contribute document content, please go to [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs). -## 赞助本项目 +Part of the English document is written by me, and part is translated by Google, +and there may be inaccurate descriptions, strange or offensive expressions. +If you are a native English speaker, some corrections to the documentation are welcome. -你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。 -## 开源协议 +## Sponsor this project -本项目依据旧版本惯例采用 MIT License 开源,部分扩展的集成编译命令参考或修改自以下项目: +You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). -- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)(木兰宽松许可证) -- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)(Apache 2.0 LICENSE、SWOOLE-CLI LICENSE) +## Open-Source License -因本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。 -请在编译完成后,使用命令 `bin/spc dump-license` 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。 +This project itself is based on MIT License, +some newly added extensions and dependencies may originate from the following projects (including but not limited to), +and the headers of these code files will also be given additional instructions LICENSE and AUTHOR: -## 进阶 +- [dixyes/lwmbs](https://github.com/dixyes/lwmbs) (Mulun Permissive License) +- [swoole/swoole-cli](https://github.com/swoole/swoole-cli) (Apache 2.0 LICENSE+SWOOLE-CLI LICENSE) -本项目重构分支为模块化编写。如果你对本项目感兴趣,想加入开发,可以参照文档的 [贡献指南](https://static-php.dev) 贡献代码或文档。 +Due to the special nature of this project, +many other open source projects such as curl and protobuf will be used during the project compilation process, +and they all have their own open source licenses. + +Please use the `bin/spc dump-license` command to export the open source licenses used in the project after compilation, +and comply with the corresponding project's LICENSE. + +## Advanced + +The refactoring branch of this project is written modularly. +If you are interested in this project and want to join the development, +you can refer to the [Contribution Guide](https://static-php.dev) of the documentation to contribute code or documentation. From 5e0cccfe3dcebab8a7ae698e1777f9018356008a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 26 Oct 2023 20:20:17 +0800 Subject: [PATCH 261/296] Add --by-extensions for README --- README-zh.md | 2 ++ README.md | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README-zh.md b/README-zh.md index a03053d1..f8369cad 100755 --- a/README-zh.md +++ b/README-zh.md @@ -124,6 +124,8 @@ chmod +x bin/spc ./bin/spc doctor # 拉取所有依赖库 ./bin/spc fetch --all +# 只拉取编译指定扩展需要的所有依赖 +./bin/spc download --by-extensions=openssl,pcntl,mbstring,pdo_sqlite # 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx ./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro ``` diff --git a/README.md b/README.md index 3bd471fc..6f58e82f 100755 --- a/README.md +++ b/README.md @@ -133,7 +133,9 @@ Basic usage for building php and micro with some extensions: # Check system tool dependencies, fix them automatically ./bin/spc doctor # fetch all libraries -./bin/spc fetch --all +./bin/spc download --all +# only fetch necessary sources by needed extensions +./bin/spc download --by-extensions=openssl,pcntl,mbstring,pdo_sqlite # with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI ./bin/spc build bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl --build-cli --build-micro ``` From 29179ecb84a871a6de59e0f273076e0486d97a10 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 26 Oct 2023 20:28:35 +0800 Subject: [PATCH 262/296] Adjust new README --- README-zh.md | 10 +++++----- README.md | 12 +++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README-zh.md b/README-zh.md index f8369cad..9beb1999 100755 --- a/README-zh.md +++ b/README-zh.md @@ -14,7 +14,7 @@ Build single static PHP binary, with PHP project together, with popular extensio > 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/crazywhalecc/phpmicro)。 -[![Version](https://img.shields.io/badge/Version-2.0--rc5-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc7-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) @@ -23,6 +23,10 @@ Build single static PHP binary, with PHP project together, with popular extensio > 项目名称是 static-php-cli,但其实支持 cli、fpm、micro 和 embed SAPI 😎 +## 文档 + +目前 README 编写了基本用法。有关 static-php-cli 所有的功能,请点击这里查看文档:。 + ## 编译环境需求 是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。 @@ -41,10 +45,6 @@ Build single static PHP binary, with PHP project together, with popular extensio 目前支持编译的 PHP 版本为:`7.3`,`7.4`,`8.0`,`8.1`,`8.2`,`8.3`。 -## 文档 - -点击这里查看文档:。 - ## 使用 请先根据下方扩展列表选择你要编译的扩展。 diff --git a/README.md b/README.md index 6f58e82f..bf5e8f22 100755 --- a/README.md +++ b/README.md @@ -24,6 +24,11 @@ You can also use the micro binary file to combine php binary and php source code [![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() +## Docs + +The current README contains basic usage. For all the features of static-php-cli, +see . + ## Compilation Requirements Yes, this project is written in PHP, pretty funny. @@ -43,10 +48,6 @@ Here is the architecture support status, where `CI` represents support for GitHu Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`. -## Docs - -docs here: . - ## Simple Usage Please first select the extension you want to compile based on the extension list below. @@ -190,7 +191,8 @@ cd buildroot/bin/ ### micro.sfx Usage > phpmicro is a SelF-extracted eXecutable SAPI module, -> provided by [dixyes/phpmicro](https://github.com/dixyes/phpmicro). +> provided by [phpmicro](https://github.com/dixyes/phpmicro) project. +> But this project is using a [fork](https://github.com/crazywhalecc/phpmicro) of phpmicro, because we need to add some features to it. > It can put php runtime and your source code together. When using the parameter `--build-all` or `--build-micro`, From 970a74896a7196388eacb79556a1a604e3858855 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 26 Oct 2023 20:34:58 +0800 Subject: [PATCH 263/296] Adjust new README --- README-zh.md | 17 +++++++++-------- README.md | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/README-zh.md b/README-zh.md index 9beb1999..eb45bd2c 100755 --- a/README-zh.md +++ b/README-zh.md @@ -45,25 +45,26 @@ Build single static PHP binary, with PHP project together, with popular extensio 目前支持编译的 PHP 版本为:`7.3`,`7.4`,`8.0`,`8.1`,`8.2`,`8.3`。 -## 使用 +## 自托管直接下载 -请先根据下方扩展列表选择你要编译的扩展。 - -### 自托管直接下载 - -如果你不想自行编译,可以从本项目现有的 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.static-php.dev/static-php-cli/common/) +如果你不想自行编译 PHP,可以从本项目现有的示例 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.static-php.dev/static-php-cli/common/) > 自托管的服务器默认包含的扩展有:`bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` +## 使用 static-php-cli 构建 PHP + ### 支持的扩展情况 -[扩展支持列表](https://static-php.dev/zh/guide/extensions.html) +请先根据下方扩展列表选择你要编译的扩展。 + +- [扩展支持列表](https://static-php.dev/zh/guide/extensions.html) +- [编译命令生成器](https://static-php.dev/zh/guide/cli-generator.html) > 如果这里没有你需要的扩展,可以提交 Issue。 ### 使用 Actions 构建 -使用 GitHub Action 可以方便地构建一个静态编译的 PHP 和 phpmicro,同时可以自行定义要编译的扩展。 +使用 GitHub Action 可以方便地构建一个静态编译的 PHP,同时可以自行定义要编译的扩展。 1. Fork 本项目。 2. 进入项目的 Actions,选择 CI。 diff --git a/README.md b/README.md index bf5e8f22..432969e6 100755 --- a/README.md +++ b/README.md @@ -48,25 +48,26 @@ Here is the architecture support status, where `CI` represents support for GitHu Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`. -## Simple Usage +## Direct Download -Please first select the extension you want to compile based on the extension list below. - -### Direct Download - -If you don't compile yourself, you can download example pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.static-php.dev/static-php-cli/common/) +If you don't want to compile yourself, you can download example pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.static-php.dev/static-php-cli/common/) > self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` +## Use static-php-cli to build PHP + ### Supported Extensions -[Supported Extension List](https://static-php.dev/en/guide/extensions.html) +Please first select the extension you want to compile based on the extension list below. + +- [Supported Extension List](https://static-php.dev/en/guide/extensions.html) +- [Command Generator](https://static-php.dev/en/guide/cli-generator.html) > If an extension you need is missing, you can submit an issue. ### GitHub Actions Build -Use GitHub Action to easily build a statically compiled PHP and phpmicro, +Use GitHub Action to easily build a statically compiled PHP, and at the same time define the extensions to be compiled by yourself. 1. Fork me. From 9a5b02692de19cca53c94aaf526ff756e227750b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 26 Oct 2023 20:37:35 +0800 Subject: [PATCH 264/296] Adjust new README --- README-zh.md | 10 ++++++---- README.md | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README-zh.md b/README-zh.md index eb45bd2c..52f11220 100755 --- a/README-zh.md +++ b/README-zh.md @@ -161,7 +161,9 @@ chmod +x bin/spc 同时,你也可以使用参数 `--no-strip` 来关闭裁剪,关闭裁剪后可以使用 gdb 等工具调试,但这样会让静态二进制体积变大。 -### 使用 php-cli +## 不同 SAPI 的使用 + +### 使用 cli > php-cli 是一个静态的二进制文件,类似 Go、Rust 语言编译后的单个可移植的二进制文件。 @@ -176,7 +178,7 @@ cd buildroot/bin/ ./php your_project.phar # 运行打包为 phar 单文件的项目 ``` -### 使用 micro.sfx +### 使用 micro > phpmicro 是一个提供自执行二进制 PHP 的项目,本项目依赖 phpmicro 进行编译自执行二进制。详见 [dixyes/phpmicro](https://github.com/dixyes/phpmicro)。 @@ -206,7 +208,7 @@ bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=sys > 有些情况下的 phar 文件或 PHP 项目可能无法在 micro 环境下运行。 -### 使用 php-fpm +### 使用 fpm 采用项目参数 `--build-fpm` 或 `--build-all` 时,最后编译结果会输出一个 `./php-fpm` 的文件。 该文件存放在 `buildroot/bin/` 目录,拷贝出来即可使用。 @@ -216,7 +218,7 @@ bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=sys 指定 `php-fpm.conf` 可以使用命令参数 `-y`,例如:`./php-fpm -y php-fpm.conf`。 -### 使用 php-embed +### 使用 embed 采用项目参数 `--build-embed` 或 `--build-all` 时,最后编译结果会输出一个 `libphp.a`、`php-config` 以及一系列头文件,存放在 `buildroot/`,你可以在你的其他代码中引入它们。 diff --git a/README.md b/README.md index 432969e6..892d1a58 100755 --- a/README.md +++ b/README.md @@ -172,7 +172,9 @@ In addition, we build NTS by default. If you are going to build ZTS version, jus Adding option `--no-strip` can produce binaries with debug symbols, in order to debug (using gdb). Disabling strip will increase the size of static binary. -### php-cli Usage +## Different SAPI Usage + +### Use cli > php-cli is a single static binary, you can use it like normal php installed on your system. @@ -189,7 +191,7 @@ cd buildroot/bin/ ./php your_project.phar # run your phar (project archive) ``` -### micro.sfx Usage +### Use micro > phpmicro is a SelF-extracted eXecutable SAPI module, > provided by [phpmicro](https://github.com/dixyes/phpmicro) project. @@ -225,7 +227,7 @@ bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=sys > In some cases, PHAR files may not run in a micro environment. -### php-fpm Usage +### Use fpm When using the parameter `--build-all` or `--build-fpm`, the final compilation result will output a file named `./php-fpm`, @@ -236,7 +238,7 @@ Because php-fpm must specify a configuration file before running, the php-fpm co Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`. -### Embed Usage +### Use embed When using the project parameters `--build-embed` or `--build-all`, the final compilation result will output a `libphp.a`, `php-config` and a series of header files, From 549910927852ca1073ad856cdc099853e3a6aeac Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 26 Oct 2023 20:40:32 +0800 Subject: [PATCH 265/296] Adjust new README --- README-zh.md | 18 +++++++++--------- README.md | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README-zh.md b/README-zh.md index 52f11220..f2e25aa2 100755 --- a/README-zh.md +++ b/README-zh.md @@ -27,7 +27,15 @@ Build single static PHP binary, with PHP project together, with popular extensio 目前 README 编写了基本用法。有关 static-php-cli 所有的功能,请点击这里查看文档:。 -## 编译环境需求 +## 自托管直接下载 + +如果你不想自行编译 PHP,可以从本项目现有的示例 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.static-php.dev/static-php-cli/common/) + +> 自托管的服务器默认包含的扩展有:`bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` + +## 使用 static-php-cli 构建 PHP + +### 编译环境需求 是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。 但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 mbstring、pcntl 扩展和 PHP 版本大于等于 8.1 即可。 @@ -45,14 +53,6 @@ Build single static PHP binary, with PHP project together, with popular extensio 目前支持编译的 PHP 版本为:`7.3`,`7.4`,`8.0`,`8.1`,`8.2`,`8.3`。 -## 自托管直接下载 - -如果你不想自行编译 PHP,可以从本项目现有的示例 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.static-php.dev/static-php-cli/common/) - -> 自托管的服务器默认包含的扩展有:`bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` - -## 使用 static-php-cli 构建 PHP - ### 支持的扩展情况 请先根据下方扩展列表选择你要编译的扩展。 diff --git a/README.md b/README.md index 892d1a58..7a70448d 100755 --- a/README.md +++ b/README.md @@ -29,7 +29,15 @@ You can also use the micro binary file to combine php binary and php source code The current README contains basic usage. For all the features of static-php-cli, see . -## Compilation Requirements +## Direct Download + +If you don't want to compile yourself, you can download example pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.static-php.dev/static-php-cli/common/) + +> self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` + +## Use static-php-cli to build PHP + +### Compilation Requirements Yes, this project is written in PHP, pretty funny. But static-php-cli runtime only requires an environment above PHP 8.1 and `mbstring`, `pcntl` extension. @@ -48,14 +56,6 @@ Here is the architecture support status, where `CI` represents support for GitHu Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`. -## Direct Download - -If you don't want to compile yourself, you can download example pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.static-php.dev/static-php-cli/common/) - -> self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` - -## Use static-php-cli to build PHP - ### Supported Extensions Please first select the extension you want to compile based on the extension list below. From 98f32ae0f0696ba8a40e01aa47a08cd1d1393a28 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 26 Oct 2023 20:49:42 +0800 Subject: [PATCH 266/296] Use emoji --- README-zh.md | 14 +++++++------- README.md | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README-zh.md b/README-zh.md index f2e25aa2..ab86733b 100755 --- a/README-zh.md +++ b/README-zh.md @@ -40,14 +40,14 @@ Build single static PHP binary, with PHP project together, with popular extensio 是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。 但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 mbstring、pcntl 扩展和 PHP 版本大于等于 8.1 即可。 -下面是架构支持情况,`CI` 代表支持 GitHub Action 构建,`Local` 代表支持本地构建,空 代表暂不支持。 +下面是架构支持情况,:octocat: 代表支持 GitHub Action 构建,:computer: 代表支持本地构建,空 代表暂不支持。 -| | x86_64 | aarch64 | -|---------|-----------|-----------| -| macOS | CI, Local | Local | -| Linux | CI, Local | CI, Local | -| Windows | | | -| FreeBSD | Local | Local | +| | x86_64 | aarch64 | +|---------|----------------------|----------------------| +| macOS | :octocat: :computer: | :computer: | +| Linux | :octocat: :computer: | :octocat: :computer: | +| Windows | | | +| FreeBSD | :computer: | :computer: | > macOS-arm64 因 GitHub 暂未提供 arm runner,如果要构建 arm 二进制,可以使用手动构建。 diff --git a/README.md b/README.md index 7a70448d..8e75ff1f 100755 --- a/README.md +++ b/README.md @@ -42,15 +42,15 @@ If you don't want to compile yourself, you can download example pre-compiled art Yes, this project is written in PHP, pretty funny. But static-php-cli runtime only requires an environment above PHP 8.1 and `mbstring`, `pcntl` extension. -Here is the architecture support status, where `CI` represents support for GitHub Action builds, -`Local` represents support for local builds, and blank represents not currently supported. +Here is the architecture support status, where :octocat: represents support for GitHub Action builds, +:computer: represents support for local manual builds, and blank represents not currently supported. -| | x86_64 | aarch64 | -|---------|-----------|-----------| -| macOS | CI, Local | Local | -| Linux | CI, Local | CI, Local | -| Windows | | | -| FreeBSD | Local | Local | +| | x86_64 | aarch64 | +|---------|----------------------|----------------------| +| macOS | :octocat: :computer: | :computer: | +| Linux | :octocat: :computer: | :octocat: :computer: | +| Windows | | | +| FreeBSD | :computer: | :computer: | > macOS-arm64 is not supported for GitHub Actions, if you are going to build on arm, you can build it manually on your own machine. From e84a246dd22305afa33797a4114e860f194f5d78 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 27 Oct 2023 17:33:43 +0200 Subject: [PATCH 267/296] add back required -lgomp for imagick extension --- src/SPC/builder/extension/imagick.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index 3c225471..ef965d58 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -14,6 +14,7 @@ class imagick extends Extension { // imagick may call omp_pause_all which requires -lgomp $extra_libs = $this->builder->getOption('extra-libs', ''); + $extra_libs .= ' -lgomp '; $this->builder->setOption('extra-libs', $extra_libs); return true; } From d40f2cafecfc7034f1368cf2064cad5ea39c76f5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 27 Oct 2023 17:34:55 +0200 Subject: [PATCH 268/296] simplify libpng compilation --- src/SPC/builder/linux/library/libpng.php | 25 ++---------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index 3b6b2b6a..1946e925 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -20,36 +20,14 @@ declare(strict_types=1); namespace SPC\builder\linux\library; -use SPC\builder\linux\SystemUtil; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; -use SPC\store\FileSystem; class libpng extends LinuxLibraryBase { public const NAME = 'libpng'; - /** - * @throws FileSystemException - */ - public function patchBeforeBuild(): bool - { - FileSystem::replaceFileStr( - SOURCE_PATH . '/libpng/configure', - '-lz', - BUILD_LIB_PATH . '/libz.a' - ); - if (SystemUtil::getOSRelease()['dist'] === 'alpine') { - FileSystem::replaceFileStr( - SOURCE_PATH . '/libpng/configure', - '-lm', - '/usr/lib/libm.a' - ); - } - return true; - } - /** * @throws FileSystemException * @throws RuntimeException @@ -66,6 +44,7 @@ class libpng extends LinuxLibraryBase ->exec('chmod +x ./configure') ->exec('chmod +x ./install-sh') ->exec( + 'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' . './configure ' . '--disable-shared ' . '--enable-static ' . @@ -75,7 +54,7 @@ class libpng extends LinuxLibraryBase '--prefix=' ) ->exec('make clean') - ->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I. -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la") + ->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la") ->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX); $this->cleanLaFiles(); From 2e47e8af6b311acf836e6798a0f104e32c7cc638 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 27 Oct 2023 18:22:43 +0200 Subject: [PATCH 269/296] specify --with-openssl-dir in php ./configure I'm not sure if this is correct, please revert if it doesn't fix the issue --- config/ext.json | 2 +- src/SPC/builder/extension/openssl.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index f2698d5e..b18c8eb9 100644 --- a/config/ext.json +++ b/config/ext.json @@ -232,7 +232,7 @@ }, "openssl": { "type": "builtin", - "arg-type": "with", + "arg-type": "custom", "lib-depends": [ "openssl" ], diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index a81f24b5..44d0c5c7 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -22,4 +22,9 @@ class openssl extends Extension return false; } + + public function getUnixConfigureArg(): string + { + return '--with-openssl=' . BUILD_ROOT_PATH . ' --with-openssl-dir=' . BUILD_ROOT_PATH; + } } From 86ce7e9d25dee0988a83c3cd735a5802ea48bc3c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 29 Oct 2023 00:48:30 +0200 Subject: [PATCH 270/296] rename --by-extensions to --for-extensions --without-suggests to --without-suggestions --- README-zh.md | 2 +- README.md | 2 +- src/SPC/command/DownloadCommand.php | 12 ++++++------ src/SPC/command/DumpLicenseCommand.php | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README-zh.md b/README-zh.md index ab86733b..94f79ce7 100755 --- a/README-zh.md +++ b/README-zh.md @@ -126,7 +126,7 @@ chmod +x bin/spc # 拉取所有依赖库 ./bin/spc fetch --all # 只拉取编译指定扩展需要的所有依赖 -./bin/spc download --by-extensions=openssl,pcntl,mbstring,pdo_sqlite +./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite # 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx ./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro ``` diff --git a/README.md b/README.md index 8e75ff1f..d89d48f3 100755 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ Basic usage for building php and micro with some extensions: # fetch all libraries ./bin/spc download --all # only fetch necessary sources by needed extensions -./bin/spc download --by-extensions=openssl,pcntl,mbstring,pdo_sqlite +./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite # with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI ./bin/spc build bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl --build-cli --build-micro ``` diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index dfad36fe..435bcf00 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -35,8 +35,8 @@ class DownloadCommand extends BaseCommand $this->addOption('all', 'A', null, 'Fetch all sources that static-php-cli needed'); $this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"'); $this->addOption('from-zip', 'Z', InputOption::VALUE_REQUIRED, 'Fetch from zip archive'); - $this->addOption('by-extensions', 'e', InputOption::VALUE_REQUIRED, 'Fetch by extensions, e.g "openssl,mbstring"'); - $this->addOption('without-suggests', null, null, 'Do not fetch suggested sources when using --by-extensions'); + $this->addOption('for-extensions', 'e', InputOption::VALUE_REQUIRED, 'Fetch by extensions, e.g "openssl,mbstring"'); + $this->addOption('without-suggestions', null, null, 'Do not fetch suggested sources when using --for-extensions'); } public function initialize(InputInterface $input, OutputInterface $output): void @@ -45,7 +45,7 @@ class DownloadCommand extends BaseCommand $input->getOption('all') || $input->getOption('clean') || $input->getOption('from-zip') - || $input->getOption('by-extensions') + || $input->getOption('for-extensions') ) { $input->setArgument('sources', ''); } @@ -108,10 +108,10 @@ class DownloadCommand extends BaseCommand Config::$source['openssl']['regex'] = '/href="(?openssl-(?1.[^"]+)\.tar\.gz)\"/'; } - // --by-extensions - if ($by_ext = $this->getOption('by-extensions')) { + // --for-extensions + if ($by_ext = $this->getOption('for-extensions')) { $ext = array_map('trim', array_filter(explode(',', $by_ext))); - $sources = $this->calculateSourcesByExt($ext, !$this->getOption('without-suggests')); + $sources = $this->calculateSourcesByExt($ext, !$this->getOption('without-suggestions')); array_unshift($sources, 'php-src', 'micro', 'pkg-config'); } else { // get source list that will be downloaded diff --git a/src/SPC/command/DumpLicenseCommand.php b/src/SPC/command/DumpLicenseCommand.php index 98b5a4fe..5535f820 100644 --- a/src/SPC/command/DumpLicenseCommand.php +++ b/src/SPC/command/DumpLicenseCommand.php @@ -20,7 +20,7 @@ class DumpLicenseCommand extends BaseCommand { public function configure(): void { - $this->addOption('by-extensions', null, InputOption::VALUE_REQUIRED, 'Dump by extensions and related libraries', null); + $this->addOption('for-extensions', null, InputOption::VALUE_REQUIRED, 'Dump by extensions and related libraries', null); $this->addOption('without-php', null, InputOption::VALUE_NONE, 'Dump without php-src'); $this->addOption('by-libs', null, InputOption::VALUE_REQUIRED, 'Dump by libraries', null); $this->addOption('by-sources', null, InputOption::VALUE_REQUIRED, 'Dump by original sources (source.json)', null); @@ -35,9 +35,9 @@ class DumpLicenseCommand extends BaseCommand public function handle(): int { $dumper = new LicenseDumper(); - if ($this->getOption('by-extensions') !== null) { + if ($this->getOption('for-extensions') !== null) { // 从参数中获取要编译的 extensions,并转换为数组 - $extensions = array_map('trim', array_filter(explode(',', $this->getOption('by-extensions')))); + $extensions = array_map('trim', array_filter(explode(',', $this->getOption('for-extensions')))); // 根据提供的扩展列表获取依赖库列表并编译 [$extensions, $libraries] = DependencyUtil::getExtLibsByDeps($extensions); $dumper->addExts($extensions); @@ -67,7 +67,7 @@ class DumpLicenseCommand extends BaseCommand $this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir')); return static::SUCCESS; } - $this->output->writeln('You must use one of "--by-extensions=", "--by-libs=", "--by-sources=" to dump'); + $this->output->writeln('You must use one of "--for-extensions=", "--by-libs=", "--by-sources=" to dump'); return static::FAILURE; } } From 90b2e5568c98f002c75f9ed63da1069da2d1f6aa Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 29 Oct 2023 23:34:17 +0800 Subject: [PATCH 271/296] update sqlite version --- config/source.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index c6813c03..b3557941 100644 --- a/config/source.json +++ b/config/source.json @@ -433,7 +433,7 @@ }, "sqlite": { "type": "url", - "url": "https://www.sqlite.org/2023/sqlite-autoconf-3410100.tar.gz", + "url": "https://www.sqlite.org/2023/sqlite-autoconf-3430200.tar.gz", "license": { "type": "text", "text": "The author disclaims copyright to this source code. In place of\na legal notice, here is a blessing:\n\n * May you do good and not evil.\n * May you find forgiveness for yourself and forgive others.\n * May you share freely, never taking more than you give." From 2768dc0c404fe679832f507ff14a4fdc2e24e4c0 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 30 Oct 2023 00:35:58 +0800 Subject: [PATCH 272/296] adjust doctor for os and linux musl check --- src/SPC/doctor/item/LinuxMuslCheck.php | 6 +++--- src/SPC/doctor/item/OSCheckList.php | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index d4bc2c8f..ad8f7502 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -26,7 +26,7 @@ class LinuxMuslCheck } $musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); - if (file_exists($musl_wrapper_lib)) { + if (file_exists($musl_wrapper_lib) && file_exists('/usr/local/musl/bin/musl-gcc')) { return CheckResult::ok(); } return CheckResult::fail('musl-wrapper is not installed on your system', 'fix-musl-wrapper'); @@ -71,7 +71,7 @@ class LinuxMuslCheck Downloader::downloadSource($musl_version_name, $musl_source); FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); logger()->info('Installing musl wrapper'); - shell(true)->cd(SOURCE_PATH . "/{$musl_version_name}") + shell()->cd(SOURCE_PATH . "/{$musl_version_name}") ->exec('./configure') ->exec('make -j') ->exec("{$prefix}make install"); @@ -106,7 +106,7 @@ class LinuxMuslCheck Downloader::downloadSource('musl-compile', $musl_compile_source); logger()->info('Extracting musl-cross'); FileSystem::extractSource('musl-compile', DOWNLOAD_PATH . "/{$arch}-musl-toolchain.tgz"); - shell(true)->exec($prefix . 'cp -rf ' . SOURCE_PATH . '/musl-compile/* /usr/local/musl'); + shell()->exec($prefix . 'cp -rf ' . SOURCE_PATH . '/musl-compile/* /usr/local/musl'); return true; } catch (RuntimeException) { return false; diff --git a/src/SPC/doctor/item/OSCheckList.php b/src/SPC/doctor/item/OSCheckList.php index 7344ecda..ad6b2551 100644 --- a/src/SPC/doctor/item/OSCheckList.php +++ b/src/SPC/doctor/item/OSCheckList.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\doctor\item; +use SPC\builder\linux\SystemUtil; use SPC\builder\traits\UnixSystemUtilTrait; use SPC\doctor\AsCheckItem; use SPC\doctor\CheckResult; @@ -18,6 +19,7 @@ class OSCheckList if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) { return CheckResult::fail('Current OS is not supported'); } - return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . ', supported'); + $distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : ''; + return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported'); } } From 6b848da4dd5fe6632bbbed1716358dcb1ebeb2d9 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 29 Oct 2023 18:02:02 +0100 Subject: [PATCH 273/296] disable musl-gcc wrapper --- src/SPC/doctor/item/LinuxMuslCheck.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index ad8f7502..c9639ff4 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -26,7 +26,7 @@ class LinuxMuslCheck } $musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); - if (file_exists($musl_wrapper_lib) && file_exists('/usr/local/musl/bin/musl-gcc')) { + if (file_exists($musl_wrapper_lib) && file_exists('/usr/local/musl/lib/libc.a')) { return CheckResult::ok(); } return CheckResult::fail('musl-wrapper is not installed on your system', 'fix-musl-wrapper'); @@ -72,7 +72,7 @@ class LinuxMuslCheck FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); logger()->info('Installing musl wrapper'); shell()->cd(SOURCE_PATH . "/{$musl_version_name}") - ->exec('./configure') + ->exec('./configure --disable-gcc-wrapper') ->exec('make -j') ->exec("{$prefix}make install"); // TODO: add path using putenv instead of editing /etc/profile From a5754125a8edab512e89dc192713ca36fb284c97 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 30 Oct 2023 20:32:59 +0800 Subject: [PATCH 274/296] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d89d48f3..a3dedf84 100755 --- a/README.md +++ b/README.md @@ -94,6 +94,8 @@ Here's how to download from GitHub Actions: You can also download binaries from a self-hosted server: [enter](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/). +> SPC single-file binary is built by phpmicro and box. + ### Manual build (using source code) Clone repo first: From ed8837fe9f151d90c32f5e6b65950ce368be8f55 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 31 Oct 2023 00:59:22 +0800 Subject: [PATCH 275/296] let postgresql use -lc++ in bsd and macos --- src/SPC/builder/unix/library/postgresql.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 235e40f0..38be1bf2 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; @@ -46,7 +47,11 @@ trait postgresql $output = shell()->execWithResult("pkg-config --libs-only-l --static {$packages}"); if (!empty($output[1][0])) { $libs = $output[1][0]; - $envs .= " LIBS=\"{$libs} -lstdc++\" "; + $libcpp = ''; + if ($this->builder->getLib('icu')) { + $libcpp = $this instanceof LinuxLibraryBase ? ' -lstdc++' : ' -lc++'; + } + $envs .= " LIBS=\"{$libs}{$libcpp}\" "; } FileSystem::resetDir($this->source_dir . '/build'); From 7625f585d213f3dd1a9dd8eae0f0229187040033 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 31 Oct 2023 00:45:55 +0800 Subject: [PATCH 276/296] fix macos imagemagick libwebp linking issue --- src/SPC/builder/unix/library/libwebp.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SPC/builder/unix/library/libwebp.php b/src/SPC/builder/unix/library/libwebp.php index 32aa7201..19b534ac 100644 --- a/src/SPC/builder/unix/library/libwebp.php +++ b/src/SPC/builder/unix/library/libwebp.php @@ -35,5 +35,7 @@ trait libwebp $this->patchPkgconfPrefix(['libsharpyuv.pc', 'libwebp.pc', 'libwebpdecoder.pc', 'libwebpdemux.pc', 'libwebpmux.pc'], PKGCONF_PATCH_PREFIX | PKGCONF_PATCH_LIBDIR); $this->patchPkgconfPrefix(['libsharpyuv.pc'], PKGCONF_PATCH_CUSTOM, ['/^includedir=.*$/m', 'includedir=${prefix}/include/webp']); $this->cleanLaFiles(); + // fix imagemagick binary linking issue + $this->patchPkgconfPrefix(['libwebp.pc'], PKGCONF_PATCH_CUSTOM, ['/-lwebp$/m', '-lwebp -lsharpyuv']); } } From e637cce6f26e320c58b1846afb26e3ce93288270 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 31 Oct 2023 01:48:49 +0800 Subject: [PATCH 277/296] use prompts to ask --- src/SPC/command/DoctorCommand.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/SPC/command/DoctorCommand.php b/src/SPC/command/DoctorCommand.php index b184fa21..9aabdeca 100644 --- a/src/SPC/command/DoctorCommand.php +++ b/src/SPC/command/DoctorCommand.php @@ -8,8 +8,8 @@ use SPC\doctor\CheckListHandler; use SPC\doctor\CheckResult; use SPC\exception\RuntimeException; use Symfony\Component\Console\Attribute\AsCommand; -use Symfony\Component\Console\Helper\QuestionHelper; -use Symfony\Component\Console\Question\ConfirmationQuestion; + +use function Laravel\Prompts\confirm; #[AsCommand('doctor', 'Diagnose whether the current environment can compile normally')] class DoctorCommand extends BaseCommand @@ -49,9 +49,8 @@ class DoctorCommand extends BaseCommand throw new RuntimeException('Some check items can not be fixed !'); case FIX_POLICY_PROMPT: if ($result->getFixItem() !== '') { - $helper = new QuestionHelper(); - $question = new ConfirmationQuestion('Do you want to fix it? [Y/n] ', true); - if ($helper->ask($this->input, $this->output, $question)) { + $question = confirm('Do you want to fix it?'); + if ($question) { $checker->emitFix($this->output, $result); } else { throw new RuntimeException('You cancelled fix'); From aee040d6a4c9aa8a8de83aa18882a270a0b1a24a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 31 Oct 2023 01:48:57 +0800 Subject: [PATCH 278/296] use prompts to show table --- src/SPC/command/dev/AllExtCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index 52eb38dc..196de39f 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -14,6 +14,8 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Style\SymfonyStyle; +use function Laravel\Prompts\table; + #[AsCommand('dev:extensions', 'Helper command that lists available extension details', ['list-ext'])] class AllExtCommand extends BaseCommand { @@ -62,7 +64,7 @@ class AllExtCommand extends BaseCommand if ($data === []) { $style->warning('Unknown extension selected: ' . implode(',', $extensions)); } else { - $style->table( + table( ['Extension', 'lib-depends', 'lib-suggests', 'ext-depends', 'ext-suggests', 'unix-only'], $data ); From e158cc58865edf912726262b578b5ecd85c961a8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 31 Oct 2023 01:51:14 +0800 Subject: [PATCH 279/296] update composer lock --- composer.lock | 350 +++++++++++++++++++++++++++++++------------------- 1 file changed, 215 insertions(+), 135 deletions(-) diff --git a/composer.lock b/composer.lock index 604913f1..974375d0 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "illuminate/collections", - "version": "v10.24.0", + "version": "v10.29.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "939a975daa8a5f77974ffa6a24067f5e947683f4" + "reference": "bb8784ce913bd46f944b4bd67cd857f40d9cfe68" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/939a975daa8a5f77974ffa6a24067f5e947683f4", - "reference": "939a975daa8a5f77974ffa6a24067f5e947683f4", + "url": "https://api.github.com/repos/illuminate/collections/zipball/bb8784ce913bd46f944b4bd67cd857f40d9cfe68", + "reference": "bb8784ce913bd46f944b4bd67cd857f40d9cfe68", "shasum": "" }, "require": { @@ -59,11 +59,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-09-18T18:32:31+00:00" + "time": "2023-10-10T12:55:25+00:00" }, { "name": "illuminate/conditionable", - "version": "v10.24.0", + "version": "v10.29.0", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -109,7 +109,7 @@ }, { "name": "illuminate/contracts", - "version": "v10.24.0", + "version": "v10.29.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -157,7 +157,7 @@ }, { "name": "illuminate/macroable", - "version": "v10.24.0", + "version": "v10.29.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -203,23 +203,27 @@ }, { "name": "laravel/prompts", - "version": "v0.1.8", + "version": "v0.1.12", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "68dcc65babf92e1fb43cba0b3f78fc3d8002709c" + "reference": "b35f249028c22016e45e48626e19e5d42fd827ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/68dcc65babf92e1fb43cba0b3f78fc3d8002709c", - "reference": "68dcc65babf92e1fb43cba0b3f78fc3d8002709c", + "url": "https://api.github.com/repos/laravel/prompts/zipball/b35f249028c22016e45e48626e19e5d42fd827ff", + "reference": "b35f249028c22016e45e48626e19e5d42fd827ff", "shasum": "" }, "require": { "ext-mbstring": "*", "illuminate/collections": "^10.0|^11.0", "php": "^8.1", - "symfony/console": "^6.2" + "symfony/console": "^6.2|^7.0" + }, + "conflict": { + "illuminate/console": ">=10.17.0 <10.25.0", + "laravel/framework": ">=10.17.0 <10.25.0" }, "require-dev": { "mockery/mockery": "^1.5", @@ -231,6 +235,11 @@ "ext-pcntl": "Required for the spinner to be animated." }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.1.x-dev" + } + }, "autoload": { "files": [ "src/helpers.php" @@ -245,9 +254,9 @@ ], "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.8" + "source": "https://github.com/laravel/prompts/tree/v0.1.12" }, - "time": "2023-09-19T15:33:56+00:00" + "time": "2023-10-18T14:18:57+00:00" }, { "name": "psr/container", @@ -974,16 +983,16 @@ }, { "name": "symfony/string", - "version": "v6.3.2", + "version": "v6.3.5", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "53d1a83225002635bca3482fcbf963001313fb68" + "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/53d1a83225002635bca3482fcbf963001313fb68", - "reference": "53d1a83225002635bca3482fcbf963001313fb68", + "url": "https://api.github.com/repos/symfony/string/zipball/13d76d0fb049051ed12a04bef4f9de8715bea339", + "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339", "shasum": "" }, "require": { @@ -1040,7 +1049,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.3.2" + "source": "https://github.com/symfony/string/tree/v6.3.5" }, "funding": [ { @@ -1056,7 +1065,7 @@ "type": "tidelift" } ], - "time": "2023-07-05T08:41:27+00:00" + "time": "2023-09-18T10:38:32+00:00" }, { "name": "zhamao/logger", @@ -1682,16 +1691,16 @@ }, { "name": "captainhook/captainhook", - "version": "5.16.4", + "version": "5.18.2", "source": { "type": "git", "url": "https://github.com/captainhookphp/captainhook.git", - "reference": "524c8660551bafe9c7211440a71a35984e8dfc4b" + "reference": "61c24442f71ea216e9e172861d48d7676439dd18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/524c8660551bafe9c7211440a71a35984e8dfc4b", - "reference": "524c8660551bafe9c7211440a71a35984e8dfc4b", + "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/61c24442f71ea216e9e172861d48d7676439dd18", + "reference": "61c24442f71ea216e9e172861d48d7676439dd18", "shasum": "" }, "require": { @@ -1701,7 +1710,7 @@ "php": ">=7.4", "sebastianfeldmann/camino": "^0.9.2", "sebastianfeldmann/cli": "^3.3", - "sebastianfeldmann/git": "^3.8.9", + "sebastianfeldmann/git": "^3.9", "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0", "symfony/filesystem": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0", "symfony/process": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0" @@ -1753,7 +1762,7 @@ ], "support": { "issues": "https://github.com/captainhookphp/captainhook/issues", - "source": "https://github.com/captainhookphp/captainhook/tree/5.16.4" + "source": "https://github.com/captainhookphp/captainhook/tree/5.18.2" }, "funding": [ { @@ -1761,7 +1770,7 @@ "type": "github" } ], - "time": "2023-04-17T19:48:47+00:00" + "time": "2023-10-16T15:13:42+00:00" }, { "name": "captainhook/plugin-composer", @@ -1820,16 +1829,16 @@ }, { "name": "composer/pcre", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", "shasum": "" }, "require": { @@ -1871,7 +1880,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.0" + "source": "https://github.com/composer/pcre/tree/3.1.1" }, "funding": [ { @@ -1887,7 +1896,7 @@ "type": "tidelift" } ], - "time": "2022-11-17T09:50:14+00:00" + "time": "2023-10-11T07:11:09+00:00" }, { "name": "composer/semver", @@ -2038,16 +2047,16 @@ }, { "name": "doctrine/deprecations", - "version": "v1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", "shasum": "" }, "require": { @@ -2079,9 +2088,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" + "source": "https://github.com/doctrine/deprecations/tree/1.1.2" }, - "time": "2023-06-03T09:27:29+00:00" + "time": "2023-09-27T20:04:15+00:00" }, { "name": "fidry/console", @@ -2167,6 +2176,75 @@ ], "time": "2022-12-18T10:49:34+00:00" }, + { + "name": "fidry/filesystem", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/theofidry/filesystem.git", + "reference": "1dd372ab3eb8b84ffe9578bff576b00c9a44ee46" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theofidry/filesystem/zipball/1dd372ab3eb8b84ffe9578bff576b00c9a44ee46", + "reference": "1dd372ab3eb8b84ffe9578bff576b00c9a44ee46", + "shasum": "" + }, + "require": { + "php": "^8.1", + "symfony/filesystem": "^6.3", + "thecodingmachine/safe": "^2.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4", + "ergebnis/composer-normalize": "^2.28", + "infection/infection": "^0.26", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^10.3", + "symfony/finder": "^6.3", + "symfony/phpunit-bridge": "^6.2" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": false, + "forward-command": false + }, + "branch-alias": { + "dev-main": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Fidry\\FileSystem\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Théo Fidry", + "email": "theo.fidry@gmail.com" + } + ], + "description": "Symfony Filesystem with a few more utilities.", + "keywords": [ + "filesystem" + ], + "support": { + "issues": "https://github.com/theofidry/filesystem/issues", + "source": "https://github.com/theofidry/filesystem/tree/1.1.0" + }, + "funding": [ + { + "url": "https://github.com/theofidry", + "type": "github" + } + ], + "time": "2023-10-07T07:32:54+00:00" + }, { "name": "filp/whoops", "version": "2.15.3", @@ -2240,16 +2318,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.28.0", + "version": "v3.37.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "113e09fea3d2306319ffaa2423fe3de768b28cff" + "reference": "c3fe76976081ab871aa654e872da588077e19679" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/113e09fea3d2306319ffaa2423fe3de768b28cff", - "reference": "113e09fea3d2306319ffaa2423fe3de768b28cff", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/c3fe76976081ab871aa654e872da588077e19679", + "reference": "c3fe76976081ab871aa654e872da588077e19679", "shasum": "" }, "require": { @@ -2282,8 +2360,6 @@ "phpspec/prophecy": "^1.16", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.5", - "phpunitgoodpractices/polyfill": "^1.6", - "phpunitgoodpractices/traits": "^1.9.2", "symfony/phpunit-bridge": "^6.2.3", "symfony/yaml": "^5.4 || ^6.0" }, @@ -2323,7 +2399,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.28.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.37.1" }, "funding": [ { @@ -2331,7 +2407,7 @@ "type": "github" } ], - "time": "2023-09-22T20:43:40+00:00" + "time": "2023-10-29T20:51:23+00:00" }, { "name": "humbug/box", @@ -2445,32 +2521,33 @@ }, { "name": "humbug/php-scoper", - "version": "0.18.3", + "version": "0.18.4", "source": { "type": "git", "url": "https://github.com/humbug/php-scoper.git", - "reference": "1a49b88b7961152daf534757137b8f86f67fde23" + "reference": "d79c1486537280c21c907e9a8a610eceb391407f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/humbug/php-scoper/zipball/1a49b88b7961152daf534757137b8f86f67fde23", - "reference": "1a49b88b7961152daf534757137b8f86f67fde23", + "url": "https://api.github.com/repos/humbug/php-scoper/zipball/d79c1486537280c21c907e9a8a610eceb391407f", + "reference": "d79c1486537280c21c907e9a8a610eceb391407f", "shasum": "" }, "require": { "fidry/console": "^0.5.0", + "fidry/filesystem": "^1.1", "jetbrains/phpstorm-stubs": "^v2022.2", "nikic/php-parser": "^4.12", "php": "^8.1", "symfony/console": "^5.2 || ^6.0", "symfony/filesystem": "^5.2 || ^6.0", "symfony/finder": "^5.2 || ^6.0", - "thecodingmachine/safe": "^1.3 || ^2.0" + "thecodingmachine/safe": "^2.0" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.1", "ergebnis/composer-normalize": "^2.28", - "fidry/makefile": "^0.2.1", + "fidry/makefile": "^1.0", "humbug/box": "^4.0", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.0", @@ -2521,9 +2598,9 @@ "description": "Prefixes all PHP namespaces in a file or directory.", "support": { "issues": "https://github.com/humbug/php-scoper/issues", - "source": "https://github.com/humbug/php-scoper/tree/0.18.3" + "source": "https://github.com/humbug/php-scoper/tree/0.18.4" }, - "time": "2023-03-16T22:49:19+00:00" + "time": "2023-10-20T17:14:04+00:00" }, { "name": "jetbrains/phpstorm-stubs", @@ -2575,16 +2652,16 @@ }, { "name": "justinrainbow/json-schema", - "version": "5.2.12", + "version": "v5.2.13", "source": { "type": "git", "url": "https://github.com/justinrainbow/json-schema.git", - "reference": "ad87d5a5ca981228e0e205c2bc7dfb8e24559b60" + "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/ad87d5a5ca981228e0e205c2bc7dfb8e24559b60", - "reference": "ad87d5a5ca981228e0e205c2bc7dfb8e24559b60", + "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", + "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793", "shasum": "" }, "require": { @@ -2639,22 +2716,22 @@ ], "support": { "issues": "https://github.com/justinrainbow/json-schema/issues", - "source": "https://github.com/justinrainbow/json-schema/tree/5.2.12" + "source": "https://github.com/justinrainbow/json-schema/tree/v5.2.13" }, - "time": "2022-04-13T08:02:27+00:00" + "time": "2023-09-26T02:20:38+00:00" }, { "name": "laravel/serializable-closure", - "version": "v1.3.1", + "version": "v1.3.2", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "e5a3057a5591e1cfe8183034b0203921abe2c902" + "reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/e5a3057a5591e1cfe8183034b0203921abe2c902", - "reference": "e5a3057a5591e1cfe8183034b0203921abe2c902", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/076fe2cf128bd54b4341cdc6d49b95b34e101e4c", + "reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c", "shasum": "" }, "require": { @@ -2701,7 +2778,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2023-07-14T13:56:28+00:00" + "time": "2023-10-17T13:38:16+00:00" }, { "name": "myclabs/deep-copy", @@ -2872,16 +2949,16 @@ }, { "name": "nunomaduro/collision", - "version": "v7.9.0", + "version": "v7.10.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "296d0cf9fe462837ac0da8a568b56fc026b132da" + "reference": "49ec67fa7b002712da8526678abd651c09f375b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/296d0cf9fe462837ac0da8a568b56fc026b132da", - "reference": "296d0cf9fe462837ac0da8a568b56fc026b132da", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/49ec67fa7b002712da8526678abd651c09f375b2", + "reference": "49ec67fa7b002712da8526678abd651c09f375b2", "shasum": "" }, "require": { @@ -2890,19 +2967,22 @@ "php": "^8.1.0", "symfony/console": "^6.3.4" }, + "conflict": { + "laravel/framework": ">=11.0.0" + }, "require-dev": { - "brianium/paratest": "^7.2.7", - "laravel/framework": "^10.23.1", - "laravel/pint": "^1.13.1", + "brianium/paratest": "^7.3.0", + "laravel/framework": "^10.28.0", + "laravel/pint": "^1.13.3", "laravel/sail": "^1.25.0", "laravel/sanctum": "^3.3.1", "laravel/tinker": "^2.8.2", "nunomaduro/larastan": "^2.6.4", - "orchestra/testbench-core": "^8.11.0", - "pestphp/pest": "^2.19.1", - "phpunit/phpunit": "^10.3.5", + "orchestra/testbench-core": "^8.13.0", + "pestphp/pest": "^2.23.2", + "phpunit/phpunit": "^10.4.1", "sebastian/environment": "^6.0.1", - "spatie/laravel-ignition": "^2.3.0" + "spatie/laravel-ignition": "^2.3.1" }, "type": "library", "extra": { @@ -2961,7 +3041,7 @@ "type": "patreon" } ], - "time": "2023-09-19T10:45:09+00:00" + "time": "2023-10-11T15:45:01+00:00" }, { "name": "nunomaduro/termwind", @@ -3397,16 +3477,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.1", + "version": "1.24.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01" + "reference": "bcad8d995980440892759db0c32acae7c8e79442" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01", - "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", + "reference": "bcad8d995980440892759db0c32acae7c8e79442", "shasum": "" }, "require": { @@ -3438,22 +3518,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" }, - "time": "2023-09-18T12:18:02+00:00" + "time": "2023-09-26T12:28:12+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.35", + "version": "1.10.40", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3" + "reference": "93c84b5bf7669920d823631e39904d69b9c7dc5d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e730e5facb75ffe09dfb229795e8c01a459f26c3", - "reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/93c84b5bf7669920d823631e39904d69b9c7dc5d", + "reference": "93c84b5bf7669920d823631e39904d69b9c7dc5d", "shasum": "" }, "require": { @@ -3502,20 +3582,20 @@ "type": "tidelift" } ], - "time": "2023-09-19T15:27:56+00:00" + "time": "2023-10-30T14:48:31+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "10.1.6", + "version": "10.1.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "56f33548fe522c8d82da7ff3824b42829d324364" + "reference": "355324ca4980b8916c18b9db29f3ef484078f26e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/56f33548fe522c8d82da7ff3824b42829d324364", - "reference": "56f33548fe522c8d82da7ff3824b42829d324364", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/355324ca4980b8916c18b9db29f3ef484078f26e", + "reference": "355324ca4980b8916c18b9db29f3ef484078f26e", "shasum": "" }, "require": { @@ -3572,7 +3652,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.6" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.7" }, "funding": [ { @@ -3580,7 +3660,7 @@ "type": "github" } ], - "time": "2023-09-19T04:59:03+00:00" + "time": "2023-10-04T15:34:17+00:00" }, { "name": "phpunit/php-file-iterator", @@ -3827,16 +3907,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.3.5", + "version": "10.4.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "747c3b2038f1139e3dcd9886a3f5a948648b7503" + "reference": "cacd8b9dd224efa8eb28beb69004126c7ca1a1a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/747c3b2038f1139e3dcd9886a3f5a948648b7503", - "reference": "747c3b2038f1139e3dcd9886a3f5a948648b7503", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/cacd8b9dd224efa8eb28beb69004126c7ca1a1a1", + "reference": "cacd8b9dd224efa8eb28beb69004126c7ca1a1a1", "shasum": "" }, "require": { @@ -3876,7 +3956,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.3-dev" + "dev-main": "10.4-dev" } }, "autoload": { @@ -3908,7 +3988,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.5" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.4.2" }, "funding": [ { @@ -3924,7 +4004,7 @@ "type": "tidelift" } ], - "time": "2023-09-19T05:42:37+00:00" + "time": "2023-10-26T07:21:45+00:00" }, { "name": "psr/event-dispatcher", @@ -4222,16 +4302,16 @@ }, { "name": "sebastian/complexity", - "version": "3.0.1", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "c70b73893e10757af9c6a48929fa6a333b56a97a" + "reference": "68cfb347a44871f01e33ab0ef8215966432f6957" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/c70b73893e10757af9c6a48929fa6a333b56a97a", - "reference": "c70b73893e10757af9c6a48929fa6a333b56a97a", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68cfb347a44871f01e33ab0ef8215966432f6957", + "reference": "68cfb347a44871f01e33ab0ef8215966432f6957", "shasum": "" }, "require": { @@ -4244,7 +4324,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.1-dev" } }, "autoload": { @@ -4268,7 +4348,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", "security": "https://github.com/sebastianbergmann/complexity/security/policy", - "source": "https://github.com/sebastianbergmann/complexity/tree/3.0.1" + "source": "https://github.com/sebastianbergmann/complexity/tree/3.1.0" }, "funding": [ { @@ -4276,7 +4356,7 @@ "type": "github" } ], - "time": "2023-08-31T09:55:53+00:00" + "time": "2023-09-28T11:50:59+00:00" }, { "name": "sebastian/diff", @@ -4411,16 +4491,16 @@ }, { "name": "sebastian/exporter", - "version": "5.1.0", + "version": "5.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344" + "reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c3fa8483f9539b190f7cd4bfc4a07631dd1df344", - "reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/64f51654862e0f5e318db7e9dcc2292c63cdbddc", + "reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc", "shasum": "" }, "require": { @@ -4434,7 +4514,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -4477,7 +4557,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", "security": "https://github.com/sebastianbergmann/exporter/security/policy", - "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.0" + "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.1" }, "funding": [ { @@ -4485,7 +4565,7 @@ "type": "github" } ], - "time": "2023-09-18T07:15:37+00:00" + "time": "2023-09-24T13:22:09+00:00" }, { "name": "sebastian/global-state", @@ -5007,16 +5087,16 @@ }, { "name": "sebastianfeldmann/git", - "version": "3.8.9", + "version": "3.9.3", "source": { "type": "git", "url": "https://github.com/sebastianfeldmann/git.git", - "reference": "38586be69b0932b630337afcc8db12e5b7981254" + "reference": "eb2ca84a2b45a461f0bf5d4fd400df805649e83a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianfeldmann/git/zipball/38586be69b0932b630337afcc8db12e5b7981254", - "reference": "38586be69b0932b630337afcc8db12e5b7981254", + "url": "https://api.github.com/repos/sebastianfeldmann/git/zipball/eb2ca84a2b45a461f0bf5d4fd400df805649e83a", + "reference": "eb2ca84a2b45a461f0bf5d4fd400df805649e83a", "shasum": "" }, "require": { @@ -5056,7 +5136,7 @@ ], "support": { "issues": "https://github.com/sebastianfeldmann/git/issues", - "source": "https://github.com/sebastianfeldmann/git/tree/3.8.9" + "source": "https://github.com/sebastianfeldmann/git/tree/3.9.3" }, "funding": [ { @@ -5064,7 +5144,7 @@ "type": "github" } ], - "time": "2023-03-30T16:37:34+00:00" + "time": "2023-10-13T09:10:48+00:00" }, { "name": "seld/jsonlint", @@ -5351,16 +5431,16 @@ }, { "name": "symfony/finder", - "version": "v6.3.3", + "version": "v6.3.5", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e" + "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/9915db259f67d21eefee768c1abcf1cc61b1fc9e", - "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e", + "url": "https://api.github.com/repos/symfony/finder/zipball/a1b31d88c0e998168ca7792f222cbecee47428c4", + "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4", "shasum": "" }, "require": { @@ -5395,7 +5475,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.3.3" + "source": "https://github.com/symfony/finder/tree/v6.3.5" }, "funding": [ { @@ -5411,7 +5491,7 @@ "type": "tidelift" } ], - "time": "2023-07-31T08:31:44+00:00" + "time": "2023-09-26T12:56:25+00:00" }, { "name": "symfony/options-resolver", @@ -5605,16 +5685,16 @@ }, { "name": "symfony/var-dumper", - "version": "v6.3.4", + "version": "v6.3.6", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "2027be14f8ae8eae999ceadebcda5b4909b81d45" + "reference": "999ede244507c32b8e43aebaa10e9fce20de7c97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/2027be14f8ae8eae999ceadebcda5b4909b81d45", - "reference": "2027be14f8ae8eae999ceadebcda5b4909b81d45", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/999ede244507c32b8e43aebaa10e9fce20de7c97", + "reference": "999ede244507c32b8e43aebaa10e9fce20de7c97", "shasum": "" }, "require": { @@ -5669,7 +5749,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.3.4" + "source": "https://github.com/symfony/var-dumper/tree/v6.3.6" }, "funding": [ { @@ -5685,7 +5765,7 @@ "type": "tidelift" } ], - "time": "2023-08-24T14:51:05+00:00" + "time": "2023-10-12T18:45:56+00:00" }, { "name": "thecodingmachine/safe", From d5405ce4360292754128bd604faa747642ff748a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 31 Oct 2023 01:51:53 +0800 Subject: [PATCH 280/296] update to the release version --- src/SPC/ConsoleApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 967da910..5ab014fa 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.0-rc7'; + public const VERSION = '2.0.0'; public function __construct() { From bfc56cff72f4b3134f7bd60ae81d15ce101c24a5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 30 Oct 2023 22:14:47 +0100 Subject: [PATCH 281/296] refactor build var generation --- src/SPC/builder/linux/LinuxBuilder.php | 65 ++++++++++++-------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 73d47acc..22ff513e 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -140,10 +140,6 @@ class LinuxBuilder extends BuilderBase $this->setOption('extra-libs', $extra_libs); $cflags = $this->arch_c_flags; - $use_lld = ''; - if (str_ends_with(getenv('CC'), 'clang') && SystemUtil::findCommand('lld')) { - $use_lld = '-Xcompiler -fuse-ld=lld'; - } // prepare build php envs $envs_build_php = SystemUtil::makeEnvVarString([ @@ -203,22 +199,22 @@ class LinuxBuilder extends BuilderBase if ($enableCli) { logger()->info('building cli'); - $this->buildCli($use_lld); + $this->buildCli(); } if ($enableFpm) { logger()->info('building fpm'); - $this->buildFpm($use_lld); + $this->buildFpm(); } if ($enableMicro) { logger()->info('building micro'); - $this->buildMicro($use_lld, $cflags); + $this->buildMicro(); } if ($enableEmbed) { logger()->info('building embed'); if ($enableMicro) { FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la'); } - $this->buildEmbed($use_lld); + $this->buildEmbed(); } if (php_uname('m') === $this->getOption('arch')) { @@ -232,13 +228,9 @@ class LinuxBuilder extends BuilderBase * @throws RuntimeException * @throws FileSystemException */ - public function buildCli(string $use_lld): void + public function buildCli(): void { - $vars = SystemUtil::makeEnvVarString([ - 'EXTRA_CFLAGS' => '-g -Os -fno-ident -fPIE ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), - 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), - 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", - ]); + $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec("make -j{$this->concurrency} {$vars} cli"); @@ -257,7 +249,7 @@ class LinuxBuilder extends BuilderBase * @throws RuntimeException * @throws WrongUsageException */ - public function buildMicro(string $use_lld, string $cflags): void + public function buildMicro(): void { if ($this->getPHPVersionID() < 80000) { throw new WrongUsageException('phpmicro only support PHP >= 8.0!'); @@ -267,12 +259,9 @@ class LinuxBuilder extends BuilderBase SourcePatcher::patchMicro(['phar']); } - $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; - $vars = SystemUtil::makeEnvVarString([ - 'EXTRA_CFLAGS' => '-g -Os -fno-ident -fPIE ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $enable_fake_cli, - 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), - 'EXTRA_LDFLAGS_PROGRAM' => "{$cflags} {$use_lld} -all-static", - ]); + $vars = SystemUtil::makeEnvVarString($this->getBuildVars([ + 'EXTRA_CFLAGS' => $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '', + ])); shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec("make -j{$this->concurrency} {$vars} micro"); @@ -294,14 +283,9 @@ class LinuxBuilder extends BuilderBase * @throws FileSystemException * @throws RuntimeException */ - public function buildFpm(string $use_lld): void + public function buildFpm(): void { - $vars = SystemUtil::makeEnvVarString([ - 'EXTRA_CFLAGS' => '-g -Os -fno-ident -fPIE ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), - 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), - 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", - ]); - + $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec("make -j{$this->concurrency} {$vars} fpm"); @@ -318,17 +302,30 @@ class LinuxBuilder extends BuilderBase * * @throws RuntimeException */ - public function buildEmbed(string $use_lld): void + public function buildEmbed(): void { - $vars = SystemUtil::makeEnvVarString([ - 'EXTRA_CFLAGS' => '-g -Os -fno-ident -fPIE ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), - 'EXTRA_LIBS' => $this->getOption('extra-libs', ''), - 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", - ]); + $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); shell() ->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install"); } + + private function getBuildVars($input = []): array + { + $use_lld = ''; + if (str_ends_with(getenv('CC'), 'clang') && SystemUtil::findCommand('lld')) { + $use_lld = '-Xcompiler -fuse-ld=lld'; + } + $optimization = $this->getOption('no-strip', false) ? '-g -O0' : '-g0 -0s'; + $cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : ''; + $libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : ''; + $ldflags = isset($input['EXTRA_LDFLAGS_PROGRAM']) && $input['EXTRA_LDFLAGS_PROGRAM'] ? " {$input['EXTRA_LDFLAGS_PROGRAM']}" : ''; + return [ + 'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $cflags, + 'EXTRA_LIBS' => $this->getOption('extra-libs', '') . $libs, + 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static" . $ldflags, + ]; + } } From 8747266df6aea8adc80d56260a8759a977aa724e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 30 Oct 2023 22:22:01 +0100 Subject: [PATCH 282/296] make it rc8 --- src/SPC/ConsoleApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 5ab014fa..2de132e0 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.0.0'; + public const VERSION = '2.0.0-rc8'; public function __construct() { From 0b37080cddf376d3ce31c9d32ac2e062eb8f8276 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 31 Oct 2023 12:17:53 +0800 Subject: [PATCH 283/296] a good coding font is very important --- src/SPC/builder/linux/LinuxBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 22ff513e..da7f793d 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -318,7 +318,7 @@ class LinuxBuilder extends BuilderBase if (str_ends_with(getenv('CC'), 'clang') && SystemUtil::findCommand('lld')) { $use_lld = '-Xcompiler -fuse-ld=lld'; } - $optimization = $this->getOption('no-strip', false) ? '-g -O0' : '-g0 -0s'; + $optimization = $this->getOption('no-strip', false) ? '-g -O0' : '-g0 -Os'; $cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : ''; $libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : ''; $ldflags = isset($input['EXTRA_LDFLAGS_PROGRAM']) && $input['EXTRA_LDFLAGS_PROGRAM'] ? " {$input['EXTRA_LDFLAGS_PROGRAM']}" : ''; From 279a1dab4ba4341bc5a5d4a46fa12a69f78cc457 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 31 Oct 2023 18:02:24 +0800 Subject: [PATCH 284/296] fix prompts dependency and box pack path --- box.json | 1 + composer.json | 2 +- composer.lock | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/box.json b/box.json index e5f82806..83904e36 100644 --- a/box.json +++ b/box.json @@ -9,6 +9,7 @@ "src", "vendor/psr", "vendor/laravel/prompts", + "vendor/illuminate", "vendor/symfony", "vendor/zhamao" ], diff --git a/composer.json b/composer.json index 706f8d64..2a8b4c96 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "php": ">= 8.1", "ext-mbstring": "*", "ext-pcntl": "*", - "laravel/prompts": "^0.1.3", + "laravel/prompts": "^0.1.12", "symfony/console": "^5.4 || ^6 || ^7", "zhamao/logger": "^1.0" }, diff --git a/composer.lock b/composer.lock index 974375d0..109c39b3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ea069b1a67a9a432f954fe6dbd4fea48", + "content-hash": "198b6207aabb33778c51282cb7aa0c52", "packages": [ { "name": "illuminate/collections", From 8230e1bcec8a9be6958f5c41b91c893f95c4c81e Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 1 Nov 2023 00:02:59 +0800 Subject: [PATCH 285/296] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3dedf84..341734e7 100755 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ You can also use the micro binary file to combine php binary and php source code ## Docs The current README contains basic usage. For all the features of static-php-cli, -see . +see . ## Direct Download From 58897c69416118ff562c87355edf7410800cec6b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 1 Nov 2023 01:34:57 +0800 Subject: [PATCH 286/296] add swoole curl hook support, disable pgsql hook support --- src/SPC/builder/extension/swoole.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index ab8b9848..987a0cab 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -13,11 +13,11 @@ class swoole extends Extension public function getUnixConfigureArg(): string { $arg = '--enable-swoole'; - $arg .= $this->builder->getExt('pgsql') ? ' --enable-swoole-pgsql' : ' --disable-swoole-pgsql'; + // pgsql hook is buggy for static php + $arg .= ' --disable-swoole-pgsql'; $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl'; $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; - // curl hook is buggy for static php - $arg .= ' --disable-swoole-curl'; + $arg .= $this->builder->getExt('curl') ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; return $arg; } } From 772ab77d2eabb5c737615819a3a1086ac16c79e3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 1 Nov 2023 01:35:15 +0800 Subject: [PATCH 287/296] fix glfw linking issue --- src/SPC/builder/extension/glfw.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/SPC/builder/extension/glfw.php b/src/SPC/builder/extension/glfw.php index 2920dbf6..ad1be3a7 100644 --- a/src/SPC/builder/extension/glfw.php +++ b/src/SPC/builder/extension/glfw.php @@ -17,10 +17,19 @@ class glfw extends Extension */ public function patchBeforeBuildconf(): bool { + if (file_exists(SOURCE_PATH . '/php-src/ext/glfw')) { + return false; + } FileSystem::copyDir(SOURCE_PATH . '/ext-glfw', SOURCE_PATH . '/php-src/ext/glfw'); return true; } + public function patchBeforeConfigure(): bool + { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lglfw ', '-lglfw3 '); + return true; + } + public function getUnixConfigureArg(): string { return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH; From 7bef45eb327f06552d2b20ae61365448c5666dd3 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 1 Nov 2023 11:01:44 +0800 Subject: [PATCH 288/296] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 341734e7..5df67a2f 100755 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ see . ## Direct Download -If you don't want to compile yourself, you can download example pre-compiled artifact from Actions, or from self-hosted server: [Here](https://dl.static-php.dev/static-php-cli/common/) +If you don't want to compile yourself, you can download example pre-compiled artifact from [Actions](https://github.com/crazywhalecc/static-php-cli-hosted/actions/workflows/build-php-common.yml), or from [self-hosted server](https://dl.static-php.dev/static-php-cli/common/). > self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` From d29ba16cbc3dfb16b60e7d8e79b6b86ec4aeaf44 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 1 Nov 2023 13:49:18 +0800 Subject: [PATCH 289/296] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5df67a2f..20e1bc6f 100755 --- a/README.md +++ b/README.md @@ -16,12 +16,12 @@ You can also use the micro binary file to combine php binary and php source code > This SAPI feature is from the [Fork](https://github.com/crazywhalecc/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro). -[![Version](https://img.shields.io/badge/Version-2.0--rc7-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc8-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) -[![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() +[![](https://img.shields.io/badge/Extension%20Counter-65+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() ## Docs From 9e1c2c6dd5abd62b906502a4b80cec0b83f3d2d2 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 1 Nov 2023 13:49:37 +0800 Subject: [PATCH 290/296] Update README-zh.md --- README-zh.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README-zh.md b/README-zh.md index 94f79ce7..f15013ea 100755 --- a/README-zh.md +++ b/README-zh.md @@ -14,11 +14,11 @@ Build single static PHP binary, with PHP project together, with popular extensio > 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/crazywhalecc/phpmicro)。 -[![Version](https://img.shields.io/badge/Version-2.0--rc7-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0--rc8-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) -[![](https://img.shields.io/badge/Extension%20Counter-55+-yellow.svg?style=flat-square)]() +[![](https://img.shields.io/badge/Extension%20Counter-65+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() > 项目名称是 static-php-cli,但其实支持 cli、fpm、micro 和 embed SAPI 😎 From 5ee7dd9200fc85771ff35a937d505110b957ab2b Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 1 Nov 2023 13:51:12 +0800 Subject: [PATCH 291/296] Update README-zh.md --- README-zh.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README-zh.md b/README-zh.md index f15013ea..effb276d 100755 --- a/README-zh.md +++ b/README-zh.md @@ -16,8 +16,7 @@ Build single static PHP binary, with PHP project together, with popular extensio [![Version](https://img.shields.io/badge/Version-2.0--rc8-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) +[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli-hosted/build-php-common.yml?branch=refactor&label=Build%20Common%20Extensions&style=flat-square)](https://github.com/crazywhalecc/static-php-cli-hosted/actions/workflows/build-php-common.yml) [![](https://img.shields.io/badge/Extension%20Counter-65+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() From af464e7b3d0dee71e45eff64ab1636b0a5e54109 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 1 Nov 2023 20:06:02 +0800 Subject: [PATCH 292/296] Update source.json --- config/source.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index b3557941..c5434c6f 100644 --- a/config/source.json +++ b/config/source.json @@ -216,7 +216,7 @@ }, "libmemcached": { "type": "git", - "url": "https://github.com/crazywhalecc/libmemcached-macos.git", + "url": "https://github.com/static-php/libmemcached-macos.git", "rev": "master", "license": { "type": "file", From 97a76aba8a9ac4bb931a7976bb13a4e253a5eea5 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 1 Nov 2023 20:35:45 +0800 Subject: [PATCH 293/296] update README --- README-zh.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-zh.md b/README-zh.md index effb276d..d595c15e 100755 --- a/README-zh.md +++ b/README-zh.md @@ -231,7 +231,7 @@ bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=sys 另外,添加新扩展的贡献方式,可以参考下方 `进阶`。 -如果你想贡献文档内容,请到项目仓库 [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs) 贡献。 +如果你想贡献文档内容,请到项目仓库 [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs) 贡献。 ## 赞助本项目 diff --git a/README.md b/README.md index 20e1bc6f..c3ec3292 100755 --- a/README.md +++ b/README.md @@ -257,7 +257,7 @@ For an advanced example of how to use this feature, take a look at [how to use i If the extension you need is missing, you can create an issue. If you are familiar with this project, you are also welcome to initiate a pull request. -If you want to contribute document content, please go to [crazywhalecc/static-php-cli-docs](https://github.com/crazywhalecc/static-php-cli-docs). +If you want to contribute document content, please go to [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs). Part of the English document is written by me, and part is translated by Google, and there may be inaccurate descriptions, strange or offensive expressions. From 678283cd9803b2e82b2a8f76ffe40db2096196ee Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 1 Nov 2023 20:48:23 +0800 Subject: [PATCH 294/296] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c3ec3292..899ebeed 100755 --- a/README.md +++ b/README.md @@ -257,13 +257,14 @@ For an advanced example of how to use this feature, take a look at [how to use i If the extension you need is missing, you can create an issue. If you are familiar with this project, you are also welcome to initiate a pull request. -If you want to contribute document content, please go to [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs). +If you want to contribute documentation, please go to [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs). + +Now there is a [static-php](https://github.com/static-php) organization, which is used to store the repo related to the project. Part of the English document is written by me, and part is translated by Google, and there may be inaccurate descriptions, strange or offensive expressions. If you are a native English speaker, some corrections to the documentation are welcome. - ## Sponsor this project You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). From 1bf39c1f065024dbc131c0546421f9b0c955d653 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 1 Nov 2023 20:51:31 +0800 Subject: [PATCH 295/296] Update static-php-cli-hosted ownership --- .github/workflows/release-build.yml | 2 +- README-zh.md | 2 +- README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 139d4a34..cb08ba23 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -24,7 +24,7 @@ jobs: - name: Reuse static-php-cli-hosted artifacts uses: dawidd6/action-download-artifact@v2 with: - repo: crazywhalecc/static-php-cli-hosted + repo: static-php/static-php-cli-hosted branch: master workflow: build-spc-release.yml name: "spc-${{ matrix.operating-system }}" diff --git a/README-zh.md b/README-zh.md index d595c15e..6d2a4237 100755 --- a/README-zh.md +++ b/README-zh.md @@ -16,7 +16,7 @@ Build single static PHP binary, with PHP project together, with popular extensio [![Version](https://img.shields.io/badge/Version-2.0--rc8-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli-hosted/build-php-common.yml?branch=refactor&label=Build%20Common%20Extensions&style=flat-square)](https://github.com/crazywhalecc/static-php-cli-hosted/actions/workflows/build-php-common.yml) +[![](https://img.shields.io/github/actions/workflow/status/static-php/static-php-cli-hosted/build-php-common.yml?branch=refactor&label=Build%20Common%20Extensions&style=flat-square)](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-common.yml) [![](https://img.shields.io/badge/Extension%20Counter-65+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() diff --git a/README.md b/README.md index 899ebeed..c233b38f 100755 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ see . ## Direct Download -If you don't want to compile yourself, you can download example pre-compiled artifact from [Actions](https://github.com/crazywhalecc/static-php-cli-hosted/actions/workflows/build-php-common.yml), or from [self-hosted server](https://dl.static-php.dev/static-php-cli/common/). +If you don't want to compile yourself, you can download example pre-compiled artifact from [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-common.yml), or from [self-hosted server](https://dl.static-php.dev/static-php-cli/common/). > self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` From ac7a2367631e6aba7d7f4f5c0c80e2b7be6d9ff4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 1 Nov 2023 21:06:46 +0800 Subject: [PATCH 296/296] Transfer crazywhalecc/phpmicro ownership --- README-zh.md | 2 +- README.md | 4 ++-- config/source.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README-zh.md b/README-zh.md index 6d2a4237..33cb1d64 100755 --- a/README-zh.md +++ b/README-zh.md @@ -12,7 +12,7 @@ Build single static PHP binary, with PHP project together, with popular extensio 截屏2023-05-02 15 52 33 -> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/crazywhalecc/phpmicro)。 +> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/static-php/phpmicro)。 [![Version](https://img.shields.io/badge/Version-2.0--rc8-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() diff --git a/README.md b/README.md index c233b38f..c89abc91 100755 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ You can also use the micro binary file to combine php binary and php source code 2023-05-02 15 52 33 -> This SAPI feature is from the [Fork](https://github.com/crazywhalecc/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro). +> This SAPI feature is from the [Fork](https://github.com/static-php/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro). [![Version](https://img.shields.io/badge/Version-2.0--rc8-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() @@ -197,7 +197,7 @@ cd buildroot/bin/ > phpmicro is a SelF-extracted eXecutable SAPI module, > provided by [phpmicro](https://github.com/dixyes/phpmicro) project. -> But this project is using a [fork](https://github.com/crazywhalecc/phpmicro) of phpmicro, because we need to add some features to it. +> But this project is using a [fork](https://github.com/static-php/phpmicro) of phpmicro, because we need to add some features to it. > It can put php runtime and your source code together. When using the parameter `--build-all` or `--build-micro`, diff --git a/config/source.json b/config/source.json index c5434c6f..cd849f86 100644 --- a/config/source.json +++ b/config/source.json @@ -314,7 +314,7 @@ "type": "git", "path": "php-src/sapi/micro", "rev": "master", - "url": "https://github.com/crazywhalecc/phpmicro", + "url": "https://github.com/static-php/phpmicro", "license": { "type": "file", "path": "LICENSE"