add clickhouse extension by ilia

This commit is contained in:
henderkes
2026-05-09 15:10:30 +07:00
parent dc6e63e1ba
commit 3f48413281
3 changed files with 60 additions and 1 deletions

View 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

View 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;
}
}

View File

@@ -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`).
$extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'curl,swoole',
'Linux', 'Darwin' => 'openssl,zstd,clickhouse',
'Windows' => 'intl',
};