MuslToolchain::class, 'gcc-native' => GccNativeToolchain::class, 'clang-native' => ClangNativeToolchain::class, 'msvc' => MSVCToolchain::class, 'zig' => ZigToolchain::class, ]; public static function isTarget(string $target): bool { $env = getenv('SPC_TARGET'); if ($env === false) { return false; } $env = strtolower($env); return $env === $target; } public static function isStaticTarget(): bool { $env = getenv('SPC_TARGET'); if ($env === false) { return false; } $env = strtolower($env); return str_ends_with($env, '-static') || $env === self::MUSL_STATIC; } public static function initTargetForToolchain(string $toolchain): void { $target = getenv('SPC_TARGET'); $toolchain = strtolower($toolchain); if (isset(self::TOOLCHAIN_LIST[$toolchain])) { $toolchainClass = self::TOOLCHAIN_LIST[$toolchain]; /* @var ToolchainInterface $toolchainClass */ (new $toolchainClass())->initEnv($target); } GlobalEnvManager::putenv("SPC_TOOLCHAIN={$toolchain}"); } public static function afterInitTargetForToolchain() { if (!getenv('SPC_TOOLCHAIN')) { throw new WrongUsageException('SPC_TOOLCHAIN not set'); } $toolchain = getenv('SPC_TOOLCHAIN'); if (!isset(self::TOOLCHAIN_LIST[$toolchain])) { throw new WrongUsageException("Unknown toolchain: {$toolchain}"); } $toolchainClass = self::TOOLCHAIN_LIST[$toolchain]; (new $toolchainClass())->afterInit(getenv('SPC_TARGET')); } }