From 1b6d0e35ea6c3f7288e4e28acb5a636870a40554 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 17 May 2023 22:19:28 +0800 Subject: [PATCH] add zts support --- src/SPC/builder/BuilderProvider.php | 2 ++ src/SPC/builder/linux/LinuxBuilder.php | 3 ++- src/SPC/builder/macos/MacOSBuilder.php | 3 ++- src/SPC/command/BuildCliCommand.php | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/BuilderProvider.php b/src/SPC/builder/BuilderProvider.php index 4a19aef2..879153f8 100644 --- a/src/SPC/builder/BuilderProvider.php +++ b/src/SPC/builder/BuilderProvider.php @@ -31,11 +31,13 @@ class BuilderProvider cc: $input->getOption('cc'), cxx: $input->getOption('cxx'), arch: $input->getOption('arch'), + zts: $input->getOption('enable-zts'), ), 'Linux' => new LinuxBuilder( cc: $input->getOption('cc'), cxx: $input->getOption('cxx'), arch: $input->getOption('arch'), + zts: $input->getOption('enable-zts'), ), default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'), }; diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 208d32ce..b8d8757d 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -43,7 +43,7 @@ class LinuxBuilder extends BuilderBase * @throws RuntimeException * @throws WrongUsageException */ - public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null) + public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null, bool $zts = false) { // 初始化一些默认参数 $this->cc = $cc ?? match (SystemUtil::getOSRelease()['dist']) { @@ -53,6 +53,7 @@ class LinuxBuilder extends BuilderBase $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); // 根据 CPU 线程数设置编译进程数 diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 296b8580..cb7f9f56 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -31,7 +31,7 @@ class MacOSBuilder extends BuilderBase * @throws RuntimeException * @throws WrongUsageException */ - public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null) + public function __construct(?string $cc = null, ?string $cxx = null, ?string $arch = null, bool $zts = false) { // 如果是 Debug 模式,才使用 set -x 显示每条执行的命令 $this->set_x = defined('DEBUG_MODE') ? 'set -x' : 'true'; @@ -40,6 +40,7 @@ class MacOSBuilder extends BuilderBase $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 diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 2da580e6..6aad5509 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -26,6 +26,7 @@ class BuildCliCommand extends BuildCommand $this->addOption('build-fpm', null, null, 'build fpm'); $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'); } public function handle(): int