mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
chore
This commit is contained in:
parent
f69f8d1e4a
commit
a8dcfce99e
@ -10,6 +10,9 @@ use SPC\builder\macos\SystemUtil as MacOSSystemUtil;
|
|||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\util\GlobalEnvManager;
|
use SPC\util\GlobalEnvManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toolchain implementation for system clang compiler.
|
||||||
|
*/
|
||||||
class ClangNativeToolchain implements ToolchainInterface
|
class ClangNativeToolchain implements ToolchainInterface
|
||||||
{
|
{
|
||||||
public function initEnv(): void
|
public function initEnv(): void
|
||||||
@ -20,6 +23,9 @@ class ClangNativeToolchain implements ToolchainInterface
|
|||||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_LD=ld');
|
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_LD=ld');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws WrongUsageException
|
||||||
|
*/
|
||||||
public function afterInit(): void
|
public function afterInit(): void
|
||||||
{
|
{
|
||||||
foreach (['CC', 'CXX', 'AR', 'LD'] as $env) {
|
foreach (['CC', 'CXX', 'AR', 'LD'] as $env) {
|
||||||
|
|||||||
@ -15,6 +15,8 @@ class GlobalEnvManager
|
|||||||
{
|
{
|
||||||
private static array $env_cache = [];
|
private static array $env_cache = [];
|
||||||
|
|
||||||
|
private static bool $initialized = false;
|
||||||
|
|
||||||
public static function getInitializedEnv(): array
|
public static function getInitializedEnv(): array
|
||||||
{
|
{
|
||||||
return self::$env_cache;
|
return self::$env_cache;
|
||||||
@ -28,6 +30,9 @@ class GlobalEnvManager
|
|||||||
*/
|
*/
|
||||||
public static function init(): void
|
public static function init(): void
|
||||||
{
|
{
|
||||||
|
if (self::$initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Check pre-defined env vars exists
|
// Check pre-defined env vars exists
|
||||||
if (getenv('BUILD_ROOT_PATH') === false) {
|
if (getenv('BUILD_ROOT_PATH') === false) {
|
||||||
throw new RuntimeException('You must include src/globals/internal-env.php before using GlobalEnvManager');
|
throw new RuntimeException('You must include src/globals/internal-env.php before using GlobalEnvManager');
|
||||||
@ -85,6 +90,7 @@ class GlobalEnvManager
|
|||||||
self::putenv("{$k}={$v}");
|
self::putenv("{$k}={$v}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self::$initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function putenv(string $val): void
|
public static function putenv(string $val): void
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user