From b88a68dab840e74cadd5b64957a71c07733258ff Mon Sep 17 00:00:00 2001 From: henderkes Date: Wed, 29 Oct 2025 18:55:26 +0100 Subject: [PATCH] fix postgresql libraries when --with-suggested-libs is false --- config/lib.json | 4 ++-- src/SPC/builder/unix/library/postgresql.php | 2 +- src/SPC/util/DependencyUtil.php | 19 ++++++++++++++++++- src/SPC/util/SPCConfigUtil.php | 3 ++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/config/lib.json b/config/lib.json index c3d864f4..4f1dd601 100644 --- a/config/lib.json +++ b/config/lib.json @@ -607,8 +607,8 @@ }, "libxml2": { "source": "libxml2", - "static-libs-unix": [ - "libxml2.a" + "pkg-configs": [ + "libxml-2.0" ], "static-libs-windows": [ "libxml2s.lib", diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 67935d14..a81f93de 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -46,7 +46,7 @@ trait postgresql protected function build(): void { $libs = array_map(fn ($x) => $x->getName(), $this->getDependencies()); - $spc = new SPCConfigUtil($this->getBuilder(), ['no_php' => true, 'libs_only_deps' => true]); + $spc = new SPCConfigUtil($this->builder, ['no_php' => true, 'libs_only_deps' => true]); $config = $spc->config(libraries: $libs, include_suggest_lib: $this->builder->getOption('with-suggested-libs')); $env_vars = [ diff --git a/src/SPC/util/DependencyUtil.php b/src/SPC/util/DependencyUtil.php index 83123f65..c300832d 100644 --- a/src/SPC/util/DependencyUtil.php +++ b/src/SPC/util/DependencyUtil.php @@ -105,7 +105,7 @@ class DependencyUtil * @param array $additional_libs Array of additional libraries * @return array Ordered array of extension names */ - public static function getExtsAndLibs(array $exts, array $additional_libs = [], bool $include_suggested_exts = false, bool $include_suggested_libs = false): array + public static function getExtsAndLibs(array $exts, array $additional_libs = [], bool $include_suggested_exts = false, bool $include_suggested_libs = false, array $extra_libraries_from_builder = []): array { $dep_list = self::platExtToLibs(); @@ -144,6 +144,23 @@ class DependencyUtil $dep_list[$name]['suggests'] = array_values($dep_list[$name]['suggests']); } } + // include suggested libraries + if ($extra_libraries_from_builder) { + // check every deps suggests + foreach ($dep_list as $name => $obj) { + $del_list = []; + foreach ($obj['suggests'] as $id => $suggest) { + if (!str_starts_with($suggest, 'ext@') && in_array($suggest, $extra_libraries_from_builder)) { + $dep_list[$name]['depends'][] = $suggest; + $del_list[] = $id; + } + } + foreach ($del_list as $id) { + unset($dep_list[$name]['suggests'][$id]); + } + $dep_list[$name]['suggests'] = array_values($dep_list[$name]['suggests']); + } + } // convert ext_name to ext@ext_name $origin_exts = $exts; diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index f321ca10..d7f35efb 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -62,7 +62,8 @@ class SPCConfigUtil $extensions[] = $ext; } } - [$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib); + $extra_builder_libs = $this->builder?->getLibs() ?? []; + [$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib, array_map(fn ($l) => $l->getName(), $extra_builder_libs)); ob_start(); if ($this->builder === null) {