diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 33d187c23..b61a10e5d 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -6,6 +6,7 @@ use SPC\exception\ExceptionHandler; use SPC\exception\FileSystemException; +use SPC\exception\InterruptException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; @@ -407,6 +408,13 @@ public function emitPatchPoint(string $point_name): void } logger()->debug('Running additional patch script: ' . $patch); require $patch; + } catch (InterruptException $e) { + if ($e->getCode() === 0) { + logger()->notice('Patch script ' . $patch . ' interrupted' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.')); + } else { + logger()->error('Patch script ' . $patch . ' interrupted with error code [' . $e->getCode() . ']' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.')); + } + exit($e->getCode()); } catch (\Throwable $e) { logger()->critical('Patch script ' . $patch . ' failed to run.'); if ($this->getOption('debug')) { @@ -414,6 +422,7 @@ public function emitPatchPoint(string $point_name): void } else { logger()->critical('Please check with --debug option to see more details.'); } + throw $e; } } } diff --git a/src/SPC/builder/extension/parallel.php b/src/SPC/builder/extension/parallel.php index f50dffb26..de4e5d88c 100644 --- a/src/SPC/builder/extension/parallel.php +++ b/src/SPC/builder/extension/parallel.php @@ -6,6 +6,7 @@ use SPC\builder\Extension; use SPC\exception\WrongUsageException; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('parallel')] @@ -17,4 +18,10 @@ public function validate(): void throw new WrongUsageException('ext-parallel must be built with ZTS builds. Use "--enable-zts" option!'); } } + + public function patchBeforeBuildconf(): bool + { + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/parallel/config.m4', '/PHP_VERSION=.*/m', ''); + return true; + } } diff --git a/src/SPC/exception/InterruptException.php b/src/SPC/exception/InterruptException.php new file mode 100644 index 000000000..b004f47f6 --- /dev/null +++ b/src/SPC/exception/InterruptException.php @@ -0,0 +1,7 @@ +getPatchPoint(); } +function patch_point_interrupt(int $retcode, string $msg = ''): InterruptException +{ + return new InterruptException(message: $msg, code: $retcode); +} + // ------- function f_* part ------- // f_ means standard function wrapper diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 6bf021590..a08ebc7f5 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -26,7 +26,7 @@ ]; // whether enable thread safe -$zts = false; +$zts = true; $no_strip = false; @@ -38,7 +38,7 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'grpc,openssl,pgsql', + 'Linux', 'Darwin' => 'parallel', 'Windows' => 'amqp,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,ds,exif,ffi,fileinfo,filter,ftp,gd,iconv,igbinary,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pdo,pdo_mysql,pdo_sqlite,pdo_sqlsrv,phar,rar,redis,session,shmop,simdjson,simplexml,soap,sockets,sqlite3,sqlsrv,ssh2,swow,sysvshm,tokenizer,xml,xmlreader,xmlwriter,yac,yaml,zip,zlib', }; diff --git a/tests/SPC/builder/BuilderTest.php b/tests/SPC/builder/BuilderTest.php index fe46b785c..5796f5dfe 100644 --- a/tests/SPC/builder/BuilderTest.php +++ b/tests/SPC/builder/BuilderTest.php @@ -246,6 +246,7 @@ public function testEmitPatchPoint(string $point) public function testEmitPatchPointNotExists() { $this->expectOutputRegex('/failed to run/'); + $this->expectException(RuntimeException::class); $this->builder->setOption('with-added-patch', ['/tmp/patch-point.not_exsssists.php']); $this->builder->emitPatchPoint('not-exists'); }