mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-10 10:25:36 +08:00
Compare commits
3 Commits
11e19db480
...
2b6d228bc3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b6d228bc3 | ||
|
|
7ebc7c0275 | ||
|
|
721ac4a390 |
@@ -4,9 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\unix\library;
|
||||
|
||||
use SPC\builder\linux\SystemUtil;
|
||||
use SPC\toolchain\ToolchainManager;
|
||||
use SPC\toolchain\ZigToolchain;
|
||||
use SPC\util\executor\UnixCMakeExecutor;
|
||||
use SPC\util\SPCTarget;
|
||||
|
||||
trait libaom
|
||||
{
|
||||
@@ -17,9 +19,19 @@ trait libaom
|
||||
$new = trim($extra . ' -D_GNU_SOURCE');
|
||||
f_putenv("SPC_COMPILER_EXTRA={$new}");
|
||||
}
|
||||
$targetCpu = SPCTarget::getTargetArch();
|
||||
if (str_starts_with($targetCpu, 'aarch')) {
|
||||
$targetCpu = str_replace('aarch', 'arm', $targetCpu);
|
||||
}
|
||||
if (!SystemUtil::findCommand('nasm') && !SystemUtil::findCommand('yasm')) {
|
||||
$targetCpu = 'generic';
|
||||
}
|
||||
UnixCMakeExecutor::create($this)
|
||||
->setBuildDir("{$this->source_dir}/builddir")
|
||||
->addConfigureArgs('-DAOM_TARGET_CPU=generic')
|
||||
->addConfigureArgs(
|
||||
"-DAOM_TARGET_CPU={$targetCpu}",
|
||||
'-DCONFIG_RUNTIME_CPU_DETECT=1'
|
||||
)
|
||||
->build();
|
||||
f_putenv("SPC_COMPILER_EXTRA={$extra}");
|
||||
$this->patchPkgconfPrefix(['aom.pc']);
|
||||
|
||||
@@ -127,4 +127,19 @@ class SPCTarget
|
||||
default => PHP_OS_FAMILY,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the target OS arch, e.g. x86_64, aarch64, arm, x86.
|
||||
*/
|
||||
public static function getTargetArch(): string
|
||||
{
|
||||
$target = (string) getenv('SPC_TARGET');
|
||||
return match (true) {
|
||||
str_starts_with($target, 'aarch64') => 'aarch64',
|
||||
str_starts_with($target, 'arm-') => 'arm',
|
||||
str_starts_with($target, 'x86_64-') => 'x86_64',
|
||||
str_starts_with($target, 'x86-') => 'x86',
|
||||
default => GNU_ARCH,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user