2024-12-19 12:23:39 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
|
|
2026-05-22 11:59:13 +07:00
|
|
|
use SPC\builder\linux\SystemUtil;
|
2025-07-01 16:25:08 +07:00
|
|
|
use SPC\toolchain\ToolchainManager;
|
|
|
|
|
use SPC\toolchain\ZigToolchain;
|
2025-06-09 09:24:31 +08:00
|
|
|
use SPC\util\executor\UnixCMakeExecutor;
|
2026-05-22 11:49:15 +07:00
|
|
|
use SPC\util\SPCTarget;
|
2024-12-19 12:23:39 +08:00
|
|
|
|
|
|
|
|
trait libaom
|
|
|
|
|
{
|
|
|
|
|
protected function build(): void
|
|
|
|
|
{
|
2025-07-04 14:39:42 +07:00
|
|
|
$extra = getenv('SPC_COMPILER_EXTRA');
|
2025-07-01 16:25:08 +07:00
|
|
|
if (ToolchainManager::getToolchainClass() === ZigToolchain::class) {
|
2025-07-01 16:57:56 +07:00
|
|
|
$new = trim($extra . ' -D_GNU_SOURCE');
|
2025-07-04 14:39:42 +07:00
|
|
|
f_putenv("SPC_COMPILER_EXTRA={$new}");
|
2025-06-27 20:28:59 +07:00
|
|
|
}
|
2026-05-22 11:49:15 +07:00
|
|
|
$targetCpu = SPCTarget::getTargetArch();
|
|
|
|
|
if (str_starts_with($targetCpu, 'aarch')) {
|
|
|
|
|
$targetCpu = str_replace($targetCpu, 'aarch', 'arm');
|
|
|
|
|
}
|
2026-05-22 11:59:13 +07:00
|
|
|
if (!SystemUtil::findCommand('nasm') && !SystemUtil::findCommand('yasm')) {
|
|
|
|
|
$targetCpu = 'generic';
|
|
|
|
|
}
|
2025-06-09 01:07:30 +08:00
|
|
|
UnixCMakeExecutor::create($this)
|
2025-06-09 09:26:39 +08:00
|
|
|
->setBuildDir("{$this->source_dir}/builddir")
|
2026-05-22 11:49:15 +07:00
|
|
|
->addConfigureArgs(
|
|
|
|
|
"-DAOM_TARGET_CPU={$targetCpu}",
|
|
|
|
|
'-DCONFIG_RUNTIME_CPU_DETECT=1'
|
|
|
|
|
)
|
2025-06-09 01:07:30 +08:00
|
|
|
->build();
|
2025-07-04 14:39:42 +07:00
|
|
|
f_putenv("SPC_COMPILER_EXTRA={$extra}");
|
2024-12-19 12:23:39 +08:00
|
|
|
$this->patchPkgconfPrefix(['aom.pc']);
|
|
|
|
|
}
|
|
|
|
|
}
|