mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-07 08:45:40 +08:00
22 lines
801 B
PHP
22 lines
801 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace StaticPHP\Toolchain;
|
||
|
|
|
||
|
|
use StaticPHP\Runtime\SystemTarget;
|
||
|
|
use StaticPHP\Util\GlobalEnvManager;
|
||
|
|
|
||
|
|
class ClangBrewToolchain extends ClangNativeToolchain
|
||
|
|
{
|
||
|
|
public function initEnv(): void
|
||
|
|
{
|
||
|
|
$homebrew_prefix = getenv('HOMEBREW_PREFIX') ?: (SystemTarget::getTargetArch() === 'aarch64' ? '/opt/homebrew' : '/usr/local/homebrew');
|
||
|
|
GlobalEnvManager::putenv("SPC_DEFAULT_CC={$homebrew_prefix}/opt/llvm/bin/clang");
|
||
|
|
GlobalEnvManager::putenv("SPC_DEFAULT_CXX={$homebrew_prefix}/opt/llvm/bin/clang++");
|
||
|
|
GlobalEnvManager::putenv("SPC_DEFAULT_AR={$homebrew_prefix}/opt/llvm/bin/llvm-ar");
|
||
|
|
GlobalEnvManager::putenv('SPC_DEFAULT_LD=ld');
|
||
|
|
GlobalEnvManager::addPathIfNotExists("{$homebrew_prefix}/opt/llvm/bin");
|
||
|
|
}
|
||
|
|
}
|