mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
Add frameworks for extension
This commit is contained in:
parent
2ea8a7e662
commit
e0734fe848
@ -424,6 +424,10 @@
|
||||
"openssl",
|
||||
"zstd",
|
||||
"zlib"
|
||||
],
|
||||
"frameworks": [
|
||||
"CoreFoundation",
|
||||
"Security"
|
||||
]
|
||||
},
|
||||
"msgpack": {
|
||||
|
||||
@ -53,6 +53,11 @@ class Extension
|
||||
}
|
||||
}
|
||||
|
||||
public function getFrameworks(): array
|
||||
{
|
||||
return Config::getExt($this->getName(), 'frameworks', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取开启该扩展的 PHP 编译添加的参数
|
||||
*
|
||||
|
||||
@ -67,6 +67,10 @@ class MacOSBuilder extends UnixBuilderBase
|
||||
array_push($frameworks, ...$lib->getFrameworks());
|
||||
}
|
||||
|
||||
foreach ($this->exts as $ext) {
|
||||
array_push($frameworks, ...$ext->getFrameworks());
|
||||
}
|
||||
|
||||
if ($asString) {
|
||||
return implode(' ', array_map(fn ($x) => "-framework {$x}", $frameworks));
|
||||
}
|
||||
|
||||
@ -55,10 +55,13 @@ class SPCConfigUtil
|
||||
ob_get_clean();
|
||||
$ldflags = $this->getLdflagsString();
|
||||
$libs = $this->getLibsString($libraries, $with_dependencies);
|
||||
if (PHP_OS_FAMILY === 'Darwin') {
|
||||
$libs .= " {$this->getFrameworksString($extensions)}";
|
||||
}
|
||||
$cflags = $this->getIncludesString();
|
||||
|
||||
// embed
|
||||
$libs = '-lphp -lc ' . $libs;
|
||||
$libs = trim("-lphp -lc {$libs}");
|
||||
$extra_env = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS');
|
||||
if (is_string($extra_env)) {
|
||||
$libs .= ' ' . trim($extra_env, '"');
|
||||
@ -157,4 +160,18 @@ class SPCConfigUtil
|
||||
// get short name
|
||||
return '-l' . substr($lib, 3, -2);
|
||||
}
|
||||
|
||||
private function getFrameworksString(array $extensions): string
|
||||
{
|
||||
$list = [];
|
||||
foreach ($extensions as $extension) {
|
||||
foreach (Config::getExt($extension, 'frameworks', []) as $fw) {
|
||||
$ks = '-framework ' . $fw;
|
||||
if (!in_array($ks, $list)) {
|
||||
$list[] = $ks;
|
||||
}
|
||||
}
|
||||
}
|
||||
return implode(' ', $list);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user