Add homebrew llvm version toolchain support

This commit is contained in:
crazywhalecc
2026-03-20 11:20:42 +08:00
parent 00649d816e
commit e9be3a41db
4 changed files with 42 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ namespace StaticPHP\Doctor\Item;
use StaticPHP\Attribute\Doctor\CheckItem;
use StaticPHP\Attribute\Doctor\FixItem;
use StaticPHP\Doctor\CheckResult;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\System\MacOSUtil;
class MacOSToolCheck
@@ -58,6 +59,20 @@ class MacOSToolCheck
return CheckResult::ok();
}
#[CheckItem('if homebrew llvm are installed', limit_os: 'Darwin')]
public function checkBrewLLVM(): ?CheckResult
{
if (getenv('SPC_USE_LLVM') === 'brew') {
$homebrew_prefix = getenv('HOMEBREW_PREFIX') ?: (SystemTarget::getTargetArch() === 'aarch64' ? '/opt/homebrew' : '/usr/local/homebrew');
if (MacOSUtil::findCommand('clang', ["{$homebrew_prefix}/opt/llvm/bin"]) === null) {
return CheckResult::fail('Homebrew llvm is not installed', 'brew', ['missing' => ['llvm']]);
}
return CheckResult::ok();
}
return null;
}
#[CheckItem('if bison version is 3.0 or later', limit_os: 'Darwin')]
public function checkBisonVersion(array $command_path = []): ?CheckResult
{