2024-12-19 12:23:39 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
|
|
|
|
|
|
use SPC\exception\FileSystemException;
|
|
|
|
|
use SPC\exception\RuntimeException;
|
2025-06-09 09:24:31 +08:00
|
|
|
use SPC\util\executor\UnixCMakeExecutor;
|
2024-12-19 12:23:39 +08:00
|
|
|
|
|
|
|
|
trait libaom
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
*/
|
|
|
|
|
protected function build(): void
|
|
|
|
|
{
|
2025-06-27 20:28:59 +07:00
|
|
|
$cc = getenv('CC');
|
|
|
|
|
$cxx = getenv('CXX');
|
|
|
|
|
if (str_contains($cc, 'zig') && getenv('SPC_LIBC') === 'musl') {
|
2025-06-27 23:35:04 +07:00
|
|
|
f_putenv('CC=' . $cc . ' -D_POSIX_SOURCE');
|
|
|
|
|
f_putenv('CXX=' . $cxx . ' -D_POSIX_SOURCE');
|
2025-06-27 20:28:59 +07:00
|
|
|
}
|
2025-06-09 01:07:30 +08:00
|
|
|
UnixCMakeExecutor::create($this)
|
2025-06-09 09:26:39 +08:00
|
|
|
->setBuildDir("{$this->source_dir}/builddir")
|
2025-06-09 12:49:33 +08:00
|
|
|
->addConfigureArgs('-DAOM_TARGET_CPU=generic')
|
2025-06-09 01:07:30 +08:00
|
|
|
->build();
|
2025-06-27 20:28:59 +07:00
|
|
|
if (str_contains($cc, 'zig') && getenv('SPC_LIBC') === 'musl') {
|
2025-06-27 23:35:04 +07:00
|
|
|
f_putenv('CC=' . $cc);
|
|
|
|
|
f_putenv('CXX=' . $cxx);
|
2025-06-27 20:28:59 +07:00
|
|
|
}
|
2024-12-19 12:23:39 +08:00
|
|
|
$this->patchPkgconfPrefix(['aom.pc']);
|
|
|
|
|
}
|
|
|
|
|
}
|