mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
46 lines
1.7 KiB
PHP
46 lines
1.7 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace SPC\builder\extension;
|
||
|
|
|
||
|
|
use SPC\builder\Extension;
|
||
|
|
use SPC\builder\macos\MacOSBuilder;
|
||
|
|
use SPC\builder\windows\WindowsBuilder;
|
||
|
|
use SPC\store\FileSystem;
|
||
|
|
use SPC\util\CustomExt;
|
||
|
|
use SPC\util\GlobalEnvManager;
|
||
|
|
|
||
|
|
#[CustomExt('grpc')]
|
||
|
|
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')) {
|
||
|
|
shell()->exec('ln -s ' . $this->builder->getLib('grpc')->getSourceDir() . '/src/php/ext/grpc ' . SOURCE_PATH . '/php-src/ext/grpc');
|
||
|
|
$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;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function patchBeforeMake(): bool
|
||
|
|
{
|
||
|
|
// add -Wno-strict-prototypes
|
||
|
|
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getUnixConfigureArg(): string
|
||
|
|
{
|
||
|
|
return '--enable-grpc=' . BUILD_ROOT_PATH . '/grpc GRPC_LIB_SUBDIR=' . BUILD_LIB_PATH;
|
||
|
|
}
|
||
|
|
}
|