mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 05:14:52 +08:00
add swoole-hook-odbc to work the same way as the other hooks
This commit is contained in:
parent
2694dd9e21
commit
b1da64d46b
@ -843,12 +843,10 @@
|
|||||||
"zlib"
|
"zlib"
|
||||||
],
|
],
|
||||||
"lib-suggests": [
|
"lib-suggests": [
|
||||||
"zstd",
|
"zstd"
|
||||||
"unixodbc"
|
|
||||||
],
|
],
|
||||||
"lib-suggests-linux": [
|
"lib-suggests-linux": [
|
||||||
"zstd",
|
"zstd",
|
||||||
"unixodbc",
|
|
||||||
"liburing"
|
"liburing"
|
||||||
],
|
],
|
||||||
"ext-depends": [
|
"ext-depends": [
|
||||||
@ -859,7 +857,8 @@
|
|||||||
"sockets",
|
"sockets",
|
||||||
"swoole-hook-pgsql",
|
"swoole-hook-pgsql",
|
||||||
"swoole-hook-mysql",
|
"swoole-hook-mysql",
|
||||||
"swoole-hook-sqlite"
|
"swoole-hook-sqlite",
|
||||||
|
"swoole-hook-odbc"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"swoole-hook-mysql": {
|
"swoole-hook-mysql": {
|
||||||
@ -909,6 +908,22 @@
|
|||||||
"swoole"
|
"swoole"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"swoole-hook-odbc": {
|
||||||
|
"support": {
|
||||||
|
"Windows": "no",
|
||||||
|
"BSD": "wip"
|
||||||
|
},
|
||||||
|
"notes": true,
|
||||||
|
"type": "addon",
|
||||||
|
"arg-type": "none",
|
||||||
|
"ext-depends": [
|
||||||
|
"pdo",
|
||||||
|
"swoole"
|
||||||
|
],
|
||||||
|
"lib-depends": [
|
||||||
|
"unixodbc"
|
||||||
|
]
|
||||||
|
},
|
||||||
"swow": {
|
"swow": {
|
||||||
"support": {
|
"support": {
|
||||||
"BSD": "wip"
|
"BSD": "wip"
|
||||||
|
|||||||
@ -8,6 +8,7 @@ use SPC\builder\Extension;
|
|||||||
use SPC\builder\macos\MacOSBuilder;
|
use SPC\builder\macos\MacOSBuilder;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
use SPC\util\CustomExt;
|
use SPC\util\CustomExt;
|
||||||
|
use SPC\util\SPCConfigUtil;
|
||||||
|
|
||||||
#[CustomExt('swoole')]
|
#[CustomExt('swoole')]
|
||||||
class swoole extends Extension
|
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';
|
$arg .= $this->builder->getExt('swoole-hook-sqlite') ? ' --enable-swoole-sqlite' : ' --disable-swoole-sqlite';
|
||||||
|
|
||||||
// enable this feature , need stop pdo_*
|
// 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;
|
return $arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,10 +18,6 @@ class swoole_hook_mysql extends Extension
|
|||||||
|
|
||||||
public function runCliCheckUnix(): void
|
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"');
|
[$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"');
|
||||||
$out = implode('', $out);
|
$out = implode('', $out);
|
||||||
if ($ret !== 0) {
|
if ($ret !== 0) {
|
||||||
|
|||||||
40
src/SPC/builder/extension/swoole_hook_odbc.php
Normal file
40
src/SPC/builder/extension/swoole_hook_odbc.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\exception\ValidationException;
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('swoole-hook-odbc')]
|
||||||
|
class swoole_hook_odbc extends Extension
|
||||||
|
{
|
||||||
|
public function getDistName(): string
|
||||||
|
{
|
||||||
|
return 'swoole';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validate(): void
|
||||||
|
{
|
||||||
|
// pdo_pgsql need to be disabled
|
||||||
|
if ($this->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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -27,10 +27,6 @@ class swoole_hook_pgsql extends Extension
|
|||||||
|
|
||||||
public function runCliCheckUnix(): void
|
public function runCliCheckUnix(): void
|
||||||
{
|
{
|
||||||
// skip if not enable swoole
|
|
||||||
if ($this->builder->getExt('swoole') === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$sharedExtensions = $this->getSharedExtensionLoadString();
|
$sharedExtensions = $this->getSharedExtensionLoadString();
|
||||||
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
|
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
|
||||||
$out = implode('', $out);
|
$out = implode('', $out);
|
||||||
|
|||||||
@ -27,10 +27,6 @@ class swoole_hook_sqlite extends Extension
|
|||||||
|
|
||||||
public function runCliCheckUnix(): void
|
public function runCliCheckUnix(): void
|
||||||
{
|
{
|
||||||
// skip if not enable swoole
|
|
||||||
if ($this->builder->getExt('swoole') === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$sharedExtensions = $this->getSharedExtensionLoadString();
|
$sharedExtensions = $this->getSharedExtensionLoadString();
|
||||||
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
|
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"');
|
||||||
$out = implode('', $out);
|
$out = implode('', $out);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user