Skip to content

Commit 0719c45

Browse files
committed
Merge remote-tracking branch 'origin/v3-refactor/new-extensions' into v3-refactor/new-extensions
# Conflicts: # config/pkg/ext/builtin-extensions.yml
2 parents 404195a + f414bd2 commit 0719c45

File tree

14 files changed

+231
-14
lines changed

14 files changed

+231
-14
lines changed

config/pkg/ext/builtin-extensions.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,35 @@ ext-gmp:
7676
- gmp
7777
php-extension:
7878
arg-type: with-path
79+
ext-iconv:
80+
type: php-extension
81+
depends@unix:
82+
- libiconv
83+
php-extension:
84+
arg-type@unix: with-path
85+
arg-type@windows: with
86+
ext-intl:
87+
type: php-extension
88+
depends@unix:
89+
- icu
90+
ext-ldap:
91+
type: php-extension
92+
depends:
93+
- ldap
94+
suggests:
95+
- gmp
96+
- libsodium
97+
- ext-openssl
98+
php-extension:
99+
arg-type: with-path
100+
ext-libxml:
101+
type: php-extension
102+
depends:
103+
- ext-xml
104+
php-extension:
105+
build-with-php: true
106+
build-shared: false
107+
arg-type: none
79108
ext-mbregex:
80109
type: php-extension
81110
depends:
@@ -115,6 +144,8 @@ ext-readline:
115144
arg-type: '--with-libedit --without-readline'
116145
build-shared: false
117146
build-static: true
147+
ext-session:
148+
type: php-extension
118149
ext-sockets:
119150
type: php-extension
120151
ext-xml:

config/pkg/ext/ext-grpc.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ext-grpc:
2+
type: php-extension
3+
artifact:
4+
source:
5+
type: pecl
6+
name: grpc
7+
metadata:
8+
license-files: [LICENSE]
9+
license: Apache-2.0
10+
depends:
11+
- grpc
12+
lang: cpp
13+
php-extension:
14+
arg-type@unix: enable-path

config/pkg/ext/ext-igbinary.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ext-igbinary:
2+
type: php-extension
3+
artifact:
4+
source:
5+
type: pecl
6+
name: igbinary
7+
metadata:
8+
license-files: [COPYING]
9+
license: BSD-3-Clause
10+
suggests:
11+
- ext-session
12+
- ext-apcu

config/pkg/ext/ext-imagick.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ext-imagick:
2+
type: php-extension
3+
artifact:
4+
source:
5+
type: pecl
6+
name: imagick
7+
metadata:
8+
license-files: [LICENSE]
9+
license: PHP-3.01
10+
depends:
11+
- imagemagick
12+
php-extension:
13+
arg-type: custom

config/pkg/ext/ext-lz4.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ext-lz4:
2+
type: php-extension
3+
artifact:
4+
source:
5+
type: ghtagtar
6+
repo: kjdev/php-ext-lz4
7+
extract: php-src/ext/lz4
8+
metadata:
9+
license-files: [LICENSE]
10+
license: MIT
11+
depends:
12+
- liblz4
13+
php-extension:
14+
arg-type@unix: '--enable-lz4=@shared_suffix@ --with-lz4-includedir=@build_root_path@'
15+
arg-type@windows: '--enable-lz4'

config/pkg/ext/ext-maxminddb.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ext-maxminddb:
2+
type: php-extension
3+
artifact:
4+
source:
5+
type: pecl
6+
name: maxminddb
7+
metadata:
8+
license-files: [LICENSE]
9+
license: Apache-2.0
10+
depends:
11+
- libmaxminddb
12+
php-extension:
13+
arg-type: with

