Skip to content

Commit b88a68d

Browse files
committed
fix postgresql libraries when --with-suggested-libs is false
1 parent 5476385 commit b88a68d

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

config/lib.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,8 @@
607607
},
608608
"libxml2": {
609609
"source": "libxml2",
610-
"static-libs-unix": [
611-
"libxml2.a"
610+
"pkg-configs": [
611+
"libxml-2.0"
612612
],
613613
"static-libs-windows": [
614614
"libxml2s.lib",

src/SPC/builder/unix/library/postgresql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function patchBeforeBuild(): bool
4646
protected function build(): void
4747
{
4848
$libs = array_map(fn ($x) => $x->getName(), $this->getDependencies());
49-
$spc = new SPCConfigUtil($this->getBuilder(), ['no_php' => true, 'libs_only_deps' => true]);
49+
$spc = new SPCConfigUtil($this->builder, ['no_php' => true, 'libs_only_deps' => true]);
5050
$config = $spc->config(libraries: $libs, include_suggest_lib: $this->builder->getOption('with-suggested-libs'));
5151

5252
$env_vars = [

src/SPC/util/DependencyUtil.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function getLibs(array $libs, bool $include_suggested_libs = false
105105
* @param array $additional_libs Array of additional libraries
106106
* @return array Ordered array of extension names
107107
*/
108-
public static function getExtsAndLibs(array $exts, array $additional_libs = [], bool $include_suggested_exts = false, bool $include_suggested_libs = false): array
108+
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
109109
{
110110
$dep_list = self::platExtToLibs();
111111

@@ -144,6 +144,23 @@ public static function getExtsAndLibs(array $exts, array $additional_libs = [],
144144
$dep_list[$name]['suggests'] = array_values($dep_list[$name]['suggests']);
145145
}
146146
}
147+
// include suggested libraries
148+
if ($extra_libraries_from_builder) {
149+
// check every deps suggests
150+
foreach ($dep_list as $name => $obj) {
151+
$del_list = [];
152+
foreach ($obj['suggests'] as $id => $suggest) {
153+
if (!str_starts_with($suggest, 'ext@') && in_array($suggest, $extra_libraries_from_builder)) {
154+
$dep_list[$name]['depends'][] = $suggest;
155+
$del_list[] = $id;
156+
}
157+
}
158+
foreach ($del_list as $id) {
159+
unset($dep_list[$name]['suggests'][$id]);
160+
}
161+
$dep_list[$name]['suggests'] = array_values($dep_list[$name]['suggests']);
162+
}
163+
}
147164

148165
// convert ext_name to ext@ext_name
149166
$origin_exts = $exts;

src/SPC/util/SPCConfigUtil.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public function config(array $extensions = [], array $libraries = [], bool $incl
6262
$extensions[] = $ext;
6363
}
6464
}
65-
[$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
65+
$extra_builder_libs = $this->builder?->getLibs() ?? [];
66+
[$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib, array_map(fn ($l) => $l->getName(), $extra_builder_libs));
6667

6768
ob_start();
6869
if ($this->builder === null) {

0 commit comments

Comments
 (0)