mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
add hasCppExtension check
This commit is contained in:
parent
0e024a8c43
commit
b8e6f9d1be
@ -138,6 +138,7 @@
|
|||||||
},
|
},
|
||||||
"intl": {
|
"intl": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
|
"cpp-extension": true,
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"icu"
|
"icu"
|
||||||
]
|
]
|
||||||
@ -327,6 +328,7 @@
|
|||||||
"type": "external",
|
"type": "external",
|
||||||
"source": "swoole",
|
"source": "swoole",
|
||||||
"arg-type": "custom",
|
"arg-type": "custom",
|
||||||
|
"cpp-extension": true,
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"openssl"
|
"openssl"
|
||||||
],
|
],
|
||||||
|
|||||||
@ -140,6 +140,37 @@ abstract class BuilderBase
|
|||||||
return $this->exts[$name] ?? null;
|
return $this->exts[$name] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有要编译的扩展对象
|
||||||
|
*
|
||||||
|
* @return Extension[]
|
||||||
|
*/
|
||||||
|
public function getExts(): array
|
||||||
|
{
|
||||||
|
return $this->exts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查 C++ 扩展是否存在
|
||||||
|
*
|
||||||
|
* @throws FileSystemException
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws WrongUsageException
|
||||||
|
*/
|
||||||
|
public function hasCppExtension(): bool
|
||||||
|
{
|
||||||
|
// judge cpp-extension
|
||||||
|
$exts = array_keys($this->getExts());
|
||||||
|
$cpp = false;
|
||||||
|
foreach ($exts as $ext) {
|
||||||
|
if (Config::getExt($ext, 'cpp-extension', false) === true) {
|
||||||
|
$cpp = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $cpp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置本次 Builder 是否为仅编译库的模式
|
* 设置本次 Builder 是否为仅编译库的模式
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -139,7 +139,8 @@ class LinuxBuilder extends BuilderBase
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($this->getExt('swoole') || $this->getExt('intl')) {
|
|
||||||
|
if ($this->hasCppExtension()) {
|
||||||
$extra_libs .= ' -lstdc++';
|
$extra_libs .= ' -lstdc++';
|
||||||
}
|
}
|
||||||
if ($this->getExt('imagick')) {
|
if ($this->getExt('imagick')) {
|
||||||
|
|||||||
@ -118,12 +118,15 @@ class MacOSBuilder extends BuilderBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws RuntimeException
|
* @param int $build_target build target
|
||||||
|
* @param bool $bloat just raw add all lib files
|
||||||
* @throws FileSystemException
|
* @throws FileSystemException
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws WrongUsageException
|
||||||
*/
|
*/
|
||||||
public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $bloat = false): void
|
public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $bloat = false): void
|
||||||
{
|
{
|
||||||
$extra_libs = $this->getFrameworks(true) . ' ' . ($this->getExt('swoole') || $this->getExt('intl') ? '-lc++ ' : '');
|
$extra_libs = $this->getFrameworks(true) . ' ' . ($this->hasCppExtension() ? '-lc++' : '');
|
||||||
if (!$bloat) {
|
if (!$bloat) {
|
||||||
$extra_libs .= implode(' ', $this->getAllStaticLibFiles());
|
$extra_libs .= implode(' ', $this->getAllStaticLibFiles());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user