Skip to content

Commit 3f48413

Browse files
committed
add clickhouse extension by ilia
1 parent dc6e63e commit 3f48413

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

config/pkg/ext/ext-clickhouse.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ext-clickhouse:
2+
type: php-extension
3+
artifact:
4+
source:
5+
type: ghtar
6+
repo: iliaal/php_clickhouse
7+
extract: php-src/ext/clickhouse
8+
prefer-stable: true
9+
metadata:
10+
license-files: [LICENSE]
11+
license: PHP-3.01
12+
suggests@unix:
13+
- openssl
14+
lang: cpp
15+
php-extension:
16+
os:
17+
- Linux
18+
- Darwin
19+
arg-type@unix: custom
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Package\Extension;
6+
7+
use Package\Target\php;
8+
use StaticPHP\Attribute\Package\BeforeStage;
9+
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
10+
use StaticPHP\Attribute\Package\Extension;
11+
use StaticPHP\Attribute\PatchDescription;
12+
use StaticPHP\Package\PackageInstaller;
13+
use StaticPHP\Package\PhpExtensionPackage;
14+
use StaticPHP\Util\FileSystem;
15+
16+
#[Extension('clickhouse')]
17+
class clickhouse extends PhpExtensionPackage
18+
{
19+
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-clickhouse')]
20+
#[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).')]
21+
public function patchBeforeBuildconfUnix(): void
22+
{
23+
FileSystem::replaceFileRegex(
24+
"{$this->getSourceDir()}/config.m4",
25+
'/^(\s*)THIS_DIR=.*/m',
26+
'$1THIS_DIR=PHP_EXT_SRCDIR()',
27+
);
28+
}
29+
30+
#[CustomPhpConfigureArg('Darwin')]
31+
#[CustomPhpConfigureArg('Linux')]
32+
public function getUnixConfigureArg(bool $shared, PackageInstaller $installer): string
33+
{
34+
$arg = '--enable-clickhouse' . ($shared ? '=shared' : '');
35+
if ($installer->getLibraryPackage('openssl')) {
36+
$arg .= ' --enable-clickhouse-openssl';
37+
}
38+
return $arg;
39+
}
40+
}

src/globals/test-extensions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
5252
$extensions = match (PHP_OS_FAMILY) {
53-
'Linux', 'Darwin' => 'curl,swoole',
53+
'Linux', 'Darwin' => 'openssl,zstd,clickhouse',
5454
'Windows' => 'intl',
5555
};
5656

0 commit comments

Comments
 (0)