diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index fb78849c..af5b7a50 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,17 +1,12 @@ ## What does this PR do? + ## Checklist before merging -> If your PR involves the changes mentioned below and completed the action, please tick the corresponding option. -> If a modification is not involved, please skip it directly. - -- If you modified `*.php` or `*.json`, run them locally to ensure your changes are valid: +- If you modified `*.php` or `*.yml`, run them locally to ensure your changes are valid: - [ ] `composer cs-fix` - [ ] `composer analyse` - [ ] `composer test` - - [ ] `bin/spc dev:sort-config` -- If it's an extension or dependency update, please ensure the following: - - [ ] Add your test combination to `src/globals/test-extensions.php`. - - [ ] If adding new or fixing bugs, add commit message containing `extension test` or `test extensions` to trigger full test suite. + - [ ] `bin/spc dev:lint-config` diff --git a/config/pkg/ext/ext-clickhouse.yml b/config/pkg/ext/ext-clickhouse.yml new file mode 100644 index 00000000..3e8479bd --- /dev/null +++ b/config/pkg/ext/ext-clickhouse.yml @@ -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 diff --git a/src/Package/Extension/clickhouse.php b/src/Package/Extension/clickhouse.php new file mode 100644 index 00000000..3e11975f --- /dev/null +++ b/src/Package/Extension/clickhouse.php @@ -0,0 +1,40 @@ +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; + } +} diff --git a/src/Package/Target/php/unix.php b/src/Package/Target/php/unix.php index 2b832fe5..7d4d0063 100644 --- a/src/Package/Target/php/unix.php +++ b/src/Package/Target/php/unix.php @@ -352,14 +352,13 @@ trait unix // ------------- SPC_CMD_VAR_PHP_EMBED_TYPE=static ------------- - // process libphp.a for static embed - if (!file_exists("{$package->getLibDir()}/libphp.a")) { - return; + // process libphp.a for static embed (only when present) + if (file_exists("{$package->getLibDir()}/libphp.a")) { + $ar = getenv('AR') ?: 'ar'; + $libphp_a = "{$package->getLibDir()}/libphp.a"; + shell()->exec("{$ar} -t {$libphp_a} | grep '\\.a$' | xargs -n1 {$ar} d {$libphp_a}"); + UnixUtil::exportDynamicSymbols($libphp_a); } - $ar = getenv('AR') ?: 'ar'; - $libphp_a = "{$package->getLibDir()}/libphp.a"; - shell()->exec("{$ar} -t {$libphp_a} | grep '\\.a$' | xargs -n1 {$ar} d {$libphp_a}"); - UnixUtil::exportDynamicSymbols($libphp_a); // deploy embed php scripts $package->runStage([$this, 'patchUnixEmbedScripts']); @@ -508,7 +507,8 @@ trait unix if (file_exists(BUILD_BIN_PATH . '/php-config')) { logger()->debug('Patching php-config prefix and libs order'); $php_config_str = FileSystem::readFile(BUILD_BIN_PATH . '/php-config'); - $php_config_str = str_replace('prefix=""', 'prefix="' . BUILD_ROOT_PATH . '"', $php_config_str); + // anchor to start-of-line so we don't also match `program_prefix=""` + $php_config_str = preg_replace('/^prefix=""/m', 'prefix="' . BUILD_ROOT_PATH . '"', $php_config_str); // move mimalloc to the beginning of libs $php_config_str = preg_replace('/(libs=")(.*?)\s*(' . preg_quote(BUILD_LIB_PATH, '/') . '\/mimalloc\.o)\s*(.*?)"/', '$1$3 $2 $4"', $php_config_str); // move lstdc++ to the end of libs diff --git a/src/StaticPHP/Package/PhpExtensionPackage.php b/src/StaticPHP/Package/PhpExtensionPackage.php index 1201496d..fef88efd 100644 --- a/src/StaticPHP/Package/PhpExtensionPackage.php +++ b/src/StaticPHP/Package/PhpExtensionPackage.php @@ -306,7 +306,7 @@ class PhpExtensionPackage extends Package shell()->cd($package->getSourceDir()) ->setEnv($env) ->exec( - './configure ' . $this->getPhpConfigureArg(SystemTarget::getCurrentPlatformString(), true) . + './configure ' . $this->getPhpConfigureArg(SystemTarget::getTargetOS(), true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' . "--enable-shared --disable-static {$phpvars}" ); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 8281f88b..2e6e807e 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -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', };