mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-07 00:35:41 +08:00
extra dependencies for extensions
This commit is contained in:
@@ -11,6 +11,7 @@ use SPC\exception\FileSystemException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
class SPCConfigUtil
|
||||
@@ -42,7 +43,7 @@ class SPCConfigUtil
|
||||
* @throws WrongUsageException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false): array
|
||||
public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false, $with_dependencies = false): array
|
||||
{
|
||||
[$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
||||
|
||||
@@ -54,7 +55,7 @@ class SPCConfigUtil
|
||||
}
|
||||
ob_get_clean();
|
||||
$ldflags = $this->getLdflagsString();
|
||||
$libs = $this->getLibsString($libraries);
|
||||
$libs = $this->getLibsString($libraries, $with_dependencies);
|
||||
$cflags = $this->getIncludesString();
|
||||
|
||||
// embed
|
||||
@@ -97,13 +98,39 @@ class SPCConfigUtil
|
||||
return '-L' . BUILD_LIB_PATH;
|
||||
}
|
||||
|
||||
private function getLibsString(array $libraries): string
|
||||
private function getLibsString(array $libraries, bool $withDependencies = false): string
|
||||
{
|
||||
$short_name = [];
|
||||
foreach (array_reverse($libraries) as $library) {
|
||||
$libs = Config::getLib($library, 'static-libs', []);
|
||||
foreach ($libs as $lib) {
|
||||
$short_name[] = $this->getShortLibName($lib);
|
||||
if ($withDependencies) {
|
||||
$noExt = str_replace('.a', '', $lib);
|
||||
$requiredLibs = [];
|
||||
$pkgconfFile = BUILD_LIB_PATH . "/pkgconfig/{$noExt}.pc";
|
||||
if (file_exists($pkgconfFile)) {
|
||||
$lines = file($pkgconfFile);
|
||||
foreach ($lines as $value) {
|
||||
if (str_starts_with($value, 'Libs')) {
|
||||
$items = explode(' ', $value);
|
||||
foreach ($items as $item) {
|
||||
$item = trim($item);
|
||||
if (str_starts_with($item, '-l')) {
|
||||
$requiredLibs[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($requiredLibs as $requiredLib) {
|
||||
if (!in_array($requiredLib, $short_name)) {
|
||||
$short_name[] = $requiredLib;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$short_name[] = $this->getShortLibName($lib);
|
||||
}
|
||||
}
|
||||
if (PHP_OS_FAMILY !== 'Darwin') {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user