mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Add suffix support for SPC_TARGET
This commit is contained in:
parent
c23c5ae614
commit
a6364389ba
@ -43,6 +43,8 @@ class SPCTarget
|
||||
return false;
|
||||
}
|
||||
$env = strtolower($env);
|
||||
// ver
|
||||
$env = explode('@', $env)[0];
|
||||
return $env === $target;
|
||||
}
|
||||
|
||||
@ -53,7 +55,9 @@ class SPCTarget
|
||||
return false;
|
||||
}
|
||||
$env = strtolower($env);
|
||||
return str_ends_with($env, '-static') || $env === self::MUSL_STATIC;
|
||||
// ver
|
||||
$env = explode('@', $env)[0];
|
||||
return str_ends_with($env, '-static');
|
||||
}
|
||||
|
||||
public static function initTargetForToolchain(string $toolchain): void
|
||||
@ -80,4 +84,12 @@ class SPCTarget
|
||||
$toolchainClass = self::TOOLCHAIN_LIST[$toolchain];
|
||||
(new $toolchainClass())->afterInit(getenv('SPC_TARGET'));
|
||||
}
|
||||
|
||||
public static function getTargetSuffix(): ?string
|
||||
{
|
||||
$target = getenv('SPC_TARGET');
|
||||
$target = strtolower($target);
|
||||
// ver
|
||||
return explode('@', $target)[1] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,11 +9,16 @@ use SPC\builder\linux\SystemUtil as LinuxSystemUtil;
|
||||
use SPC\builder\macos\SystemUtil as MacOSSystemUtil;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
class ClangNativeToolchain implements ToolchainInterface
|
||||
{
|
||||
public function initEnv(string $target): void
|
||||
{
|
||||
// native toolchain does not support versioning
|
||||
if (SPCTarget::getTargetSuffix() !== null) {
|
||||
throw new WrongUsageException('Clang native toolchain does not support versioning.');
|
||||
}
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CC=clang');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CXX=clang++');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_AR=ar');
|
||||
|
||||
@ -9,11 +9,16 @@ use SPC\builder\linux\SystemUtil as LinuxSystemUtil;
|
||||
use SPC\builder\macos\SystemUtil as MacOSSystemUtil;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
class GccNativeToolchain implements ToolchainInterface
|
||||
{
|
||||
public function initEnv(string $target): void
|
||||
{
|
||||
// native toolchain does not support versioning
|
||||
if (SPCTarget::getTargetSuffix() !== null) {
|
||||
throw new WrongUsageException('gcc native toolchain does not support versioning.');
|
||||
}
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CC=gcc');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CXX=g++');
|
||||
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_AR=ar');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user