simplify patch logic for grpc (--enable-grpc=PATH does not actually pass a path, needs to be --with-grpc=PATH)

This commit is contained in:
DubbleClick 2025-07-22 16:26:37 +07:00
parent 4010a84d88
commit 107fb08e34
4 changed files with 21 additions and 29 deletions

View File

@ -199,6 +199,6 @@ jobs:
if: ${{ !startsWith(matrix.os, 'windows-') }}
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3

View File

@ -233,7 +233,7 @@
},
"type": "external",
"source": "grpc",
"arg-type-unix": "custom",
"arg-type-unix": "with-prefix",
"cpp-extension": true,
"lib-depends": [
"grpc"

View File

@ -16,23 +16,20 @@ class grpc extends Extension
{
public function patchBeforeBuildconf(): bool
{
// soft link to the grpc source code
if ($this->builder instanceof WindowsBuilder) {
// not support windows yet
throw new \RuntimeException('grpc extension does not support windows yet');
}
if (!is_link(SOURCE_PATH . '/php-src/ext/grpc')) {
if (is_dir($this->builder->getLib('grpc')->getSourceDir() . '/src/php/ext/grpc')) {
shell()->exec('ln -s ' . $this->builder->getLib('grpc')->getSourceDir() . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc');
} else {
throw new \RuntimeException('Cannot find grpc source code');
}
$macos = $this->builder instanceof MacOSBuilder ? "\n" . ' LDFLAGS="$LDFLAGS -framework CoreFoundation"' : '';
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/grpc/config.m4', '/GRPC_LIBDIR=.*$/m', 'GRPC_LIBDIR=' . BUILD_LIB_PATH . $macos);
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/ext/grpc/config.m4', '/SEARCH_PATH=.*$/m', 'SEARCH_PATH="' . BUILD_ROOT_PATH . '"');
return true;
if (file_exists(SOURCE_PATH . '/php-src/ext/grpc')) {
return false;
}
return false;
// soft link to the grpc source code
if (is_dir($this->builder->getLib('grpc')->getSourceDir() . '/src/php/ext/grpc')) {
shell()->exec('ln -s ' . $this->builder->getLib('grpc')->getSourceDir() . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc');
} else {
throw new \RuntimeException('Cannot find grpc source code');
}
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/grpc/config.m4', 'PHP_ARG_ENABLE(grpc,', 'PHP_ARG_WITH(grpc,');
return true;
}
public function patchBeforeConfigure(): bool
@ -62,11 +59,6 @@ class grpc extends Extension
return true;
}
public function getUnixConfigureArg(bool $shared = false): string
{
return '--enable-grpc=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . '/grpc GRPC_LIB_SUBDIR=' . BUILD_LIB_PATH;
}
private function getLibraries(): array
{
$libs = shell()->execWithResult('$PKG_CONFIG --libs --static grpc')[1][0];

View File

@ -21,19 +21,19 @@ $test_php_version = [
// test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available)
$test_os = [
// 'macos-13', // bin/spc for x86_64
'macos-13', // bin/spc for x86_64
// 'macos-14', // bin/spc for arm64
// 'macos-15', // bin/spc for arm64
'macos-15', // bin/spc for arm64
'ubuntu-latest', // bin/spc-alpine-docker for x86_64
// 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
// 'ubuntu-24.04', // bin/spc for x86_64
// 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
// 'ubuntu-24.04-arm', // bin/spc for arm64
'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
'ubuntu-24.04', // bin/spc for x86_64
'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
'ubuntu-24.04-arm', // bin/spc for arm64
// 'windows-latest', // .\bin\spc.ps1
];
// whether enable thread safe
$zts = false;
$zts = true;
$no_strip = false;