From 3052b1cca5246af7de3b3c4c458b6502e00f621a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 31 May 2025 21:01:22 +0700 Subject: [PATCH] change extension_dir, the env variable only has an effect during compilation --- src/SPC/builder/Extension.php | 5 ++++- src/SPC/builder/extension/mbregex.php | 3 +-- src/SPC/builder/extension/swoole_hook_mysql.php | 1 - src/SPC/builder/extension/swoole_hook_pgsql.php | 1 - src/SPC/builder/extension/swoole_hook_sqlite.php | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 06c892a8..1ffc6dc3 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -243,6 +243,10 @@ class Extension } } + if ($ret !== '') { + $ret = ' -d "extension_dir=' . BUILD_MODULES_PATH . '"' . $ret; + } + return $ret; } @@ -255,7 +259,6 @@ class Extension // If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php // If check failed, throw RuntimeException $sharedExtensions = $this->getSharedExtensionLoadString(); - putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); [$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index cdff2903..0e1cad28 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -26,8 +26,7 @@ class mbregex extends Extension */ public function runCliCheckUnix(): void { - $sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? ' -d "extension=mbstring"' : ''; - putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); + $sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? '-d "extension_dir=' . BUILD_MODULES_PATH . '" -d "extension=mbstring"' : ''; [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedext . ' --ri "mbstring" | grep regex', false); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !'); diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index 55a58af3..b45516ee 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -29,7 +29,6 @@ class swoole_hook_mysql extends Extension if ($this->builder->getExt('swoole') === null) { return; } - putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"', false); $out = implode('', $out); if ($ret !== 0) { diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index 68661bd5..dfbf7dc8 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -38,7 +38,6 @@ class swoole_hook_pgsql extends Extension return; } $sharedExtensions = $this->getSharedExtensionLoadString(); - putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); $out = implode('', $out); if ($ret !== 0) { diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index cb217539..29e9ef84 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -38,7 +38,6 @@ class swoole_hook_sqlite extends Extension return; } $sharedExtensions = $this->getSharedExtensionLoadString(); - putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); $out = implode('', $out); if ($ret !== 0) {