mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 15:25:41 +08:00
ClangBrew, ClangNative and GccNative now export SPC_DEFAULT_RANLIB alongside SPC_DEFAULT_AR. UnixCMakeExecutor honours both when generating the Linux toolchain file, so cmake uses the toolchain's ar/ranlib (e.g. zig-ar/zig-ranlib for archives that the system ranlib does not understand) instead of /usr/bin/ranlib.
23 lines
901 B
PHP
23 lines
901 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_RANLIB={$homebrew_prefix}/opt/llvm/bin/llvm-ranlib");
|
|
GlobalEnvManager::putenv('SPC_DEFAULT_LD=ld');
|
|
GlobalEnvManager::addPathIfNotExists("{$homebrew_prefix}/opt/llvm/bin");
|
|
}
|
|
}
|