From 0598eff9c5fce904dbb8052c79708ba4dcedefe6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 28 Jun 2025 23:13:40 +0800 Subject: [PATCH] Add suffix support for SPC_TARGET --- src/SPC/util/GlobalEnvManager.php | 2 +- src/SPC/util/SPCTarget.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index aaab1ae1..a6fe2987 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -78,7 +78,7 @@ class GlobalEnvManager // auto-select toolchain based on target and OS temporarily // TODO: use 'zig' instead of 'gcc-native' when ZigToolchain is implemented - $toolchain = match (getenv('SPC_TARGET')) { + $toolchain = match (SPCTarget::getTargetName()) { SPCTarget::MUSL_STATIC, SPCTarget::MUSL => SystemUtil::isMuslDist() ? 'gcc-native' : 'musl', SPCTarget::MACHO => 'clang-native', SPCTarget::MSVC_STATIC => 'msvc', diff --git a/src/SPC/util/SPCTarget.php b/src/SPC/util/SPCTarget.php index ec7308bf..265c3d51 100644 --- a/src/SPC/util/SPCTarget.php +++ b/src/SPC/util/SPCTarget.php @@ -85,6 +85,14 @@ class SPCTarget (new $toolchainClass())->afterInit(getenv('SPC_TARGET')); } + public static function getTargetName(): ?string + { + $target = getenv('SPC_TARGET'); + $target = strtolower($target); + // ver + return explode('@', $target)[0]; + } + public static function getTargetSuffix(): ?string { $target = getenv('SPC_TARGET');