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;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
FileSystem::resetDir($this->source_dir . '/build-dir');
|
|
|
|
|
shell()->cd($this->source_dir . '/build-dir')
|
|
|
|
|
->exec(
|
2023-10-23 00:37:28 +08:00
|
|
|
'cmake ' .
|
2023-04-29 18:59:47 +08:00
|
|
|
"{$this->builder->makeCmakeArgs()} " .
|
|
|
|
|
'-DBUILD_SHARED_LIBS=OFF ' .
|
|
|
|
|
'..'
|
|
|
|
|
)
|
|
|
|
|
->exec("cmake --build . -j {$this->builder->concurrency}")
|
|
|
|
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
|
|
|
|
$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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|