mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
fix grpc shared build (ignores CXXFLAGS, needs CPPFLAGS)
This commit is contained in:
parent
191d345250
commit
d3ba04fc5b
@ -202,6 +202,7 @@
|
|||||||
"openssl",
|
"openssl",
|
||||||
"libcares"
|
"libcares"
|
||||||
],
|
],
|
||||||
|
"cpp-library": true,
|
||||||
"provide-pre-built": true,
|
"provide-pre-built": true,
|
||||||
"frameworks": [
|
"frameworks": [
|
||||||
"CoreFoundation"
|
"CoreFoundation"
|
||||||
|
|||||||
@ -405,22 +405,7 @@ class Extension
|
|||||||
*/
|
*/
|
||||||
public function buildUnixShared(): void
|
public function buildUnixShared(): void
|
||||||
{
|
{
|
||||||
$config = (new SPCConfigUtil($this->builder))->config(
|
$env = $this->getSharedExtensionEnv();
|
||||||
[$this->getName()],
|
|
||||||
array_map(fn ($l) => $l->getName(), $this->getLibraryDependencies(recursive: true)),
|
|
||||||
$this->builder->getOption('with-suggested-exts'),
|
|
||||||
$this->builder->getOption('with-suggested-libs'),
|
|
||||||
);
|
|
||||||
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
|
|
||||||
$preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group ';
|
|
||||||
$postStatic = PHP_OS_FAMILY === 'Darwin' ? '' : ' -Wl,--end-group ';
|
|
||||||
$env = [
|
|
||||||
'CFLAGS' => $config['cflags'],
|
|
||||||
'CXXFLAGS' => $config['cflags'],
|
|
||||||
'LDFLAGS' => $config['ldflags'],
|
|
||||||
'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"),
|
|
||||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
|
||||||
];
|
|
||||||
if (str_contains($env['LIBS'], '-lstdc++') && SPCTarget::getTargetOS() === 'Linux') {
|
if (str_contains($env['LIBS'], '-lstdc++') && SPCTarget::getTargetOS() === 'Linux') {
|
||||||
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
||||||
$env['SPC_COMPILER_EXTRA'] = '-lstdc++';
|
$env['SPC_COMPILER_EXTRA'] = '-lstdc++';
|
||||||
@ -512,6 +497,26 @@ class Extension
|
|||||||
return $this->build_static;
|
return $this->build_static;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getSharedExtensionEnv(): array
|
||||||
|
{
|
||||||
|
$config = (new SPCConfigUtil($this->builder))->config(
|
||||||
|
[$this->getName()],
|
||||||
|
array_map(fn ($l) => $l->getName(), $this->getLibraryDependencies(recursive: true)),
|
||||||
|
$this->builder->getOption('with-suggested-exts'),
|
||||||
|
$this->builder->getOption('with-suggested-libs'),
|
||||||
|
);
|
||||||
|
[$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']);
|
||||||
|
$preStatic = PHP_OS_FAMILY === 'Darwin' ? '' : '-Wl,--start-group ';
|
||||||
|
$postStatic = PHP_OS_FAMILY === 'Darwin' ? '' : ' -Wl,--end-group ';
|
||||||
|
return [
|
||||||
|
'CFLAGS' => $config['cflags'],
|
||||||
|
'CXXFLAGS' => $config['cflags'],
|
||||||
|
'LDFLAGS' => $config['ldflags'],
|
||||||
|
'LIBS' => clean_spaces("{$preStatic} {$staticLibs} {$postStatic} {$sharedLibs}"),
|
||||||
|
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
protected function addLibraryDependency(string $name, bool $optional = false): void
|
protected function addLibraryDependency(string $name, bool $optional = false): void
|
||||||
{
|
{
|
||||||
$depLib = $this->builder->getLib($name);
|
$depLib = $this->builder->getLib($name);
|
||||||
@ -570,7 +575,7 @@ class Extension
|
|||||||
return [trim($staticLibString), trim($sharedLibString)];
|
return [trim($staticLibString), trim($sharedLibString)];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getLibraryDependencies(bool $recursive = false): array
|
protected function getLibraryDependencies(bool $recursive = false): array
|
||||||
{
|
{
|
||||||
$ret = array_filter($this->dependencies, fn ($x) => $x instanceof LibraryBase);
|
$ret = array_filter($this->dependencies, fn ($x) => $x instanceof LibraryBase);
|
||||||
if (!$recursive) {
|
if (!$recursive) {
|
||||||
|
|||||||
@ -56,4 +56,10 @@ class grpc extends Extension
|
|||||||
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getSharedExtensionEnv(): array
|
||||||
|
{
|
||||||
|
$env = parent::getSharedExtensionEnv();
|
||||||
|
$env['CPPFLAGS'] = $env['CXXFLAGS'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user