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-10 15:37:39 +08:00
|
|
|
use SPC\store\FileSystem;
|
2025-06-09 09:24:31 +08:00
|
|
|
use SPC\util\executor\UnixCMakeExecutor;
|
2024-12-19 12:23:39 +08:00
|
|
|
|
|
|
|
|
trait libheif
|
|
|
|
|
{
|
2025-06-10 15:37:39 +08:00
|
|
|
public function patchBeforeBuild(): bool
|
|
|
|
|
{
|
|
|
|
|
if (!str_contains(file_get_contents($this->source_dir . '/CMakeLists.txt'), 'libbrotlienc')) {
|
|
|
|
|
FileSystem::replaceFileStr(
|
|
|
|
|
$this->source_dir . '/CMakeLists.txt',
|
|
|
|
|
'list(APPEND REQUIRES_PRIVATE "libbrotlidec")',
|
|
|
|
|
'list(APPEND REQUIRES_PRIVATE "libbrotlidec")' . "\n" . ' list(APPEND REQUIRES_PRIVATE "libbrotlienc")'
|
|
|
|
|
);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-19 12:23:39 +08:00
|
|
|
/**
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
*/
|
|
|
|
|
protected function build(): void
|
|
|
|
|
{
|
2025-06-09 01:07:30 +08:00
|
|
|
UnixCMakeExecutor::create($this)
|
|
|
|
|
->addConfigureArgs(
|
|
|
|
|
'--preset=release',
|
|
|
|
|
'-DWITH_EXAMPLES=OFF',
|
|
|
|
|
'-DWITH_GDK_PIXBUF=OFF',
|
|
|
|
|
'-DBUILD_TESTING=OFF',
|
|
|
|
|
'-DWITH_LIBSHARPYUV=ON', // optional: libwebp
|
|
|
|
|
'-DENABLE_PLUGIN_LOADING=OFF',
|
2024-12-19 12:23:39 +08:00
|
|
|
)
|
2025-06-09 01:07:30 +08:00
|
|
|
->build();
|
2024-12-19 12:23:39 +08:00
|
|
|
$this->patchPkgconfPrefix(['libheif.pc']);
|
|
|
|
|
}
|
|
|
|
|
}
|