Move extra runtime object to zig toolchain

This commit is contained in:
crazywhalecc
2025-07-05 10:48:56 +08:00
parent 013a19e25b
commit 5f8cd972cd
3 changed files with 44 additions and 81 deletions

View File

@@ -4,12 +4,13 @@ declare(strict_types=1);
namespace SPC\builder;
use SPC\builder\linux\SystemUtil;
use SPC\exception\FileSystemException;
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;
class Extension
@@ -216,16 +217,15 @@ class Extension
*/
public function patchBeforeSharedMake(): bool
{
$extra = SystemUtil::getExtraRuntimeObjects();
if (!$extra) {
return false;
if (ToolchainManager::getToolchainClass() === ZigToolchain::class && ($extra = (new ZigToolchain())->getExtraRuntimeObjects())) {
FileSystem::replaceFileRegex(
$this->source_dir . '/Makefile',
"/^(shared_objects_{$this->getName()}\\s*=.*)$/m",
"$1 {$extra}",
);
return true;
}
FileSystem::replaceFileRegex(
$this->source_dir . '/Makefile',
"/^(shared_objects_{$this->getName()}\\s*=.*)$/m",
"$1 {$extra}",
);
return true;
return false;
}
/**