diff --git a/config/ext.json b/config/ext.json index d8394913..8e02b118 100644 --- a/config/ext.json +++ b/config/ext.json @@ -843,12 +843,10 @@ "zlib" ], "lib-suggests": [ - "zstd", - "unixodbc" + "zstd" ], "lib-suggests-linux": [ "zstd", - "unixodbc", "liburing" ], "ext-depends": [ @@ -859,7 +857,8 @@ "sockets", "swoole-hook-pgsql", "swoole-hook-mysql", - "swoole-hook-sqlite" + "swoole-hook-sqlite", + "swoole-hook-odbc" ] }, "swoole-hook-mysql": { @@ -909,6 +908,22 @@ "swoole" ] }, + "swoole-hook-odbc": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "notes": true, + "type": "addon", + "arg-type": "none", + "ext-depends": [ + "pdo", + "swoole" + ], + "lib-depends": [ + "unixodbc" + ] + }, "swow": { "support": { "BSD": "wip" diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 57158dbe..9d288fe7 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -8,6 +8,7 @@ use SPC\builder\Extension; use SPC\builder\macos\MacOSBuilder; use SPC\store\FileSystem; use SPC\util\CustomExt; +use SPC\util\SPCConfigUtil; #[CustomExt('swoole')] class swoole extends Extension @@ -76,7 +77,8 @@ class swoole extends Extension $arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite'; // enable this feature , need stop pdo_* - $arg .= $this->builder->getLib('unixodbc') && !$this->builder->getExt('pdo')?->isBuildStatic() ? ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH : ''; + $config = (new SPCConfigUtil($this->builder, ['libs_only_deps' => true]))->config([], ['unixodbc']); + $arg .= $this->builder->getExt('swoole-hook-odbc') ? ' --with-swoole-odbc=unixODBC,' . BUILD_ROOT_PATH . ' SWOOLE_ODBC_LIBS="' . $config['libs'] . '"' : ''; return $arg; } } diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index 0c005aee..24f65911 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -18,10 +18,6 @@ class swoole_hook_mysql extends Extension public function runCliCheckUnix(): void { - // skip if not enable swoole - if ($this->builder->getExt('swoole') === null) { - return; - } [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"'); $out = implode('', $out); if ($ret !== 0) { diff --git a/src/SPC/builder/extension/swoole_hook_odbc.php b/src/SPC/builder/extension/swoole_hook_odbc.php new file mode 100644 index 00000000..93d70c14 --- /dev/null +++ b/src/SPC/builder/extension/swoole_hook_odbc.php @@ -0,0 +1,40 @@ +builder->getExt('pdo_odbc')?->isBuildStatic()) { + throw new WrongUsageException('swoole-hook-odbc provides pdo_odbc, if you enable odbc hook for swoole, you must remove pdo_odbc extension.'); + } + } + + public function runCliCheckUnix(): void + { + $sharedExtensions = $this->getSharedExtensionLoadString(); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); + $out = implode('', $out); + if ($ret !== 0) { + throw new ValidationException("extension {$this->getName()} failed compile check: php-cli returned {$ret}", validation_module: "Extension {$this->getName()} sanity check"); + } + if (!str_contains($out, 'coroutine_odbc')) { + throw new ValidationException('swoole sqlite hook is not enabled correctly.', validation_module: 'Extension swoole sqlite hook availability check'); + } + } +} diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index 7bbc1a1f..a653d98d 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -27,10 +27,6 @@ class swoole_hook_pgsql extends Extension public function runCliCheckUnix(): void { - // skip if not enable swoole - if ($this->builder->getExt('swoole') === null) { - return; - } $sharedExtensions = $this->getSharedExtensionLoadString(); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); $out = implode('', $out); diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index 4985bd5c..81cdfec3 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -27,10 +27,6 @@ class swoole_hook_sqlite extends Extension public function runCliCheckUnix(): void { - // skip if not enable swoole - if ($this->builder->getExt('swoole') === null) { - return; - } $sharedExtensions = $this->getSharedExtensionLoadString(); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); $out = implode('', $out);