diff --git a/config/pkg/ext/builtin-extensions.yml b/config/pkg/ext/builtin-extensions.yml index 742358eb..7bbb3454 100644 --- a/config/pkg/ext/builtin-extensions.yml +++ b/config/pkg/ext/builtin-extensions.yml @@ -76,6 +76,35 @@ ext-gmp: - gmp php-extension: arg-type: with-path +ext-iconv: + type: php-extension + depends@unix: + - libiconv + php-extension: + arg-type@unix: with-path + arg-type@windows: with +ext-intl: + type: php-extension + depends@unix: + - icu +ext-ldap: + type: php-extension + depends: + - ldap + suggests: + - gmp + - libsodium + - ext-openssl + php-extension: + arg-type: with-path +ext-libxml: + type: php-extension + depends: + - ext-xml + php-extension: + build-with-php: true + build-shared: false + arg-type: none ext-mbregex: type: php-extension depends: @@ -115,6 +144,8 @@ ext-readline: arg-type: '--with-libedit --without-readline' build-shared: false build-static: true +ext-session: + type: php-extension ext-sockets: type: php-extension ext-xml: diff --git a/config/pkg/ext/ext-grpc.yml b/config/pkg/ext/ext-grpc.yml new file mode 100644 index 00000000..ff5bae7b --- /dev/null +++ b/config/pkg/ext/ext-grpc.yml @@ -0,0 +1,14 @@ +ext-grpc: + type: php-extension + artifact: + source: + type: pecl + name: grpc + metadata: + license-files: [LICENSE] + license: Apache-2.0 + depends: + - grpc + lang: cpp + php-extension: + arg-type@unix: enable-path diff --git a/config/pkg/ext/ext-igbinary.yml b/config/pkg/ext/ext-igbinary.yml new file mode 100644 index 00000000..1a80831b --- /dev/null +++ b/config/pkg/ext/ext-igbinary.yml @@ -0,0 +1,12 @@ +ext-igbinary: + type: php-extension + artifact: + source: + type: pecl + name: igbinary + metadata: + license-files: [COPYING] + license: BSD-3-Clause + suggests: + - ext-session + - ext-apcu diff --git a/config/pkg/ext/ext-imagick.yml b/config/pkg/ext/ext-imagick.yml new file mode 100644 index 00000000..e6f9843e --- /dev/null +++ b/config/pkg/ext/ext-imagick.yml @@ -0,0 +1,13 @@ +ext-imagick: + type: php-extension + artifact: + source: + type: pecl + name: imagick + metadata: + license-files: [LICENSE] + license: PHP-3.01 + depends: + - imagemagick + php-extension: + arg-type: custom diff --git a/config/pkg/ext/ext-lz4.yml b/config/pkg/ext/ext-lz4.yml new file mode 100644 index 00000000..8a3bb4db --- /dev/null +++ b/config/pkg/ext/ext-lz4.yml @@ -0,0 +1,15 @@ +ext-lz4: + type: php-extension + artifact: + source: + type: ghtagtar + repo: kjdev/php-ext-lz4 + extract: php-src/ext/lz4 + metadata: + license-files: [LICENSE] + license: MIT + depends: + - liblz4 + php-extension: + arg-type@unix: '--enable-lz4=@shared_suffix@ --with-lz4-includedir=@build_root_path@' + arg-type@windows: '--enable-lz4' diff --git a/config/pkg/ext/ext-maxminddb.yml b/config/pkg/ext/ext-maxminddb.yml new file mode 100644 index 00000000..59d7e4e3 --- /dev/null +++ b/config/pkg/ext/ext-maxminddb.yml @@ -0,0 +1,13 @@ +ext-maxminddb: + type: php-extension + artifact: + source: + type: pecl + name: maxminddb + metadata: + license-files: [LICENSE] + license: Apache-2.0 + depends: + - libmaxminddb + php-extension: + arg-type: with diff --git a/src/Package/Extension/grpc.php b/src/Package/Extension/grpc.php new file mode 100644 index 00000000..c3b08f16 --- /dev/null +++ b/src/Package/Extension/grpc.php @@ -0,0 +1,70 @@ +getSourceDir()}/src/php/ext/grpc/call.c", + 'zend_exception_get_default(TSRMLS_C),', + 'zend_ce_exception,', + ); + + // custom config.m4 content for grpc extension, to prevent building libgrpc.a again + $config_m4 = <<<'M4' +PHP_ARG_ENABLE(grpc, [whether to enable grpc support], [AS_HELP_STRING([--enable-grpc], [Enable grpc support])]) + +if test "$PHP_GRPC" != "no"; then + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include) + PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc) + GRPC_LIBDIR=@@build_lib_path@@ + PHP_ADD_LIBPATH($GRPC_LIBDIR) + PHP_ADD_LIBRARY(grpc,,GRPC_SHARED_LIBADD) + LIBS="-lpthread $LIBS" + PHP_ADD_LIBRARY(pthread) + + case $host in + *darwin*) + PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD) + ;; + *) + PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD) + PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) + PHP_ADD_LIBRARY(rt) + ;; + esac + + PHP_NEW_EXTENSION(grpc, @grpc_c_files@, $ext_shared, , -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1) + PHP_SUBST(GRPC_SHARED_LIBADD) + PHP_INSTALL_HEADERS([ext/grpc], [php_grpc.h]) +fi +M4; + $replace = get_pack_replace(); + // load grpc c files from src/php/ext/grpc + $c_files = glob("{$this->getSourceDir()}/src/php/ext/grpc/*.c"); + $replace['@grpc_c_files@'] = implode(" \\\n ", array_map(fn ($f) => 'src/php/ext/grpc/' . basename($f), $c_files)); + $config_m4 = str_replace(array_keys($replace), array_values($replace), $config_m4); + file_put_contents("{$this->getSourceDir()}/config.m4", $config_m4); + + copy("{$this->getSourceDir()}/src/php/ext/grpc/php_grpc.h", "{$this->getSourceDir()}/php_grpc.h"); + } +} diff --git a/src/Package/Extension/imagick.php b/src/Package/Extension/imagick.php new file mode 100644 index 00000000..2d2aa0aa --- /dev/null +++ b/src/Package/Extension/imagick.php @@ -0,0 +1,21 @@ +getBuildRootPath() . $disable_omp; + } +} diff --git a/src/Package/Extension/maxminddb.php b/src/Package/Extension/maxminddb.php new file mode 100644 index 00000000..bda8d34c --- /dev/null +++ b/src/Package/Extension/maxminddb.php @@ -0,0 +1,30 @@ +getSourceDir()}/config.m4")) { + return; + } + // move ext/maxminddb/ext/* to ext/maxminddb/ + $files = FileSystem::scanDirFiles("{$this->getSourceDir()}/ext", false, true); + foreach ($files as $file) { + rename("{$this->getSourceDir()}/ext/{$file}", "{$this->getSourceDir()}/{$file}"); + } + } +} diff --git a/src/Package/Library/postgresql.php b/src/Package/Library/postgresql.php index 18893d0e..682b79e2 100644 --- a/src/Package/Library/postgresql.php +++ b/src/Package/Library/postgresql.php @@ -119,8 +119,7 @@ class postgresql extends LibraryPackage // remove dynamic libs shell()->cd($this->getSourceDir() . '/build') - ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so.*") - ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so") + ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.so*") ->exec("rm -rf {$this->getBuildRootPath()}/lib/*.dylib"); FileSystem::replaceFileStr("{$this->getLibDir()}/pkgconfig/libpq.pc", '-lldap', '-lldap -llber'); diff --git a/src/Package/Target/php/frankenphp.php b/src/Package/Target/php/frankenphp.php index 8b2fb81d..f513242b 100644 --- a/src/Package/Target/php/frankenphp.php +++ b/src/Package/Target/php/frankenphp.php @@ -91,6 +91,7 @@ trait frankenphp 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' . '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . '-X \'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy\' ' . + '-X \'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp\' ' . '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . "v{$frankenphp_version} PHP {$libphp_version} Caddy'\\\" " . "-tags={$muslTags}nobadger,nomysql,nopgx{$no_brotli}{$no_watcher}", diff --git a/src/StaticPHP/Package/PhpExtensionPackage.php b/src/StaticPHP/Package/PhpExtensionPackage.php index bae11748..7064d041 100644 --- a/src/StaticPHP/Package/PhpExtensionPackage.php +++ b/src/StaticPHP/Package/PhpExtensionPackage.php @@ -94,7 +94,7 @@ class PhpExtensionPackage extends Package 'enable-path' => $shared ? "--enable-{$name}=shared,{$escapedPath}" : "--enable-{$name}={$escapedPath}", 'with' => $shared ? "--with-{$name}=shared" : "--with-{$name}", 'with-path' => $shared ? "--with-{$name}=shared,{$escapedPath}" : "--with-{$name}={$escapedPath}", - 'custom' => '', + 'custom', 'none' => '', default => $arg_type, }; // customize argument from config string diff --git a/src/StaticPHP/Runtime/Executor/UnixAutoconfExecutor.php b/src/StaticPHP/Runtime/Executor/UnixAutoconfExecutor.php index 41bc6e78..c59859cf 100644 --- a/src/StaticPHP/Runtime/Executor/UnixAutoconfExecutor.php +++ b/src/StaticPHP/Runtime/Executor/UnixAutoconfExecutor.php @@ -20,8 +20,6 @@ class UnixAutoconfExecutor extends Executor protected array $configure_args = []; - protected array $ignore_args = []; - protected PackageInstaller $installer; public function __construct(protected LibraryPackage $package, ?PackageInstaller $installer = null) @@ -40,6 +38,8 @@ class UnixAutoconfExecutor extends Executor if (!$this->package->hasStage('build')) { throw new SPCInternalException("Package {$this->package->getName()} does not have a build stage defined."); } + + $this->configure_args = $this->getDefaultConfigureArgs(); } /** @@ -48,18 +48,12 @@ class UnixAutoconfExecutor extends Executor public function configure(...$args): static { // remove all the ignored args - $args = array_merge($args, $this->getDefaultConfigureArgs(), $this->configure_args); - $args = array_diff($args, $this->ignore_args); + $args = array_merge($args, $this->configure_args); $configure_args = implode(' ', $args); InteractiveTerm::setMessage('Building package: ' . ConsoleColor::yellow($this->package->getName()) . ' (./configure)'); return $this->seekLogFileOnException(fn () => $this->shell->exec("./configure {$configure_args}")); } - public function getConfigureArgsString(): string - { - return implode(' ', array_merge($this->getDefaultConfigureArgs(), $this->configure_args)); - } - /** * Run make * @@ -134,7 +128,7 @@ class UnixAutoconfExecutor extends Executor */ public function removeConfigureArgs(...$args): static { - $this->ignore_args = [...$this->ignore_args, ...$args]; + $this->configure_args = array_diff($this->configure_args, $args); return $this; } diff --git a/src/StaticPHP/Util/System/UnixUtil.php b/src/StaticPHP/Util/System/UnixUtil.php index 7d7ddfe2..4a41c524 100644 --- a/src/StaticPHP/Util/System/UnixUtil.php +++ b/src/StaticPHP/Util/System/UnixUtil.php @@ -74,7 +74,11 @@ abstract class UnixUtil throw new SPCInternalException("The symbol file {$symbol_file} does not exist, please check if nm command is available."); } // https://github.com/ziglang/zig/issues/24662 - if (SystemTarget::getTargetOS() !== 'Linux' || ApplicationContext::get(ToolchainInterface::class) instanceof ZigToolchain) { + $toolchain = ApplicationContext::get(ToolchainInterface::class); + if ($toolchain instanceof ZigToolchain) { + return '-Wl,--export-dynamic'; // needs release 0.16, can be removed then + } + if (SystemTarget::getTargetOS() !== 'Linux') { return "-Wl,-exported_symbols_list,{$symbol_file}"; } return "-Wl,--dynamic-list={$symbol_file}";