mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-09 09:55:37 +08:00
phpstan fix
This commit is contained in:
@@ -9,6 +9,8 @@ use SPC\exception\RuntimeException;
|
|||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\toolchain\ToolchainManager;
|
||||||
|
use SPC\toolchain\ZigToolchain;
|
||||||
use SPC\util\SPCConfigUtil;
|
use SPC\util\SPCConfigUtil;
|
||||||
use SPC\util\SPCTarget;
|
use SPC\util\SPCTarget;
|
||||||
|
|
||||||
@@ -399,16 +401,17 @@ class Extension
|
|||||||
*/
|
*/
|
||||||
public function buildUnixShared(): void
|
public function buildUnixShared(): void
|
||||||
{
|
{
|
||||||
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true);
|
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()]);
|
||||||
|
|
||||||
$env = [
|
$env = [
|
||||||
'CFLAGS' => $config['cflags'],
|
'CFLAGS' => $config['cflags'],
|
||||||
'CXXFLAGS' => $config['cflags'],
|
'CXXFLAGS' => $config['cflags'],
|
||||||
'LDFLAGS' => $config['ldflags'],
|
'LDFLAGS' => $config['ldflags'],
|
||||||
'LIBS' => $config['libs'],
|
'LIBS' => $config['libs'],
|
||||||
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
|
||||||
'SPC_COMPILER_EXTRA' => '-lstdc++',
|
|
||||||
];
|
];
|
||||||
|
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
||||||
|
$env['SPC_COMPILER_EXTRA'] = '-lstdc++';
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->patchBeforeSharedPhpize()) {
|
if ($this->patchBeforeSharedPhpize()) {
|
||||||
logger()->info("Extension [{$this->getName()}] patched before shared phpize");
|
logger()->info("Extension [{$this->getName()}] patched before shared phpize");
|
||||||
@@ -433,11 +436,20 @@ class Extension
|
|||||||
'--enable-shared --disable-static'
|
'--enable-shared --disable-static'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$staticLibString = '';
|
||||||
|
$libs = explode(' ', $config['libs']);
|
||||||
|
foreach ($libs as $lib) {
|
||||||
|
$staticLib = BUILD_LIB_PATH . '/' . str_replace('-l', '', $lib) . '.a';
|
||||||
|
if (file_exists($staticLib)) {
|
||||||
|
$staticLibString .= " {$lib}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// some extensions don't define their dependencies well, this patch is only needed for a few
|
// some extensions don't define their dependencies well, this patch is only needed for a few
|
||||||
FileSystem::replaceFileRegex(
|
FileSystem::replaceFileRegex(
|
||||||
$this->source_dir . '/Makefile',
|
$this->source_dir . '/Makefile',
|
||||||
'/^(.*_SHARED_LIBADD\s*=.*)$/m',
|
'/^(.*_SHARED_LIBADD\s*=.*)$/m',
|
||||||
'$1 ' . $staticLibString
|
'$1 ' . trim($staticLibString)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->patchBeforeSharedMake()) {
|
if ($this->patchBeforeSharedMake()) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class SPCConfigUtil
|
|||||||
* @throws WrongUsageException
|
* @throws WrongUsageException
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false, bool $with_dependencies = false): array
|
public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false): array
|
||||||
{
|
{
|
||||||
[$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
[$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ class SPCConfigUtil
|
|||||||
if (!str_contains($libs, $libcpp)) {
|
if (!str_contains($libs, $libcpp)) {
|
||||||
$libs .= " {$libcpp}";
|
$libs .= " {$libcpp}";
|
||||||
}
|
}
|
||||||
if (str_contains(getenv('OATH'), 'rh/devtoolset-10')) {
|
if (str_contains(getenv('PATH'), 'rh/devtoolset-10')) {
|
||||||
str_replace('-lstdc++', '-l:stdc++.a', $libs);
|
str_replace('-lstdc++', '-l:stdc++.a', $libs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user