diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b04a1324..21dcb0e8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -129,6 +129,13 @@ jobs: extensions: curl, openssl, mbstring ini-values: memory_limit=-1 + - name: "Use test token if exists" + if: matrix.os != 'windows-latest' + run: | + if [ "${{ secrets.TEST_GH_TOKEN }}" != "" ]; then + echo "GITHUB_TOKEN=${{ secrets.TEST_GH_TOKEN }}" >> $GITHUB_ENV + fi + - name: "Cache Composer packages" id: composer-cache uses: actions/cache@v3 @@ -152,7 +159,12 @@ jobs: run: bin/spc doctor --auto-fix - name: "Run Build Tests (download)" - run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug + uses: nick-fields/retry@v3 + with: + timeout_minutes: 10 + max_attempts: 3 + retry_on: error + command: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug - name: "Run Build Tests (build)" run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php libs_cmd) --build-cli --build-micro --build-fpm --debug diff --git a/README-zh.md b/README-zh.md index a7a8e26d..7fb1384c 100755 --- a/README-zh.md +++ b/README-zh.md @@ -1,10 +1,11 @@ # static-php-cli -[![Version](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)]() -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) -[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() -[![](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html)) -[![](https://dcbadge.vercel.app/api/server/RNpegEYW?style=flat-square&compact=true&theme=default-inverted)](https://discord.gg/RNpegEYW) +[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-moccasin?style=flat-square)](README.md) +[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-moccasin?style=flat-square)](README-zh.md) +[![Releases](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/releases) +[![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) +[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE) +[![Extensions](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)](https://static-php.dev/zh/guide/extensions.html) **static-php-cli**是一个用于静态编译、构建 PHP 解释器的工具,支持众多流行扩展。 @@ -12,9 +13,6 @@ **static-php-cli**也支持将 PHP 代码和 PHP 运行时打包为一个文件并运行。 -- [README - English](./README.md) -- [README - 中文](./README-zh.md) - ## 特性 static-php-cli(简称 `spc`)有许多特性: diff --git a/README.md b/README.md index 6b87108d..9f5a5d47 100755 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # static-php-cli -[![Version](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)]() -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) -[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() -[![](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html)) -[![](https://dcbadge.vercel.app/api/server/RNpegEYW?style=flat-square&compact=true&theme=default-inverted)](https://discord.gg/RNpegEYW) +[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-moccasin?style=flat-square)](README-zh.md) +[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-moccasin?style=flat-square)](README.md) +[![Releases](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/releases) +[![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) +[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE) +[![Extensions](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)](https://static-php.dev/en/guide/extensions.html) **static-php-cli** is a powerful tool designed for building static, standalone PHP runtime with popular extensions. @@ -14,9 +15,6 @@ Static PHP built by **static-php-cli** supports `cli`, `fpm`, `embed` and `micro **static-php-cli** also has the ability to package PHP projects along with the PHP interpreter into one single executable file. -- [README - English](./README.md) -- [README - 中文](./README-zh.md) - ## Features static-php-cli (you can call it `spc`) has a lot of features: diff --git a/src/SPC/builder/extension/event.php b/src/SPC/builder/extension/event.php index 7339ad17..a1cc7bcc 100644 --- a/src/SPC/builder/extension/event.php +++ b/src/SPC/builder/extension/event.php @@ -5,6 +5,7 @@ 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; @@ -34,4 +35,16 @@ class event extends Extension FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString()); return true; } + + /** + * @throws FileSystemException + */ + public function patchBeforeMake(): bool + { + // Prevent event extension compile error on macOS + if ($this->builder instanceof MacOSBuilder) { + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', ''); + } + return true; + } } diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index 9f43e8fb..6bbeb864 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -31,6 +31,7 @@ class MacOSToolCheckList 'gzip', 'bzip2', 'cmake', + 'glibtoolize', ]; #[AsCheckItem('if homebrew has installed', limit_os: 'Darwin', level: 998)] @@ -72,8 +73,14 @@ class MacOSToolCheckList #[AsFixItem('build-tools')] public function fixBuildTools(array $missing): bool { + $replacement = [ + 'glibtoolize' => 'libtool', + ]; foreach ($missing as $cmd) { try { + if (isset($replacement[$cmd])) { + $cmd = $replacement[$cmd]; + } shell(true)->exec('brew install --formula ' . escapeshellarg($cmd)); } catch (RuntimeException) { return false; diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index c1fe1be7..53f74ddc 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -197,7 +197,6 @@ class SourcePatcher FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_STRLCAT 1$/m', ''); } if ($builder instanceof UnixBuilderBase) { - FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', ''); FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'install-micro', ''); }