Skip to content

Commit f93ad27

Browse files
committed
allow using some libs as system provided (work around mssql linking vs system openssl)
1 parent b690566 commit f93ad27

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

config/lib.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,9 @@
862862
},
863863
"openssl": {
864864
"source": "openssl",
865+
"pkg-configs": [
866+
"openssl"
867+
],
865868
"static-libs-unix": [
866869
"libssl.a",
867870
"libcrypto.a"
@@ -974,6 +977,11 @@
974977
},
975978
"unixodbc": {
976979
"source": "unixodbc",
980+
"pkg-configs": [
981+
"odbc",
982+
"odbccr",
983+
"odbcinst"
984+
],
977985
"static-libs-unix": [
978986
"libodbc.a",
979987
"libodbccr.a",
@@ -1015,6 +1023,9 @@
10151023
},
10161024
"zlib": {
10171025
"source": "zlib",
1026+
"pkg-configs": [
1027+
"zlib"
1028+
],
10181029
"static-libs-unix": [
10191030
"libz.a"
10201031
],
@@ -1028,6 +1039,9 @@
10281039
},
10291040
"zstd": {
10301041
"source": "zstd",
1042+
"pkg-configs": [
1043+
"libzstd"
1044+
],
10311045
"static-libs-unix": [
10321046
"libzstd.a"
10331047
],

src/SPC/builder/Extension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public function getLibFilesString(): string
9696
fn ($x) => $x->getStaticLibFiles(),
9797
$this->getLibraryDependencies(recursive: true)
9898
);
99-
return implode(' ', $ret);
99+
$libs = implode(' ', $ret);
100+
return deduplicate_flags($libs);
100101
}
101102

102103
/**

src/SPC/builder/LibraryBase.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,24 @@ protected function installLicense(): void
365365

366366
protected function isLibraryInstalled(): bool
367367
{
368+
if ($pkg_configs = Config::getLib(static::NAME, 'pkg-configs', [])) {
369+
$pkg_config_path = getenv('PKG_CONFIG_PATH') ?: '';
370+
$search_paths = array_unique(array_filter(explode(is_unix() ? ':' : ';', $pkg_config_path)));
371+
372+
foreach ($pkg_configs as $name) {
373+
$found = false;
374+
foreach ($search_paths as $path) {
375+
if (file_exists($path . "/{$name}.pc")) {
376+
$found = true;
377+
break;
378+
}
379+
}
380+
if (!$found) {
381+
return false;
382+
}
383+
}
384+
return true; // allow using system dependencies if pkg_config_path is explicitly defined
385+
}
368386
foreach (Config::getLib(static::NAME, 'static-libs', []) as $name) {
369387
if (!file_exists(BUILD_LIB_PATH . "/{$name}")) {
370388
return false;

0 commit comments

Comments
 (0)