mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
cs fixes
This commit is contained in:
parent
0a33fba23e
commit
b7e8587608
@ -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'])]
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user