mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-09 18:05:36 +08:00
add clickhouse extension by ilia
This commit is contained in:
19
config/pkg/ext/ext-clickhouse.yml
Normal file
19
config/pkg/ext/ext-clickhouse.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
ext-clickhouse:
|
||||||
|
type: php-extension
|
||||||
|
artifact:
|
||||||
|
source:
|
||||||
|
type: ghtar
|
||||||
|
repo: iliaal/php_clickhouse
|
||||||
|
extract: php-src/ext/clickhouse
|
||||||
|
prefer-stable: true
|
||||||
|
metadata:
|
||||||
|
license-files: [LICENSE]
|
||||||
|
license: PHP-3.01
|
||||||
|
suggests@unix:
|
||||||
|
- openssl
|
||||||
|
lang: cpp
|
||||||
|
php-extension:
|
||||||
|
os:
|
||||||
|
- Linux
|
||||||
|
- Darwin
|
||||||
|
arg-type@unix: custom
|
||||||
40
src/Package/Extension/clickhouse.php
Normal file
40
src/Package/Extension/clickhouse.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Package\Extension;
|
||||||
|
|
||||||
|
use Package\Target\php;
|
||||||
|
use StaticPHP\Attribute\Package\BeforeStage;
|
||||||
|
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
|
||||||
|
use StaticPHP\Attribute\Package\Extension;
|
||||||
|
use StaticPHP\Attribute\PatchDescription;
|
||||||
|
use StaticPHP\Package\PackageInstaller;
|
||||||
|
use StaticPHP\Package\PhpExtensionPackage;
|
||||||
|
use StaticPHP\Util\FileSystem;
|
||||||
|
|
||||||
|
#[Extension('clickhouse')]
|
||||||
|
class clickhouse extends PhpExtensionPackage
|
||||||
|
{
|
||||||
|
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-clickhouse')]
|
||||||
|
#[PatchDescription('Replace THIS_DIR=`dirname $0` with PHP_EXT_SRCDIR() in config.m4 so include paths resolve to the ext source dir during PHP main configure (dirname $0 returns "." when run from php-src root).')]
|
||||||
|
public function patchBeforeBuildconfUnix(): void
|
||||||
|
{
|
||||||
|
FileSystem::replaceFileRegex(
|
||||||
|
"{$this->getSourceDir()}/config.m4",
|
||||||
|
'/^(\s*)THIS_DIR=.*/m',
|
||||||
|
'$1THIS_DIR=PHP_EXT_SRCDIR()',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[CustomPhpConfigureArg('Darwin')]
|
||||||
|
#[CustomPhpConfigureArg('Linux')]
|
||||||
|
public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string
|
||||||
|
{
|
||||||
|
$arg = '--enable-clickhouse' . ($shared ? '=shared' : '');
|
||||||
|
if ($installer->getLibraryPackage('openssl')) {
|
||||||
|
$arg .= ' --enable-clickhouse-openssl';
|
||||||
|
}
|
||||||
|
return $arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,7 +50,7 @@ $prefer_pre_built = false;
|
|||||||
|
|
||||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||||
$extensions = match (PHP_OS_FAMILY) {
|
$extensions = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => 'curl,swoole',
|
'Linux', 'Darwin' => 'openssl,zstd,clickhouse',
|
||||||
'Windows' => 'intl',
|
'Windows' => 'intl',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user