src/Package/Extension/grpc.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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\Extension;
10+
use StaticPHP\Exception\EnvironmentException;
11+
use StaticPHP\Package\PhpExtensionPackage;
12+
use StaticPHP\Runtime\SystemTarget;
13+
use StaticPHP\Util\FileSystem;
14+
15+
#[Extension('grpc')]
16+
class grpc extends PhpExtensionPackage
17+
{
18+
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-grpc')]
19+
public function patchBeforeBuildconf(): void
20+
{
21+
if (SystemTarget::getTargetOS() === 'Windows') {
22+
throw new EnvironmentException('grpc extension does not support windows yet');
23+
}
24+
25+
// Fix deprecated PHP API usage in call.c
26+
FileSystem::replaceFileStr(
27+
"{$this->getSourceDir()}/src/php/ext/grpc/call.c",
28+
'zend_exception_get_default(TSRMLS_C),',
29+
'zend_ce_exception,',
30+
);
31+
32+
// custom config.m4 content for grpc extension, to prevent building libgrpc.a again
33+
$config_m4 = <<<'M4'
34+
PHP_ARG_ENABLE(grpc, [whether to enable grpc support], [AS_HELP_STRING([--enable-grpc], [Enable grpc support])])
35+
36+
if test "$PHP_GRPC" != "no"; then
37+
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include)
38+
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc)
39+
GRPC_LIBDIR=@@build_lib_path@@
40+
PHP_ADD_LIBPATH($GRPC_LIBDIR)
41+
PHP_ADD_LIBRARY(grpc,,GRPC_SHARED_LIBADD)
42+
LIBS="-lpthread $LIBS"
43+
PHP_ADD_LIBRARY(pthread)
44+
45+
case $host in
46+
*darwin*)
47+
PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD)
48+
;;
49+
*)
50+
PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD)
51+
PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD)
52+
PHP_ADD_LIBRARY(rt)
53+
;;
54+
esac
55+
56+
PHP_NEW_EXTENSION(grpc, @grpc_c_files@, $ext_shared, , -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1)
57+
PHP_SUBST(GRPC_SHARED_LIBADD)
58+
PHP_INSTALL_HEADERS([ext/grpc], [php_grpc.h])
59+
fi
60+
M4;
61+
$replace = get_pack_replace();
62+
// load grpc c files from src/php/ext/grpc
63+
$c_files = glob("{$this->getSourceDir()}/src/php/ext/grpc/*.c");
64+
$replace['@grpc_c_files@'] = implode(" \\\n ", array_map(fn ($f) => 'src/php/ext/grpc/' . basename($f), $c_files));
65+
$config_m4 = str_replace(array_keys($replace), array_values($replace), $config_m4);
66+
file_put_contents("{$this->getSourceDir()}/config.m4", $config_m4);
67+
68+
copy("{$this->getSourceDir()}/src/php/ext/grpc/php_grpc.h", "{$this->getSourceDir()}/php_grpc.h");
69+
}
70+
}

src/Package/Extension/imagick.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Package\Extension;
6+
7+
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
8+
use StaticPHP\Attribute\Package\Extension;
9+
use StaticPHP\Package\PackageBuilder;
10+
11+
#[Extension('imagick')]
12+
class imagick
13+
{
14+
#[CustomPhpConfigureArg('Darwin')]
15+
#[CustomPhpConfigureArg('Linux')]
16+
public function getUnixConfigureArg(bool $shared, PackageBuilder $builder): string
17+
{
18+
$disable_omp = ' ac_cv_func_omp_pause_resource_all=no';
19+
return '--with-imagick=' . ($shared ? 'shared,' : '') . $builder->getBuildRootPath() . $disable_omp;
20+
}
21+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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\Extension;
10+
use StaticPHP\Attribute\PatchDescription;
11+
use StaticPHP\Package\PhpExtensionPackage;
12+
use StaticPHP\Util\FileSystem;
13+
14+
#[Extension('maxminddb')]
15+
class maxminddb extends PhpExtensionPackage
16+
{
17+
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-maxminddb')]
18+
#[PatchDescription('Patch maxminddb extension for buildconf to support new source structure')]
19+
public function patchBeforeBuildconf(): void
20+
{
21+
if (file_exists("{$this->getSourceDir()}/config.m4")) {
22+
return;
23+
}
24+
// move ext/maxminddb/ext/* to ext/maxminddb/
25+
$files = FileSystem::scanDirFiles("{$this->getSourceDir()}/ext", false, true);
26+
foreach ($files as $file) {
27+
rename("{$this->getSourceDir()}/ext/{$file}", "{$this->getSourceDir()}/{$file}");
28+
}
29+
}
30+
}

src/Package/Library/postgresql.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ public function buildUnix(PackageInstaller $installer, PackageBuilder $builder):
119119

120120
// remove dynamic libs
121121
shell()->cd($this->getSourceDir() . '/build')
122-
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so.*")
123-
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so")
122+
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so*")
124123
->exec("rm -rf {$this->getBuildRootPath()}/lib/*.dylib");
125124

126125
FileSystem::replaceFileStr("{$this->getLibDir()}/pkgconfig/libpq.pc", '-lldap', '-lldap -llber');

0 commit comments

Comments
 (0)