|
5 | 5 | namespace SPC\builder; |
6 | 6 |
|
7 | 7 | use SPC\exception\EnvironmentException; |
8 | | -use SPC\exception\FileSystemException; |
9 | 8 | use SPC\exception\SPCException; |
10 | 9 | use SPC\exception\ValidationException; |
11 | 10 | use SPC\exception\WrongUsageException; |
12 | 11 | use SPC\store\Config; |
13 | 12 | use SPC\store\FileSystem; |
14 | | -use SPC\toolchain\ClangNativeToolchain; |
15 | | -use SPC\toolchain\GccNativeToolchain; |
16 | | -use SPC\toolchain\ToolchainManager; |
17 | | -use SPC\toolchain\ZigToolchain; |
18 | 13 | use SPC\util\SPCConfigUtil; |
19 | 14 | use SPC\util\SPCTarget; |
20 | 15 |
|
@@ -226,11 +221,11 @@ public function patchBeforeSharedConfigure(): bool |
226 | 221 | public function patchBeforeSharedMake(): bool |
227 | 222 | { |
228 | 223 | $config = (new SPCConfigUtil($this->builder))->config([$this->getName()], array_map(fn ($l) => $l->getName(), $this->builder->getLibs())); |
229 | | - [$staticLibs] = $this->splitLibsIntoStaticAndShared($config['libs']); |
| 224 | + [$staticLibs, $sharedLibs] = $this->splitLibsIntoStaticAndShared($config['libs']); |
230 | 225 | FileSystem::replaceFileRegex( |
231 | 226 | $this->source_dir . '/Makefile', |
232 | 227 | '/^(.*_SHARED_LIBADD\s*=.*)$/m', |
233 | | - '$1 ' . trim($staticLibs) |
| 228 | + clean_spaces("$1 {$staticLibs} {$sharedLibs}") |
234 | 229 | ); |
235 | 230 | if ($objs = getenv('SPC_EXTRA_RUNTIME_OBJECTS')) { |
236 | 231 | FileSystem::replaceFileRegex( |
@@ -406,26 +401,6 @@ public function buildShared(array $visited = []): void |
406 | 401 | public function buildUnixShared(): void |
407 | 402 | { |
408 | 403 | $env = $this->getSharedExtensionEnv(); |
409 | | - if (str_contains($env['LIBS'], '-lstdc++') && SPCTarget::getTargetOS() === 'Linux') { |
410 | | - if (ToolchainManager::getToolchainClass() === ZigToolchain::class) { |
411 | | - $env['SPC_COMPILER_EXTRA'] = '-lstdc++'; |
412 | | - } elseif (ToolchainManager::getToolchainClass() === GccNativeToolchain::class || ToolchainManager::getToolchainClass() === ClangNativeToolchain::class) { |
413 | | - try { |
414 | | - $content = FileSystem::readFile($this->source_dir . '/config.m4'); |
415 | | - if ($content && !str_contains($content, 'PHP_ADD_LIBRARY(stdc++')) { |
416 | | - $pattern = '/(PHP_NEW_EXTENSION\(' . $this->name . ',.*\))/m'; |
417 | | - $replacement = "$1\nPHP_ADD_LIBRARY(stdc++, 1, " . strtoupper($this->name) . '_SHARED_LIBADD)'; |
418 | | - FileSystem::replaceFileRegex( |
419 | | - $this->source_dir . '/config.m4', |
420 | | - $pattern, |
421 | | - $replacement |
422 | | - ); |
423 | | - } |
424 | | - } catch (FileSystemException) { |
425 | | - } |
426 | | - } |
427 | | - } |
428 | | - |
429 | 404 | if ($this->patchBeforeSharedPhpize()) { |
430 | 405 | logger()->info("Extension [{$this->getName()}] patched before shared phpize"); |
431 | 406 | } |
@@ -593,12 +568,12 @@ protected function getLibraryDependencies(bool $recursive = false): array |
593 | 568 | $added = 0; |
594 | 569 | foreach ($ret as $depName => $dep) { |
595 | 570 | foreach ($dep->getDependencies(true) as $depdepName => $depdep) { |
596 | | - if (!in_array($depdepName, array_keys($deps), true)) { |
| 571 | + if (!array_key_exists($depdepName, $deps)) { |
597 | 572 | $deps[$depdepName] = $depdep; |
598 | 573 | ++$added; |
599 | 574 | } |
600 | 575 | } |
601 | | - if (!in_array($depName, array_keys($deps), true)) { |
| 576 | + if (!array_key_exists($depName, $deps)) { |
602 | 577 | $deps[$depName] = $dep; |
603 | 578 | } |
604 | 579 | } |
|
0 commit comments