This commit is contained in:
DubbleClick 2025-07-01 14:02:10 +07:00
parent 0a33fba23e
commit b7e8587608
3 changed files with 20 additions and 26 deletions

View File

@ -8,16 +8,10 @@ use SPC\doctor\AsCheckItem;
use SPC\doctor\AsFixItem;
use SPC\doctor\CheckResult;
use SPC\doctor\OptionalCheck;
use SPC\exception\DownloaderException;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
use SPC\store\Downloader;
use SPC\store\FileSystem;
use SPC\store\PackageManager;
use SPC\store\pkg\Zig;
use SPC\store\SourcePatcher;
use SPC\toolchain\MuslToolchain;
use SPC\toolchain\ZigToolchain;
#[OptionalCheck([self::class, 'optionalCheck'])]

View File

@ -11,25 +11,10 @@ use SPC\store\LockFile;
class Zig extends CustomPackage
{
private static function getPath(): string
{
$arch = arch2gnu(php_uname('m'));
$os = match (PHP_OS_FAMILY) {
'Linux' => 'linux',
'Windows' => 'win',
'Darwin' => 'macos',
'BSD' => 'freebsd',
default => 'linux',
};
$packageName = "zig-{$arch}-{$os}";
return PKG_ROOT_PATH . "/{$packageName}";
}
public static function isInstalled(): bool
{
$path = self::getPath();
return file_exists("$path/zig") && file_exists("$path/zig-cc") && file_exists("$path/zig-c++");
return file_exists("{$path}/zig") && file_exists("{$path}/zig-cc") && file_exists("{$path}/zig-c++");
}
public function getSupportName(): array
@ -149,6 +134,21 @@ class Zig extends CustomPackage
];
}
private static function getPath(): string
{
$arch = arch2gnu(php_uname('m'));
$os = match (PHP_OS_FAMILY) {
'Linux' => 'linux',
'Windows' => 'win',
'Darwin' => 'macos',
'BSD' => 'freebsd',
default => 'linux',
};
$packageName = "zig-{$arch}-{$os}";
return PKG_ROOT_PATH . "/{$packageName}";
}
private function createZigCcScript(string $bin_dir): void
{
$script_path = __DIR__ . '/../scripts/zig-cc.sh';

View File

@ -14,10 +14,10 @@ class ZigToolchain implements ToolchainInterface
{
$arch = getenv('GNU_ARCH');
// Set environment variables for musl toolchain
GlobalEnvManager::putenv("SPC_LINUX_DEFAULT_CC=zig-cc");
GlobalEnvManager::putenv("SPC_LINUX_DEFAULT_CXX=zig-c++");
GlobalEnvManager::putenv("SPC_LINUX_DEFAULT_AR=ar");
GlobalEnvManager::putenv("SPC_LINUX_DEFAULT_LD=ld");
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CC=zig-cc');
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CXX=zig-c++');
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_AR=ar');
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_LD=ld');
GlobalEnvManager::addPathIfNotExists('/usr/local/musl/bin');
GlobalEnvManager::addPathIfNotExists("/usr/local/musl/{$arch}-linux-musl/bin");