Skip to content

Commit a636438

Browse files
committed
Add suffix support for SPC_TARGET
1 parent c23c5ae commit a636438

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/SPC/util/SPCTarget.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public static function isTarget(string $target): bool
4343
return false;
4444
}
4545
$env = strtolower($env);
46+
// ver
47+
$env = explode('@', $env)[0];
4648
return $env === $target;
4749
}
4850

@@ -53,7 +55,9 @@ public static function isStaticTarget(): bool
5355
return false;
5456
}
5557
$env = strtolower($env);
56-
return str_ends_with($env, '-static') || $env === self::MUSL_STATIC;
58+
// ver
59+
$env = explode('@', $env)[0];
60+
return str_ends_with($env, '-static');
5761
}
5862

5963
public static function initTargetForToolchain(string $toolchain): void
@@ -80,4 +84,12 @@ public static function afterInitTargetForToolchain()
8084
$toolchainClass = self::TOOLCHAIN_LIST[$toolchain];
8185
(new $toolchainClass())->afterInit(getenv('SPC_TARGET'));
8286
}
87+
88+
public static function getTargetSuffix(): ?string
89+
{
90+
$target = getenv('SPC_TARGET');
91+
$target = strtolower($target);
92+
// ver
93+
return explode('@', $target)[1] ?? null;
94+
}
8395
}

src/SPC/util/toolchain/ClangNativeToolchain.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99
use SPC\builder\macos\SystemUtil as MacOSSystemUtil;
1010
use SPC\exception\WrongUsageException;
1111
use SPC\util\GlobalEnvManager;
12+
use SPC\util\SPCTarget;
1213

1314
class ClangNativeToolchain implements ToolchainInterface
1415
{
1516
public function initEnv(string $target): void
1617
{
18+
// native toolchain does not support versioning
19+
if (SPCTarget::getTargetSuffix() !== null) {
20+
throw new WrongUsageException('Clang native toolchain does not support versioning.');
21+
}
1722
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CC=clang');
1823
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CXX=clang++');
1924
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_AR=ar');

src/SPC/util/toolchain/GccNativeToolchain.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99
use SPC\builder\macos\SystemUtil as MacOSSystemUtil;
1010
use SPC\exception\WrongUsageException;
1111
use SPC\util\GlobalEnvManager;
12+
use SPC\util\SPCTarget;
1213

1314
class GccNativeToolchain implements ToolchainInterface
1415
{
1516
public function initEnv(string $target): void
1617
{
18+
// native toolchain does not support versioning
19+
if (SPCTarget::getTargetSuffix() !== null) {
20+
throw new WrongUsageException('gcc native toolchain does not support versioning.');
21+
}
1722
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CC=gcc');
1823
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CXX=g++');
1924
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_AR=ar');

0 commit comments

Comments
 (0)