Skip to content

Commit 22bec87

Browse files
committed
more merge stuff
1 parent 958fd0c commit 22bec87

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

config/lib.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@
189189
"static-libs-unix": [
190190
"libgrpc.a"
191191
],
192+
"pkg-configs": [
193+
"grpc"
194+
],
192195
"lib-depends": [
193196
"zlib",
194197
"openssl",

src/SPC/builder/extension/grpc.php

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use SPC\store\FileSystem;
1010
use SPC\util\CustomExt;
1111
use SPC\util\GlobalEnvManager;
12+
use SPC\util\SPCConfigUtil;
1213
use SPC\util\SPCTarget;
1314

1415
#[CustomExt('grpc')]
@@ -40,37 +41,17 @@ public function patchBeforeBuildconf(): bool
4041

4142
public function patchBeforeConfigure(): bool
4243
{
43-
$libs = join(' ', $this->getLibraries());
44+
$util = new SPCConfigUtil($this->builder);
45+
$config = $util->config(['grpc']);
46+
$libs = $config['libs'];
4447
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lgrpc', $libs);
4548
return true;
4649
}
4750

4851
public function patchBeforeMake(): bool
4952
{
50-
$extra_libs = trim(getenv('SPC_EXTRA_LIBS'));
51-
$libs = array_map(function (string $lib) {
52-
if (str_starts_with($lib, '-l')) {
53-
$staticLib = substr($lib, 2);
54-
$staticLib = BUILD_LIB_PATH . '/lib' . $staticLib . '.a';
55-
if (file_exists($staticLib)) {
56-
return $staticLib;
57-
}
58-
}
59-
return $lib;
60-
}, $this->getLibraries());
61-
$extra_libs = str_replace(BUILD_LIB_PATH . '/libgrpc.a', join(' ', $libs), $extra_libs);
62-
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
6353
// add -Wno-strict-prototypes
6454
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
6555
return true;
6656
}
67-
68-
private function getLibraries(): array
69-
{
70-
$libs = shell()->execWithResult('$PKG_CONFIG --libs --static grpc')[1][0];
71-
$filtered = preg_replace('/-L\S+/', '', $libs);
72-
$filtered = preg_replace('/(?:\S*\/)?lib([a-zA-Z0-9_+-]+)\.a\b/', '-l$1', $filtered);
73-
$out = preg_replace('/\s+/', ' ', $filtered);
74-
return explode(' ', trim($out));
75-
}
7657
}

0 commit comments

Comments
 (0)