diff --git a/src/SPC/doctor/item/ZigCheck.php b/src/SPC/doctor/item/ZigCheck.php index 3848895e..f5983f1d 100644 --- a/src/SPC/doctor/item/ZigCheck.php +++ b/src/SPC/doctor/item/ZigCheck.php @@ -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'])] diff --git a/src/SPC/store/pkg/Zig.php b/src/SPC/store/pkg/Zig.php index e8c5600c..f819da7a 100644 --- a/src/SPC/store/pkg/Zig.php +++ b/src/SPC/store/pkg/Zig.php @@ -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'; diff --git a/src/SPC/toolchain/ZigToolchain.php b/src/SPC/toolchain/ZigToolchain.php index d4e5a82d..493287fc 100644 --- a/src/SPC/toolchain/ZigToolchain.php +++ b/src/SPC/toolchain/ZigToolchain.php @@ -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");