2023-04-29 18:59:47 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
use SPC\exception\FileSystemException;
|
|
|
|
|
use SPC\exception\RuntimeException;
|
2023-04-29 18:59:47 +08:00
|
|
|
use SPC\store\FileSystem;
|
2025-06-09 09:24:31 +08:00
|
|
|
use SPC\util\executor\UnixCMakeExecutor;
|
2023-04-29 18:59:47 +08:00
|
|
|
|
|
|
|
|
trait brotli
|
|
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
2023-04-29 18:59:47 +08:00
|
|
|
protected function build(): void
|
|
|
|
|
{
|
2025-06-09 01:07:30 +08:00
|
|
|
UnixCMakeExecutor::create($this)
|
2025-06-09 09:26:39 +08:00
|
|
|
->setBuildDir("{$this->getSourceDir()}/build-dir")
|
2025-06-09 01:07:30 +08:00
|
|
|
->build();
|
|
|
|
|
|
2023-04-29 18:59:47 +08:00
|
|
|
$this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']);
|
2024-01-07 10:54:49 +08:00
|
|
|
shell()->cd(BUILD_ROOT_PATH . '/lib')->exec('ln -sf libbrotlicommon.a libbrotli.a');
|
2023-04-29 18:59:47 +08:00
|
|
|
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
|
|
|
|
if (str_starts_with($filename, 'libbrotli') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
|
|
|
|
|
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-08 13:27:03 +08:00
|
|
|
|
|
|
|
|
if (file_exists(BUILD_BIN_PATH . '/brotli')) {
|
|
|
|
|
unlink(BUILD_BIN_PATH . '/brotli');
|
|
|
|
|
}
|
2023-04-29 18:59:47 +08:00
|
|
|
}
|
|
|
|
|
}
|