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;
|
|
|
|
|
use SPC\exception\WrongUsageException;
|
2023-08-27 03:05:53 +08:00
|
|
|
use SPC\store\FileSystem;
|
2023-08-20 19:51:45 +08:00
|
|
|
|
2023-04-29 18:59:47 +08:00
|
|
|
trait libwebp
|
|
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
* @throws WrongUsageException
|
|
|
|
|
*/
|
|
|
|
|
protected function build(): void
|
2023-04-29 18:59:47 +08:00
|
|
|
{
|
2023-08-27 03:05:53 +08:00
|
|
|
// CMake needs a clean build directory
|
|
|
|
|
FileSystem::resetDir($this->source_dir . '/build');
|
|
|
|
|
// Start build
|
|
|
|
|
shell()->cd($this->source_dir . '/build')
|
2023-04-29 18:59:47 +08:00
|
|
|
->exec(
|
2023-08-27 03:05:53 +08:00
|
|
|
"{$this->builder->configure_env} cmake " .
|
|
|
|
|
$this->builder->makeCmakeArgs() . ' ' .
|
|
|
|
|
'-DBUILD_SHARED_LIBS=OFF ' .
|
|
|
|
|
'-DWEBP_BUILD_EXTRAS=ON ' .
|
|
|
|
|
'..'
|
2023-04-29 18:59:47 +08:00
|
|
|
)
|
2023-08-27 03:05:53 +08:00
|
|
|
->exec("cmake --build . -j {$this->builder->concurrency}")
|
|
|
|
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
|
|
|
|
// patch pkgconfig
|
2023-09-12 00:09:49 +08:00
|
|
|
$this->patchPkgconfPrefix(['libsharpyuv.pc', 'libwebp.pc', 'libwebpdecoder.pc', 'libwebpdemux.pc', 'libwebpmux.pc'], PKGCONF_PATCH_PREFIX | PKGCONF_PATCH_LIBDIR);
|
|
|
|
|
$this->patchPkgconfPrefix(['libsharpyuv.pc'], PKGCONF_PATCH_CUSTOM, ['/^includedir=.*$/m', 'includedir=${prefix}/include/webp']);
|
2023-05-10 02:04:08 +08:00
|
|
|
$this->cleanLaFiles();
|
2023-04-29 18:59:47 +08:00
|
|
|
}
|
|
|
|
|
}
|