mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
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:
parent
4010a84d88
commit
107fb08e34
6
.github/workflows/tests.yml
vendored
6
.github/workflows/tests.yml
vendored
@ -199,6 +199,6 @@ jobs:
|
|||||||
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
||||||
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}
|
run: php src/globals/test-extensions.php build_embed_cmd ${{ matrix.os }} ${{ matrix.php }}
|
||||||
|
|
||||||
- name: Setup tmate session
|
# - name: Setup tmate session
|
||||||
if: ${{ failure() }}
|
# if: ${{ failure() }}
|
||||||
uses: mxschmitt/action-tmate@v3
|
# uses: mxschmitt/action-tmate@v3
|
||||||
|
|||||||
@ -233,7 +233,7 @@
|
|||||||
},
|
},
|
||||||
"type": "external",
|
"type": "external",
|
||||||
"source": "grpc",
|
"source": "grpc",
|
||||||
"arg-type-unix": "custom",
|
"arg-type-unix": "with-prefix",
|
||||||
"cpp-extension": true,
|
"cpp-extension": true,
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"grpc"
|
"grpc"
|
||||||
|
|||||||
@ -16,24 +16,21 @@ class grpc extends Extension
|
|||||||
{
|
{
|
||||||
public function patchBeforeBuildconf(): bool
|
public function patchBeforeBuildconf(): bool
|
||||||
{
|
{
|
||||||
// soft link to the grpc source code
|
|
||||||
if ($this->builder instanceof WindowsBuilder) {
|
if ($this->builder instanceof WindowsBuilder) {
|
||||||
// not support windows yet
|
|
||||||
throw new \RuntimeException('grpc extension does not support windows yet');
|
throw new \RuntimeException('grpc extension does not support windows yet');
|
||||||
}
|
}
|
||||||
if (!is_link(SOURCE_PATH . '/php-src/ext/grpc')) {
|
if (file_exists(SOURCE_PATH . '/php-src/ext/grpc')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// soft link to the grpc source code
|
||||||
if (is_dir($this->builder->getLib('grpc')->getSourceDir() . '/src/php/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');
|
shell()->exec('ln -s ' . $this->builder->getLib('grpc')->getSourceDir() . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc');
|
||||||
} else {
|
} else {
|
||||||
throw new \RuntimeException('Cannot find grpc source code');
|
throw new \RuntimeException('Cannot find grpc source code');
|
||||||
}
|
}
|
||||||
$macos = $this->builder instanceof MacOSBuilder ? "\n" . ' LDFLAGS="$LDFLAGS -framework CoreFoundation"' : '';
|
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/grpc/config.m4', 'PHP_ARG_ENABLE(grpc,', 'PHP_ARG_WITH(grpc,');
|
||||||
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;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function patchBeforeConfigure(): bool
|
public function patchBeforeConfigure(): bool
|
||||||
{
|
{
|
||||||
@ -62,11 +59,6 @@ class grpc extends Extension
|
|||||||
return true;
|
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
|
private function getLibraries(): array
|
||||||
{
|
{
|
||||||
$libs = shell()->execWithResult('$PKG_CONFIG --libs --static grpc')[1][0];
|
$libs = shell()->execWithResult('$PKG_CONFIG --libs --static grpc')[1][0];
|
||||||
|
|||||||
@ -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, macos-14, macos-15, ubuntu-latest, windows-latest are available)
|
||||||
$test_os = [
|
$test_os = [
|
||||||
// 'macos-13', // bin/spc for x86_64
|
'macos-13', // bin/spc for x86_64
|
||||||
// 'macos-14', // bin/spc for arm64
|
// '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-latest', // bin/spc-alpine-docker for x86_64
|
||||||
// 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
|
'ubuntu-22.04', // bin/spc-gnu-docker for x86_64
|
||||||
// 'ubuntu-24.04', // bin/spc for x86_64
|
'ubuntu-24.04', // bin/spc for x86_64
|
||||||
// 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
|
'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64
|
||||||
// 'ubuntu-24.04-arm', // bin/spc for arm64
|
'ubuntu-24.04-arm', // bin/spc for arm64
|
||||||
// 'windows-latest', // .\bin\spc.ps1
|
// 'windows-latest', // .\bin\spc.ps1
|
||||||
];
|
];
|
||||||
|
|
||||||
// whether enable thread safe
|
// whether enable thread safe
|
||||||
$zts = false;
|
$zts = true;
|
||||||
|
|
||||||
$no_strip = false;
|
$no_strip = false;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user