mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 00:05:42 +08:00
Move zig-toolchain-only things to zig toolchain class
This commit is contained in:
@@ -9,9 +9,8 @@ use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\toolchain\ToolchainManager;
|
||||
use SPC\toolchain\ZigToolchain;
|
||||
use SPC\util\SPCConfigUtil;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
class Extension
|
||||
{
|
||||
@@ -187,16 +186,11 @@ class Extension
|
||||
*/
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
if (
|
||||
PHP_OS_FAMILY === 'Linux' &&
|
||||
$this->isBuildShared() &&
|
||||
ToolchainManager::getToolchainClass() === ZigToolchain::class &&
|
||||
($extra = (new ZigToolchain())->getExtraRuntimeObjects())
|
||||
) {
|
||||
if (SPCTarget::getTargetOS() === 'Linux' && $this->isBuildShared() && ($objs = getenv('SPC_EXTRA_RUNTIME_OBJECTS'))) {
|
||||
FileSystem::replaceFileRegex(
|
||||
SOURCE_PATH . '/php-src/Makefile',
|
||||
"/^(shared_objects_{$this->getName()}\\s*=.*)$/m",
|
||||
"$1 {$extra}",
|
||||
"$1 {$objs}",
|
||||
);
|
||||
return true;
|
||||
}
|
||||
@@ -230,15 +224,11 @@ class Extension
|
||||
*/
|
||||
public function patchBeforeSharedMake(): bool
|
||||
{
|
||||
if (
|
||||
PHP_OS_FAMILY === 'Linux' &&
|
||||
ToolchainManager::getToolchainClass() === ZigToolchain::class &&
|
||||
($extra = (new ZigToolchain())->getExtraRuntimeObjects())
|
||||
) {
|
||||
if (SPCTarget::getTargetOS() === 'Linux' && ($objs = getenv('SPC_EXTRA_RUNTIME_OBJECTS'))) {
|
||||
FileSystem::replaceFileRegex(
|
||||
$this->source_dir . '/Makefile',
|
||||
"/^(shared_objects_{$this->getName()}\\s*=.*)$/m",
|
||||
"$1 {$extra}",
|
||||
"$1 {$objs}",
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\store\SourcePatcher;
|
||||
use SPC\toolchain\ToolchainManager;
|
||||
use SPC\toolchain\ZigToolchain;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
@@ -62,7 +60,6 @@ class LinuxBuilder extends UnixBuilderBase
|
||||
}
|
||||
// add libstdc++, some extensions or libraries need it
|
||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
|
||||
$extra_libs .= (ToolchainManager::getToolchainClass() === ZigToolchain::class ? ' -lunwind' : '');
|
||||
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||
$cflags = $this->arch_c_flags;
|
||||
f_putenv('CFLAGS=' . $cflags);
|
||||
|
||||
Reference in New Issue
Block a user