2023-04-29 18:59:47 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
|
|
2025-06-09 09:24:31 +08:00
|
|
|
use SPC\util\executor\UnixCMakeExecutor;
|
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
|
|
|
protected function build(): void
|
2023-04-29 18:59:47 +08:00
|
|
|
{
|
2025-12-01 16:55:52 +01:00
|
|
|
$cflags = getenv('SPC_DEFAULT_C_FLAGS') ?: getenv('CFLAGS') ?: '';
|
|
|
|
|
$has_avx2 = str_contains($cflags, '-mavx2') || str_contains($cflags, '-march=x86-64-v2') || str_contains($cflags, '-march=x86-64-v3');
|
2025-06-09 01:07:30 +08:00
|
|
|
UnixCMakeExecutor::create($this)
|
2025-12-01 16:55:52 +01:00
|
|
|
->addConfigureArgs(
|
2025-12-01 17:16:59 +01:00
|
|
|
'-DWEBP_BUILD_EXTRAS=OFF',
|
2025-12-01 16:55:52 +01:00
|
|
|
'-DWEBP_ENABLE_SIMD=' . ($has_avx2 ? 'ON' : 'OFF'),
|
|
|
|
|
)
|
2025-06-09 01:07:30 +08:00
|
|
|
->build();
|
2023-08-27 03:05:53 +08:00
|
|
|
// patch pkgconfig
|
2025-07-22 22:09:45 +08:00
|
|
|
$this->patchPkgconfPrefix(patch_option: PKGCONF_PATCH_PREFIX | PKGCONF_PATCH_LIBDIR);
|
2023-09-12 00:09:49 +08:00
|
|
|
$this->patchPkgconfPrefix(['libsharpyuv.pc'], PKGCONF_PATCH_CUSTOM, ['/^includedir=.*$/m', 'includedir=${prefix}/include/webp']);
|
2023-04-29 18:59:47 +08:00
|
|
|
}
|
|
|
|
|
}
|